啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf2 O- g' f) x0 `4 ?7 s
2. 曉 # VirtualHost example:, `, }; C( e" ^9 L
- 嗡乩virtual server 閮剖,靘憒:
# q) o2 k% }; K/ @" F% S - #2014/10/02 add
- Y, B! {- W' T* Y: [" J - <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
& C! Z `+ ]" R6 K - ServerAdmin [email protected]
2 o4 w9 ^4 E& D - DocumentRoot /home/coav4u/public_html, d' {) q X0 M7 N
- ServerName av4u.co
5 D, F; q8 i/ r. e: g - ErrorLog logs/www.av4u.co-error_log) G7 p3 D1 C* K, v5 {1 }5 ~
- CustomLog logs/www.av4u.co-access_log common$ g% k( f3 s" D& b' u
- </VirtualHost>
: g1 v7 E( T8 M* ]$ l2 } - <VirtualHost 192.168.1.12:80>
: g% @3 r( [, B$ N: ^- g - ServerAdmin [email protected]
- |/ L# C- l& ^! B% p; n8 K - DocumentRoot /home/coav4u/public_html
, t0 }: Q5 a0 l2 J- J9 | - ServerName www.av4u.co
4 o7 s8 O( k) L - ErrorLog logs/www.av4u.co-error_log! N0 B) i6 B% J% z6 p
- CustomLog logs/www.av4u.co-access_log common |5 e8 m9 u9 z5 f8 t
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺 }( _1 ~" R) g( H" J" [2 u* o' |
3. Apache 5 G+ h4 e( A' Q" e' R
service httpd restart #隞叵oot頨怠 --->摰3 T( W1 R3 J4 q: s
閮: service httpd start #
2 W9 t( I! V7 l) i8 B; R service httpd start #甇
- x% Z( x9 \8 o( J# h1 A0 \5 I& g寞鈭
* f# |( ` G" _" i/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)
5 e) b; z4 d# n! P( w8 K) [+ b/ R靘憒:
8 F9 r2 z! |% G! K8 Gvirtual1.conf1 X2 s' U3 [. A% F4 Z7 ^
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
" `% U6 U/ `2 \* X - ServerAdmin [email protected], x0 b. x: n9 f( Y: ]! {1 ?
- DocumentRoot /home/coav4u/public_html
: Z, Q, d& o* l, r2 z3 O2 H8 n - ServerName av4u.co
' j& Y2 V+ w) J4 R, Q9 P8 q* H - ErrorLog logs/www.av4u.co-error_log
+ n. `9 @9 @% y, H6 i, I; e - CustomLog logs/www.av4u.co-access_log common
6 j* ^) j% N7 W" f - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf" B- M# Y4 e+ D
- <VirtualHost 192.168.1.12:80>
9 z! z' `4 r+ O. Q) @1 _0 Q - ServerAdmin [email protected], C9 w' T* q" Z5 k8 P. T
- DocumentRoot /home/coav4u/public_html* J2 m# ~, c9 v) z0 {
- ServerName www.av4u.co* f$ x5 L; _8 Z; P! F
- ErrorLog logs/www.av4u.co-error_log
- V E( s& |% W2 U6 [8 q& ^ - CustomLog logs/www.av4u.co-access_log common
1 D8 n3 s" U: u; D - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
" l! C% [8 Q U/ V! U) ^雿臬箇 error:& Q4 ?( x& R# _) {
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
4 I+ n v' H5 T/ Z! M# M( r0 S2 [% |SOL:
8 B4 J7 i# B, H望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:+ h6 o" ^3 C% Q/ J
httpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80
0 p+ u3 a" U4 m# @httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
# d N8 C( o! Q* L( Y/ bhttpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>& t, k; z; _( N/ j5 q
& R4 |. G$ i! W8 \; M# t
8 I' [) r- x; s# Q5 Q1 A+ A9 Q; h
4 C3 k! |1 O" X+ o" x |
|