啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf! U& k( z2 d3 A+ ~# F" L
2. 曉 # VirtualHost example:
k. I) r3 I/ w/ I; u. W& R- 嗡乩virtual server 閮剖,靘憒:
9 M: w4 M! G2 D - #2014/10/02 add' P& u* X; h' C% h( y" b
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫# ]/ @) p5 Z" Y$ C8 X
- ServerAdmin [email protected]" e2 T3 P) ^ g
- DocumentRoot /home/coav4u/public_html
, h; w: @, P4 z o$ c. J - ServerName av4u.co3 u, Y A4 F' W1 Z
- ErrorLog logs/www.av4u.co-error_log* f; ~! b' t1 m1 r$ R
- CustomLog logs/www.av4u.co-access_log common: r* Y6 T; c m. B$ p+ d) Z
- </VirtualHost>& i+ y/ @( n& |& l0 M: @7 j
- <VirtualHost 192.168.1.12:80>
- j7 M- I& V. G; [" b( Y - ServerAdmin [email protected]
+ i' @* X7 F2 q7 K2 U S9 q - DocumentRoot /home/coav4u/public_html
3 p$ [( R5 w: z( _! O - ServerName www.av4u.co
! t& p; z q" ^3 { - ErrorLog logs/www.av4u.co-error_log* l! S6 `. k* ~" {0 U8 c! }
- CustomLog logs/www.av4u.co-access_log common
, X! m9 l9 s w( F2 Q0 }9 L - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
; ?6 \ Z% M# q3. Apache
; {) A- t) h" I2 p) a: G service httpd restart #隞叵oot頨怠 --->摰. @' c$ c M; h
閮: service httpd start # # `$ f& n1 ^0 ~! f1 ]
service httpd start #甇
9 O. b6 U# U0 b0 |( D0 ], f寞鈭8 m6 l; g" b9 J$ }* L9 ?0 x T
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)0 l: W0 @8 P+ p; a8 P
靘憒: $ m0 @# @( p& p" s; i" o
virtual1.conf6 N6 r- I* n5 P% R; _" A( J8 b% O7 e& L
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫+ v- R' F* X( `, {9 Y
- ServerAdmin [email protected]
1 X5 K: w/ Q& L - DocumentRoot /home/coav4u/public_html' q* R. }" M3 e+ @" |% p" l2 X1 o' H/ u
- ServerName av4u.co
! Y5 o! k9 m" u% h2 M! `; n - ErrorLog logs/www.av4u.co-error_log7 n, |- d9 i8 E% ]. u; h, b
- CustomLog logs/www.av4u.co-access_log common' c4 P# {5 c9 Y: x/ \( ?' f
- </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
7 }& H4 l' P+ X( O) o- r9 J- <VirtualHost 192.168.1.12:80>
3 N! V, {9 Y+ P1 p" _( [ - ServerAdmin [email protected]! d( _6 M$ x2 r" f9 @% N
- DocumentRoot /home/coav4u/public_html% M" h/ n- e& H$ D5 ~
- ServerName www.av4u.co; V+ @3 i2 {# j5 C# ?9 B* V! W; z
- ErrorLog logs/www.av4u.co-error_log8 X9 W% I3 k& F5 l6 a3 }+ ]
- CustomLog logs/www.av4u.co-access_log common. \ @; Y' S4 ^
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
! C5 ]- ]# Y) n' x雿臬箇 error:
. C2 s) A, G' o+ }6 a3 T [warn] _default_ VirtualHost overlap on port 80, the first has precedence) [ T* v Y4 ]( ^0 M f" k
SOL:
/ F/ z6 L& X. @0 g9 x! i望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
5 R: i" H9 D( L9 lhttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 . L8 a4 _9 F( f+ c+ {& j9 V
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> m) o, m+ ]" _ R% w6 k
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>! g" e4 S* X& J6 u+ {
2 l$ C6 V8 Q7 [2 z3 Y$ g* I8 j3 g9 v
# `2 n2 d+ v$ v6 b t/ k2 w: U* j" z0 z9 u G
|
|