LAMP鏋舵瀯搴旂敤瀹炴垬鈥擜pache鏈嶅姟鍩轰簬绔彛铏氭嫙涓绘満閰嶇疆

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LAMP鏋舵瀯搴旂敤瀹炴垬鈥擜pache鏈嶅姟鍩轰簬绔彛铏氭嫙涓绘満閰嶇疆相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/block' title='block'>block   闀挎寜   浜岀淮   netstat   example   浠嬬粛   not   mkdir   fir   

LAMP鏋舵瀯搴旂敤瀹炴垬鈥擜pache鏈嶅姟鍩轰簬绔彛铏氭嫙涓绘満閰嶇疆

LAMP鏋舵瀯搴旂敤瀹炴垬鈥擜pache鏈嶅姟

鍩轰簬绔彛铏氭嫙涓绘満閰嶇疆

鍓嶉潰浠嬬粛浜嗗熀浜庡煙鍚嶃€両P鐨勮櫄鎷熶富鏈洪厤缃紝瀹為檯鐢熶骇鐜涓娇鐢ㄦ渶澶氱殑杩樻槸鍩轰簬鍩熷悕鐨勮櫄鎷熶富鏈猴紝浠婂ぉ浠嬬粛鐨勫熀浜庣鍙g殑铏氭嫙涓绘満涔熶笉甯哥敤锛屼絾鐢ㄧ殑鏈€澶氱殑鍦烘櫙灏辨槸锛氬叕鍙稿唴缃戯紙濡傜綉绔欏悗鍙伴〉闈€佸叾瀹冨彂甯冪被鐨勯〉闈級
鍩轰簬绔彛鐨勮櫄鎷熼厤缃潪甯哥畝鍗?br/>榛樿鎯呭喌http榛樿鐩戝惉鐨勬槸80绔彛锛屾墍浠ラ厤缃熀浜庣鍙g殑铏氭嫙涓绘満锛屽氨鏄鍔犵浉搴旂殑鐩戝惉绔彛

涓€锛氶厤缃箣鍓嶅浠介厤缃枃浠?/h3>

[root@Centos extra]# cp httpd-vhosts.conf httpd-vhosts.conf.$(date +%F)
[root@Centos extra]# ls
httpd-autoindex.conf httpd-info.conf httpd-mpm.conf httpd-userdir.conf httpd-dav.conf httpd-languages.conf httpd-multilang-errordoc.conf
httpd-vhosts.conf httpd-vhosts.conf.2016-09-09
httpd-default.conf httpd-manual.conf httpd-ssl.conf proxy-html.conf

浜岋細閰嶇疆绔欑偣鐩綍锛堟柟渚挎祴璇曚笉鍚岀鍙o級

[root@Centos extra]# mkdir -p /data/www/blog/
[root@Centos extra]# echo "welcome to the server of blogs">>/data/www/blog/index.html
[root@Centos extra]# cat /data/www/blog/index.html
welcome to the server of blogs

涓夛細閰嶇疆铏氭嫙涓绘満閰嶇疆鏂囦欢

1銆侀厤缃墠杩橀渶瑕佸埌涓婚厤缃枃浠朵腑澧炲姞鐩綍鎺у埗鏉冮檺
[root@Centos extra]# vi ../httpd.conf
<Directory "/data/www/bbs">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
澧炲姞濡備笅閰嶇疆
<Directory "/data/www/blog">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
瀹為檯鐢熶骇鐜涓繕鏄娇鐢ㄨ鑼冭矾寰勬瘮杈冨ソ锛屼篃鍙互灏嗛厤缃慨鏀规垚濡備笅
[root@Centos extra]# vi ../httpd.conf
<Directory "/data/www">
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
瀵逛笂涓€绾х洰褰曠粺涓€鎺堟潈

2銆佷富閰嶇疆鏂囦欢澧炲姞鐩戝惉绔彛
[root@Centos extra]# vi ../httpd.conf

This is the main Apache HTTP server configuration file. It contains the
configuration directives that give the server its instructions.
See <URL:http://httpd.apache.org/docs/2.4/>; for detailed information.
............................鍏朵腑涓€浜涢厤缃儴鍒嗙渷鐣?/p>

#Listen 12.34.56.78:80
Listen 80
Listen 8888
Listen 9999

