啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf0 s5 y5 f+ o7 `- \: E
2. 曉 # VirtualHost example:
8 m9 b/ M( J! W% q& p5 o" |4 s- 嗡乩virtual server 閮剖,靘憒:
. m' _5 ]* @6 P# u: \. G - #2014/10/02 add$ x0 _3 w" C# c, `; T
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫/ t6 u6 N0 L0 L5 `8 k) D1 N
- ServerAdmin [email protected]
+ d3 I# o8 O' n - DocumentRoot /home/coav4u/public_html. Y) D) J. T! U6 @
- ServerName av4u.co! I& N+ u, X3 P, e/ C8 H. w
- ErrorLog logs/www.av4u.co-error_log
7 f: v3 o9 K& G7 o/ q* z - CustomLog logs/www.av4u.co-access_log common' Q) H) q8 C' f8 t$ g
- </VirtualHost>5 {+ a$ K- l, V& c! e
- <VirtualHost 192.168.1.12:80>
. F8 B+ \5 _, G# j - ServerAdmin [email protected]* {9 s$ p# h2 d9 Z. V* a; q
- DocumentRoot /home/coav4u/public_html9 X3 H h# _/ l* }
- ServerName www.av4u.co
( s- G8 w- t3 a2 Y. ]6 v* _6 u; t - ErrorLog logs/www.av4u.co-error_log. Z. E j, F: u1 K; Y: @
- CustomLog logs/www.av4u.co-access_log common
( e% \0 q) c9 O1 H0 A - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
& Y( N- E3 l4 w: s3 H) [5 E- j3. Apache 5 M0 x' S- j1 v& o
service httpd restart #隞叵oot頨怠 --->摰5 A" K1 O8 @- I! X$ G3 _' X& Y
閮: service httpd start # # ?, o4 O; h; P% n5 ]+ _$ S$ s; L
service httpd start #甇
3 @7 r3 `7 d/ {8 H% V& W+ p; M寞鈭
$ I& E6 Q' A S9 q/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)
3 G9 L! Q( u0 ~6 G靘憒:
: v4 v' v# j0 `virtual1.conf
5 K; M% n8 X. ^; ?) s# m, M- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫5 d C. b: }6 @$ G
- ServerAdmin [email protected]
: X0 Q; K; T0 k& t- i - DocumentRoot /home/coav4u/public_html
3 V: t- t1 _: i* a - ServerName av4u.co
* V8 ^; c' U1 ] - ErrorLog logs/www.av4u.co-error_log
5 N: q' W2 F$ { - CustomLog logs/www.av4u.co-access_log common
; M" h% r, c' x- w- |$ }* v - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf; z5 ^* X# X# d+ Y) u( S- g* I
- <VirtualHost 192.168.1.12:80>4 V4 e4 ?& A% P0 D6 [/ E N
- ServerAdmin [email protected]
; ^" C" F8 T6 J1 u - DocumentRoot /home/coav4u/public_html4 S) p% y" {/ @ X4 i8 E5 X5 F/ y5 S
- ServerName www.av4u.co5 A* S @' k, {$ y( _
- ErrorLog logs/www.av4u.co-error_log
, c5 ?4 o1 S' S) S) r - CustomLog logs/www.av4u.co-access_log common
% f8 l, N' }$ P/ E8 L' }9 J' w4 r - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
6 Q Q( m7 r/ q' o' p# x8 c雿臬箇 error:
/ D& G! {. m- _) B4 N$ e4 B [warn] _default_ VirtualHost overlap on port 80, the first has precedence
* }- R: B! E3 }, h6 \: CSOL:
7 G! [ Z% {6 v! T. N2 B% W/ x7 a望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
7 n% b5 p" d( G! Nhttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 & [3 r' b7 l9 Q* L3 J
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> 6 }# ^) ]/ P7 ~( [5 a! Q, Z; R
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>. j( W( \9 h9 z
0 T* ]" F) H3 f; b( A
2 F _8 @* p! k& m6 ?7 B
[; h/ [6 L& \# f
|
|