啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf
/ W# Y. p/ b2 D7 ]3 E2 d0 F. Y8 k2. 曉 # VirtualHost example:
/ V5 P+ u+ C2 E) j% N- 嗡乩virtual server 閮剖,靘憒:& P4 L! E; w$ O( @
- #2014/10/02 add: ?* a: w: X7 \7 H. v
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
7 K; }, h5 g3 k- t- `+ ] - ServerAdmin [email protected]& e H& c B; C
- DocumentRoot /home/coav4u/public_html
1 @% z% l5 d6 c; W - ServerName av4u.co( t& B3 O' W2 p9 h7 m5 b
- ErrorLog logs/www.av4u.co-error_log
' K( X; h/ o: Q) k M - CustomLog logs/www.av4u.co-access_log common/ d* u9 y$ `3 w. i7 K
- </VirtualHost>+ J% B% b6 v! R& `- m% w' J
- <VirtualHost 192.168.1.12:80>
- u9 a, F5 ^6 J0 f" y [ - ServerAdmin [email protected]/ k# [& ?# N7 o8 A6 b0 w1 p3 `; ~
- DocumentRoot /home/coav4u/public_html- R' I3 d2 Z; @8 Q3 k- m* N* |+ b
- ServerName www.av4u.co8 X5 e! i1 x, O, _
- ErrorLog logs/www.av4u.co-error_log4 a! n; Q. \0 z: P: b; }
- CustomLog logs/www.av4u.co-access_log common
8 u2 `' r# a6 M" F( j0 `# \" [7 _ - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
1 J- t+ b3 ~+ T0 |) a5 X) K+ A3. Apache 0 G% r1 d, O- C! ~* a: C% V% Z4 O
service httpd restart #隞叵oot頨怠 --->摰
! r" C C0 \& \) _! d 閮: service httpd start # * M. M" x! T2 r
service httpd start #甇& q/ L7 {' x/ |$ K9 i1 H+ i4 A
寞鈭( X! V b5 B- E4 ~6 M+ V$ ?' O
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)
" k( |: g# U( X靘憒:
: P8 ]6 F. i! B" S% @6 bvirtual1.conf
9 w- C8 ^' [: G& x. `- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫- \) }; N* |6 E4 G t! Q% {
- ServerAdmin [email protected]" N! L2 ^0 Z# `3 |
- DocumentRoot /home/coav4u/public_html1 H6 P P+ ?- f/ M
- ServerName av4u.co
9 D0 y7 q' J6 Q" h& Z7 `; Q* ^+ Q8 K - ErrorLog logs/www.av4u.co-error_log
/ `( H+ F( H0 I' ?6 z( ^ Y8 Z - CustomLog logs/www.av4u.co-access_log common, m( C9 e q* N2 ^* s- F' a
- </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
4 W, X# F) ~- `2 w- <VirtualHost 192.168.1.12:80>
& p$ u+ B: n/ q7 r - ServerAdmin [email protected]: q% h3 M1 N3 k
- DocumentRoot /home/coav4u/public_html
5 J5 ?; X" e( U2 b/ P+ Z' [ - ServerName www.av4u.co. ?* a3 |/ s) G. Z }
- ErrorLog logs/www.av4u.co-error_log
3 t. d+ C0 R2 Y9 O5 Z - CustomLog logs/www.av4u.co-access_log common% H D* I$ q" d: U8 {# {
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
4 ^) ]* ^7 H5 U( C2 ~" A" M% R) p雿臬箇 error:
% |% x0 {3 m# g [warn] _default_ VirtualHost overlap on port 80, the first has precedence$ ]5 t' F* R8 {0 x! ]2 f5 S% z# p
SOL:
: u( U8 k0 |4 t& @" h {望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
1 _$ N/ m! ~( G" f% Vhttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 4 }+ ~& Y9 i; m9 t, w5 p) g% D, |
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> % m7 F6 J5 r. i; M- _$ ~
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>3 s6 H- s( v: z/ V4 b8 w% H+ w
# y6 f4 J. U+ O( Y
$ [. H) R( K, M% R( s1 q: n
) J7 x3 L' H0 j# |: \ |
|