啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf
6 J# H. |% t2 |3 u) G' _+ G2. 曉 # VirtualHost example:7 G: l6 [$ f9 Q! D! V0 B" Z
- 嗡乩virtual server 閮剖,靘憒:
8 _+ \9 B# M. n; ~$ B - #2014/10/02 add. g$ S( y3 A5 o
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫! R+ t" M7 U* P x/ S' X& g# C G
- ServerAdmin [email protected]* Y! b" o. S% X, k" a0 J9 A
- DocumentRoot /home/coav4u/public_html- e& x- `# L+ S% L, e, d% b
- ServerName av4u.co# {' ~/ Y% U" s7 V- Y; |4 Z X
- ErrorLog logs/www.av4u.co-error_log
* k! s* `% Y, h( D' e - CustomLog logs/www.av4u.co-access_log common/ X! ^' m/ S$ F
- </VirtualHost>3 v! j7 u8 I- P3 }0 C& ^1 L
- <VirtualHost 192.168.1.12:80>0 I, L; | o1 `6 [
- ServerAdmin [email protected]0 ?8 p3 n$ m- g. B% a
- DocumentRoot /home/coav4u/public_html/ T7 F8 V/ c' S+ x1 F3 O" K6 O3 `
- ServerName www.av4u.co4 c; I3 x+ y, @8 n) Z3 ^7 a6 }
- ErrorLog logs/www.av4u.co-error_log
( G8 {$ {0 d4 t0 e& g - CustomLog logs/www.av4u.co-access_log common
" T' E/ M- u* p# X - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
6 v; E1 v+ ?9 b9 ~3. Apache : \0 D& l& j0 b2 ?
service httpd restart #隞叵oot頨怠 --->摰
7 k% \- e3 r e. u 閮: service httpd start # 3 k5 q0 w* Q! g$ ?# |" J
service httpd start #甇2 f% u% ], {- p1 v2 X+ z
寞鈭
& U; j# ?9 F5 Q, N/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)
+ ^$ X% H1 K# X0 K" V% K" F靘憒: o p @ H& N; z2 V
virtual1.conf
+ C7 u* \7 p: ]- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
: e6 c; G! P0 i3 G' b - ServerAdmin [email protected]
* H$ h; @9 ]- T! h7 b - DocumentRoot /home/coav4u/public_html' d) S3 `% D. k0 y
- ServerName av4u.co
/ [4 P* Y2 N7 Q$ _* Z - ErrorLog logs/www.av4u.co-error_log; [6 ~0 Q; c" d& s( n% ?
- CustomLog logs/www.av4u.co-access_log common7 x2 G: A( i# y& W% i# k3 L
- </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
H% W) Y3 q) G- <VirtualHost 192.168.1.12:80>$ Q( P: z* v6 ?1 i8 k& g
- ServerAdmin [email protected]+ Y) U7 T7 \3 i0 f
- DocumentRoot /home/coav4u/public_html
) O: Y1 L+ [/ R$ p - ServerName www.av4u.co- n) R* C9 l: D
- ErrorLog logs/www.av4u.co-error_log
0 y' b$ E3 o; V3 K! z - CustomLog logs/www.av4u.co-access_log common j5 m- W) e' i" c, ^* n
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd) P' _4 F+ Z6 s
雿臬箇 error:
1 U, h! q, `' K N9 b2 q0 j3 C! _ [warn] _default_ VirtualHost overlap on port 80, the first has precedence
$ V {. ?$ O7 vSOL:
5 o; s' Q/ @. b$ O% r9 w% @望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
- o* t/ P2 z6 Q# L. Fhttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 : p+ v+ _/ r) E6 ^. h5 k4 M
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> . a& ~/ Y& r9 h. K
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>4 j4 B! Z3 Y* k, z
# E3 H& i2 g; Z/ I2 D
& v# O+ n4 m+ b8 r5 N
: w, M' {' z0 Y0 ?& F |
|