3銆侀厤缃櫄鎷熶富鏈洪厤缃枃浠?br/>[root@Centos extra]# vi httpd-vhosts.conf
Virtual Hosts

VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for all requests that do not
#match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost 192.168.1.20:8888>
ServerAdmin admini@abc.com
DocumentRoot "/data/www/bbs"
ServerName 192.168.1.20
ServerAlias abc.com
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
</VirtualHost>

<VirtualHost 192.168.1.2:9999>
ServerAdmin admini@abc.com
DocumentRoot "/data/www/blog"
ServerName 192.168.1.2
ServerAlias abc.com
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
</VirtualHost>

4銆佹鏌ラ厤缃€侀噸鍚湇鍔?br/>[root@Centos extra]# ../../bin/apachectl -t
Syntax OK
[root@Centos extra]# ../../bin/apachectl graceful
[root@Centos extra]# ps -ef |grep http
root 23901019:42 ? 00:00:00 /application/apache2.4.23/bin/httpd -k graceful
daemon 2725 2390 0 20:33 ? 00:00:00 /application/apache2.4.23/bin/httpd -k graceful
daemon 2726 2390 0 20:33 ? 00:00:00 /application/apache2.4.23/bin/httpd -k graceful
daemon 2727 2390 0 20:33 ? 00:00:00 /application/apache2.4.23/bin/httpd -k graceful
root 2835 1934 0 20:39 pts/1 00:00:00 grep http
[root@Centos extra]# netstat -lnt |grep 8888
tcp 0 0 :::8888 ::: LISTEN
[root@Centos extra]# netstat -lnt |grep 9999
tcp 0 0 :::9999 :::
LISTEN

鍥涳細娴嬭瘯閰嶇疆

[root@Centos extra]# cat /data/www/bbs/index.html
welcome to bbs.abc.com
192.168.1.20:80 this server is the server of bbs stie
[root@Centos extra]# cat /data/www/blog/index.html
welcome to the server of blogs
鏈湴娴忚鍣ㄦ祴璇?br/>鎶€鏈浘鐗? src=
鎶€鏈浘鐗? src=
缁忚繃娴嬭瘯锛岃闂甯革紝琛ㄦ槑閰嶇疆姝g‘

浜旓細涓绘満鍒悕鐨勫簲鐢?/h2>

淇敼涓嬪垰鍒氱殑铏氭嫙涓绘満閰嶇疆
#port bash ip
<VirtualHost 192.168.1.20:8888>
ServerAdmin admini@abc.com
DocumentRoot "/data/www/bbs"
ServerName 192.168.1.20
ServerAlias abc.com
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
</VirtualHost>
#port bash name
<VirtualHost *:9999>
ServerAdmin admini@abc.com
DocumentRoot "/data/www/blog"
ServerName blog.abc.com
ServerAlias blog1.com
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
[root@Centos extra]# ../../bin/apachectl -t
Syntax OK
[root@Centos extra]# ../../bin/apachectl graceful
鎶€鏈浘鐗? src=
琛ㄦ槑鍒悕閰嶇疆涔熸槸姝g‘鐨?br/>鎶€鏈浘鐗? src=
闀挎寜浜岀淮鐮佸浘鐗囧叧娉ㄥ井淇″叕浼楀彿

以上是关于LAMP鏋舵瀯搴旂敤瀹炴垬鈥擜pache鏈嶅姟鍩轰簬绔彛铏氭嫙涓绘満閰嶇疆的主要内容,如果未能解决你的问题,请参考以下文章

鎬庝箞鐢ˋPI缃戝叧鏋勫缓寰湇鍔★綔鏋舵瀯

鏈€鎶€鏈?| API缃戝叧鏈嶅姟鐔旀柇闄嶇骇瀹炶返

Linux绯荤粺SSH鏈嶅姟涔?sshkey瀵嗛挜璁よ瘉瀹炴垬

浣犺繕鍦ㄧ湅鍒嗗竷寮忓井鏈嶅姟鏋舵瀯锛熻繖绡囨枃绔犺冻澶熻浣犲涔犲埌

涓插彛鏈嶅姟鍣ㄧ瓑搴旂敤浜庢薄姘村鐞嗗巶鐨勮嚜鍔ㄧ洃鎺у拰鎺у埗绠$悊

銆岀81鏈熴€? 鏋舵瀯鍒嗘瀽 -Tomcat 璇锋眰娴佺▼