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/>
缁忚繃娴嬭瘯锛岃闂甯革紝琛ㄦ槑閰嶇疆姝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
琛ㄦ槑鍒悕閰嶇疆涔熸槸姝g‘鐨?br/>
闀挎寜浜岀淮鐮佸浘鐗囧叧娉ㄥ井淇″叕浼楀彿
以上是关于LAMP鏋舵瀯搴旂敤瀹炴垬鈥擜pache鏈嶅姟鍩轰簬绔彛铏氭嫙涓绘満閰嶇疆的主要内容,如果未能解决你的问题,请参考以下文章
Linux绯荤粺SSH鏈嶅姟涔?sshkey瀵嗛挜璁よ瘉瀹炴垬
浣犺繕鍦ㄧ湅鍒嗗竷寮忓井鏈嶅姟鏋舵瀯锛熻繖绡囨枃绔犺冻澶熻浣犲涔犲埌