啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf) s. }+ D" e! a5 p9 r
2. 曉 # VirtualHost example:
3 g$ T l( n+ y! R- 嗡乩virtual server 閮剖,靘憒:
+ [ c4 @. o4 Q- \6 y - #2014/10/02 add
2 T& v7 P ~7 S; B" i. B - <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫0 p6 \! F5 t+ [" `5 v7 ^
- ServerAdmin root@av4u.com: V# ~2 ]2 F& \' A- K* K& Q
- DocumentRoot /home/coav4u/public_html
( R( ^9 S$ u+ e$ V- u - ServerName av4u.co3 k5 d$ Y+ R8 f t9 a3 U" L) Y: @
- ErrorLog logs/www.av4u.co-error_log
3 V$ T8 |9 _ I/ }: M - CustomLog logs/www.av4u.co-access_log common( @3 f* B% W6 y, Y
- </VirtualHost>* c$ q( M& ~ y3 ]* q: S2 b" s
- <VirtualHost 192.168.1.12:80>7 t9 ]5 ^9 r: G! D" O. ^$ Q J
- ServerAdmin root@av4u.com7 E& r# l- K, R* t7 |7 d0 r0 B
- DocumentRoot /home/coav4u/public_html: ^0 `9 [' _5 L" h% ^
- ServerName www.av4u.co9 e6 k1 J- b, t$ x! \3 J- |
- ErrorLog logs/www.av4u.co-error_log
" k. D$ [% A1 B( P: t. i6 i0 y/ F - CustomLog logs/www.av4u.co-access_log common
# u- z& i# R* q. N - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺) a1 p; e: Y2 G) o( v, y, U6 O
3. Apache
' @8 k; X6 z" H9 h/ @- @* P service httpd restart #隞叵oot頨怠 --->摰' \0 b) h1 i! D/ o' M
閮: service httpd start # : j% Z$ o3 t2 G* e& k
service httpd start #甇
9 r% ~+ p- d- _# f" |- t2 P/ k |寞鈭& M8 d6 d m# H+ A
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)% [( _4 ?7 F2 K) v. c
靘憒: ) u( _& P' t# @1 ` }
virtual1.conf
4 o% A1 w: Q y% d- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
( H! r9 K& I( c% N0 z6 ~ - ServerAdmin root@av4u.com7 O9 J2 G' P# `) k1 d8 p
- DocumentRoot /home/coav4u/public_html4 @) D3 E- G1 e
- ServerName av4u.co
& }: ~( }% C& R/ u5 ?0 e - ErrorLog logs/www.av4u.co-error_log
N: u# f1 _& U4 Y+ Y - CustomLog logs/www.av4u.co-access_log common- K n! K' T6 k$ j# o
- </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
6 V$ B; y5 m( ^1 C4 d/ `- <VirtualHost 192.168.1.12:80>
2 u7 ]6 b1 `6 L/ r - ServerAdmin root@av4u.com" k/ F: b! u7 r: H6 _! ~: I& {
- DocumentRoot /home/coav4u/public_html0 V: {% Z& X3 X. M
- ServerName www.av4u.co
0 t7 `/ W9 d7 ^5 l - ErrorLog logs/www.av4u.co-error_log
, a$ K- |3 s( ]( R( f. l - CustomLog logs/www.av4u.co-access_log common y) A& k. m. F( }& j
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
" G7 u( d- |+ t/ Y/ ]雿臬箇 error:
1 q8 |( {& G! @/ H. o1 i [warn] _default_ VirtualHost overlap on port 80, the first has precedence
& B5 U: |* u9 G/ v: h0 SSOL:
% k, u, a3 c2 \% a. e4 K. ~% }+ t望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
% s+ w7 m) L' n; x* Ohttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 3 ?1 f4 Q7 _5 m$ q# ]$ Q1 n
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> 2 o5 X$ R: _2 H. k y8 v8 ?/ z& C
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>+ ~1 f4 u3 e% |" A
# Y$ r R& V' X% |8 P) |
2 f& a+ k# M. |! J2 p; b, I8 v; p- S: g- v7 _. [# \$ b% @
|
|