啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf
; V" j. r" {3 x5 M2. 曉 # VirtualHost example:
6 _* h5 q6 n; m3 {' f6 N" U- 嗡乩virtual server 閮剖,靘憒:# V0 \, U0 |/ ]% R) r
- #2014/10/02 add% e( C( S ?$ H; r s3 a
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫+ I* p6 t6 s" u; t3 X2 B
- ServerAdmin [email protected]
7 W; v7 ^" Q! i, ^ - DocumentRoot /home/coav4u/public_html
5 t, P9 o. a- e5 _8 ~, \5 x - ServerName av4u.co' c W5 e7 { u, a
- ErrorLog logs/www.av4u.co-error_log( l+ W+ I5 o* ]+ y, A
- CustomLog logs/www.av4u.co-access_log common
) Y+ ]" ?/ _% f8 w - </VirtualHost>+ L2 y- Q) M( y' F/ [4 x! {
- <VirtualHost 192.168.1.12:80>' F' k; l9 \- v/ S
- ServerAdmin [email protected] N# t! b- t! d. e. B% c+ S
- DocumentRoot /home/coav4u/public_html
: k3 O0 ?- i* c7 G" G2 I - ServerName www.av4u.co
2 Y; S% a6 `3 e - ErrorLog logs/www.av4u.co-error_log F8 M& ^; p# j( y
- CustomLog logs/www.av4u.co-access_log common) b8 }% a/ L+ N: x) [
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
1 t$ p/ p/ ~" ^3. Apache
0 M1 f) X$ c U6 g0 G service httpd restart #隞叵oot頨怠 --->摰
+ ^3 H3 O3 G( w 閮: service httpd start # ' l5 ~5 O+ ^2 t4 N' J, y
service httpd start #甇) u r9 @; c4 V& P
寞鈭5 t# z. l+ H, x2 c6 O; x6 P1 P
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)
; s2 f1 @: N; a3 X靘憒: 8 T5 g# ?7 T. Q9 Q' F
virtual1.conf
. b( c& u g% k. m: ~% @ i- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
+ b* k* [" T, h, I- d( Q - ServerAdmin [email protected]: R B; I/ n! h5 i7 M
- DocumentRoot /home/coav4u/public_html
0 J/ u s( }9 ^+ a - ServerName av4u.co
6 k" c _: t! ~7 n8 n$ y8 x2 S - ErrorLog logs/www.av4u.co-error_log6 X& K* L, d/ C& }$ ^7 b {4 z
- CustomLog logs/www.av4u.co-access_log common
1 `8 U/ m3 b* O; [& t7 X$ a - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
8 |2 q# Q' q& O/ e7 h! v8 }- <VirtualHost 192.168.1.12:80>2 A( F+ t6 a& B
- ServerAdmin [email protected]
9 S# X& ^) Y4 \% k* B2 E - DocumentRoot /home/coav4u/public_html! e# z" P4 g4 R# _
- ServerName www.av4u.co* J& k( O q$ q1 h& x) h
- ErrorLog logs/www.av4u.co-error_log, l2 I) v* c) v1 m8 w1 n6 G6 a
- CustomLog logs/www.av4u.co-access_log common5 p5 i" e* k' }$ Z' z0 t
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
4 ?3 v: a7 [2 z I+ p雿臬箇 error:9 P/ V) b) [0 h0 d; T% M9 T
[warn] _default_ VirtualHost overlap on port 80, the first has precedence" ]8 ~, l6 D, X) k2 Z) b
SOL:
2 o8 ]( V% ?" g" y4 u. A望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
, `# U+ Q2 d B6 ihttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80
+ n# J, M9 h1 u2 V8 `3 ohttpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
- n! n8 D/ q" ^2 ?" {; rhttpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
, m$ K- ?$ k% H" C E/ G
4 v; r9 o& @0 Y7 K4 q A
( f2 E5 A7 S# l y0 X# |
8 ^; R) U0 Y) v) w* l4 Z; h( | |
|