啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf$ K( `- X P4 H; Y: F
2. 曉 # VirtualHost example:
, H6 j4 n7 z( T1 D, a# L- 嗡乩virtual server 閮剖,靘憒:
. k* b9 z- U8 V - #2014/10/02 add' y# I s+ Y v+ P7 ? `
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫1 F6 U/ m2 l& k4 c
- ServerAdmin [email protected]
' Q t8 e! s6 G8 q( N# i - DocumentRoot /home/coav4u/public_html
7 ?/ k1 y2 p+ P8 k - ServerName av4u.co
8 Y1 q) X5 C( c6 M - ErrorLog logs/www.av4u.co-error_log8 i1 W; ^& K7 f- G: B
- CustomLog logs/www.av4u.co-access_log common j6 C: `8 R8 Z: D
- </VirtualHost>. u; I/ p) r7 q `# I( A
- <VirtualHost 192.168.1.12:80>
- Y& U/ ?. a! z8 f* M$ r. s - ServerAdmin [email protected]
, }6 Q% x" f" E2 [( m, p6 v - DocumentRoot /home/coav4u/public_html3 j- g) r6 y% C2 x; V
- ServerName www.av4u.co' }" @9 J$ c% p" {; N# q; Z
- ErrorLog logs/www.av4u.co-error_log
" u$ H+ Z5 X* P' v3 K' s8 g8 p0 c, q$ j - CustomLog logs/www.av4u.co-access_log common# U. S8 V* P1 n, P* ?
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
2 `2 {& y* V( n- L5 J% L3. Apache / P4 q9 d2 S. C5 ]4 S" a2 v
service httpd restart #隞叵oot頨怠 --->摰 m, _2 O6 r K) z. M' p# Y3 P, y
閮: service httpd start # p6 y3 v9 K5 P G- R& b: k w
service httpd start #甇; t% F0 k! K5 o/ S3 N! {% `2 N4 ?
寞鈭
- \1 f @' Q5 m- F/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)! \6 D1 V1 R2 ]4 B
靘憒: n Y0 ^# I. Z7 J2 b" {8 \$ @! e
virtual1.conf. R. I1 O% M% p& R2 v5 x
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
8 k. I( {+ o; [( G" M- V5 X - ServerAdmin [email protected]
, @& ]$ J+ N: ?- d5 ?1 g - DocumentRoot /home/coav4u/public_html
, X" \6 Z; X+ p8 z. t6 x/ u( {% p& x - ServerName av4u.co' l: Y( l% [: d# S: F% ?7 Z
- ErrorLog logs/www.av4u.co-error_log0 h# d+ v! K0 l6 C5 T" J2 o: V- \' p
- CustomLog logs/www.av4u.co-access_log common
* B4 I# ]8 Q* O _ - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
/ l8 w# D* o% O% w, V- <VirtualHost 192.168.1.12:80>- `7 U0 R) ~/ f- K
- ServerAdmin [email protected]
8 `( d2 r; [* z - DocumentRoot /home/coav4u/public_html6 }7 T; \# i Y8 V# q
- ServerName www.av4u.co' G7 Z% I7 P2 J$ @) @5 e2 f: s
- ErrorLog logs/www.av4u.co-error_log+ `4 X2 ~4 l5 p
- CustomLog logs/www.av4u.co-access_log common
- _) N/ Z9 a. k. b9 H - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
9 S1 {& S) F; @4 `1 u' C0 u1 O雿臬箇 error:
+ d5 E6 [0 Q% W/ Y# b1 [: O [warn] _default_ VirtualHost overlap on port 80, the first has precedence3 C3 K) M+ S- e, Z) Y2 o8 m
SOL:
1 ^/ l2 ^( H9 ?. E( Z% c望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
. z4 [. s7 ?7 ?: o5 F8 ?2 Khttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80
$ Z1 b8 l; t, V& hhttpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
* ]. X' Q! T" Q3 }9 h4 @9 Phttpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
2 \8 A i5 g, W3 O. o
. j4 A$ C r/ u+ c1 w2 i7 p" H% n V2 g* A# [
. p7 f4 c2 g1 Z! g! U |
|