啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf
3 [, _& J4 Y1 L& X# e2. 曉 # VirtualHost example:2 }$ [, {7 h- M6 H% |
- 嗡乩virtual server 閮剖,靘憒:
- s" i% H! x! C N* p9 I4 i3 f5 m - #2014/10/02 add0 a% R# M, \9 ]0 t+ P0 l
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
( k' f6 ^: o3 V9 R* m9 r. _ - ServerAdmin [email protected]
" \7 @" O" M$ v# T - DocumentRoot /home/coav4u/public_html2 a/ `) v% e9 U
- ServerName av4u.co8 U( O+ c$ V3 U5 J0 m6 c0 ?0 b3 a
- ErrorLog logs/www.av4u.co-error_log
. S2 \" y+ p$ `/ A) B( p; s+ W - CustomLog logs/www.av4u.co-access_log common2 N) ]1 m: R/ Y. j
- </VirtualHost> o- d, D+ H, l c8 A
- <VirtualHost 192.168.1.12:80>
# [% a6 Z. v1 k- c( w2 j) ~ - ServerAdmin [email protected]2 M; E1 p5 V! `; U5 {9 C
- DocumentRoot /home/coav4u/public_html9 [2 e. {$ J0 t& J! ~2 _3 Q6 O
- ServerName www.av4u.co' n$ P& q7 O' }; z R
- ErrorLog logs/www.av4u.co-error_log1 {% c, J& i$ q% B7 } K; V
- CustomLog logs/www.av4u.co-access_log common! ?! G* ?2 i, F2 u5 X
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
9 s, ^( b3 ?0 t9 p) u$ V# ?- x3. Apache 7 v) \% m; h- f' w( V
service httpd restart #隞叵oot頨怠 --->摰
5 J6 D' X1 Z% t x, b" z 閮: service httpd start # $ M/ ^; g; O4 D4 m# |4 v4 L
service httpd start #甇 i$ U; V# y' y w, T& E5 X, [4 g
寞鈭3 r" M0 C/ }% K% X5 v) a) c4 w9 \4 U
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host); B: T+ I) d5 L- h
靘憒:
* L ^& p/ v4 v/ G4 [- w( ^! pvirtual1.conf l# r& j# r/ e4 {3 C
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
9 b, ]6 G9 g8 ~# ^* O - ServerAdmin [email protected]2 Y* \, K$ `/ E" J+ I
- DocumentRoot /home/coav4u/public_html4 g1 h- u% k$ E; I0 _* l
- ServerName av4u.co9 [6 C; A" @3 [- i/ Q; R# q1 D
- ErrorLog logs/www.av4u.co-error_log
! o& S" S' Z1 A2 { - CustomLog logs/www.av4u.co-access_log common
, ]! W1 f7 ~) f9 @2 A- [ - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
8 V, S9 E5 [( J! a1 \' }4 B- <VirtualHost 192.168.1.12:80>2 |! l j* I+ s' U0 H" r# _. } a% _
- ServerAdmin [email protected]1 K- r. R7 f( }4 L9 H6 _* J6 p
- DocumentRoot /home/coav4u/public_html
- I) @( p& j6 T! H8 X - ServerName www.av4u.co
0 V: @( D$ q3 s' h$ [7 b, T - ErrorLog logs/www.av4u.co-error_log
4 e" J' Y) K2 g - CustomLog logs/www.av4u.co-access_log common
& x! K' K. M" s) a - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd0 U' Z. G! N6 s( ?. x
雿臬箇 error:6 O0 l4 \0 E# D
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
- H6 f( _2 \- m! \8 d, v: |* o' ASOL:3 y7 I, Y" \8 z
望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:* C' F4 [& y% r- R" h
httpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 % H2 v7 @" K: h! ?
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
7 n9 P: y$ O# C/ ?) Q& ~httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
/ R. x% W/ x0 Y8 l( _! J) u9 H. ?3 o0 c# j* z4 {1 ~
( ^* \- z. `2 R: D1 c6 j
( {/ }7 H% I- N
|
|