啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf' {/ x9 w' N( y9 `5 q' j, Y6 s# {
2. 曉 # VirtualHost example: ]% \- W6 u( `5 d3 p- x4 I
- 嗡乩virtual server 閮剖,靘憒:
" d! ^* u4 E3 e8 w( O9 i% J7 | - #2014/10/02 add4 l5 b, t; C7 k q
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
) S- X0 Q- B' q" d - ServerAdmin [email protected]
/ b2 l* l8 F- M! w b4 t, d - DocumentRoot /home/coav4u/public_html
" N t9 c# w! y# k4 B' {# S - ServerName av4u.co' i- M' J" \" x4 c. k# S' m* Y8 ?
- ErrorLog logs/www.av4u.co-error_log: h0 Y: R5 P) A" |" s P
- CustomLog logs/www.av4u.co-access_log common8 {) S$ @7 t5 Q
- </VirtualHost>3 Q" k5 m1 a7 V6 k$ o) q; `/ a. _
- <VirtualHost 192.168.1.12:80>3 ~6 Z9 ~8 \' \
- ServerAdmin [email protected]
7 _4 ~3 U/ m5 i q7 i - DocumentRoot /home/coav4u/public_html" x3 E- ^' V8 O' j7 p
- ServerName www.av4u.co; o4 I0 b. v+ H S& E) n
- ErrorLog logs/www.av4u.co-error_log- n4 b8 X8 g5 P8 ?# k" Z
- CustomLog logs/www.av4u.co-access_log common2 n. I9 q4 p8 v0 { M' w
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺1 L! T5 p9 H; x0 ?8 d
3. Apache - S1 p. |4 d" X5 n Q
service httpd restart #隞叵oot頨怠 --->摰* T1 U* m, Z- T3 v4 G
閮: service httpd start # 3 Q4 z [* n5 r9 R* E! O$ |
service httpd start #甇
& a/ z2 L: X) L* X& a1 [+ u3 e/ W寞鈭/ f0 }' ?. Q1 V7 ?- _$ I$ R
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)5 G: @# _0 m. C0 k
靘憒:
% P p% u$ F' j7 R& q+ zvirtual1.conf
" S. p% ]" ^2 C f/ O) q6 A1 n- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
0 r E/ G# T% I' l( D3 W5 c0 ` - ServerAdmin [email protected]! [! G2 U. t2 L
- DocumentRoot /home/coav4u/public_html
5 ~" f2 R2 K% r3 M1 O! j# ? - ServerName av4u.co$ e- H; I7 p$ D0 e/ E
- ErrorLog logs/www.av4u.co-error_log2 l5 D6 _' l% T+ ]4 e2 m
- CustomLog logs/www.av4u.co-access_log common
2 [; P" z1 H( ]' q - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
; Y5 [1 k U8 ?. I" ^; ]- <VirtualHost 192.168.1.12:80>
T9 t' a+ M* Y - ServerAdmin [email protected]
# U+ N5 [- }3 I$ k/ H- k! Y6 c - DocumentRoot /home/coav4u/public_html
, n- r5 ~: I/ u; W5 Q - ServerName www.av4u.co* ]) P; Z( @9 }. K- J
- ErrorLog logs/www.av4u.co-error_log- S& |" s" I, B0 v" k+ e3 \1 Z6 I
- CustomLog logs/www.av4u.co-access_log common
% G7 ]! Q7 S* B - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd! ^) T( _, o8 ^$ k
雿臬箇 error:6 I! {0 ] N1 j: w* r; U
[warn] _default_ VirtualHost overlap on port 80, the first has precedence+ f6 x/ C Z% n, ^
SOL:5 F4 Q* E. u; e
望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:! S8 K7 V" m* y5 \3 h) U: q m
httpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80
) H0 E v/ ~: {% \( l# Ehttpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
5 A4 `) i4 t, J) G) Vhttpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
% t# I. `% w* a3 G( F5 f* W: H y0 `: ~. b" I) @
W) e: b Z! d1 F3 [( K E
+ ^; }$ s* V% y9 C8 m
|
|