啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf
7 S/ T2 q$ G! P' W- T2 V7 p2 A; R$ y2. 曉 # VirtualHost example:
' n/ ?3 O6 J! @( ?: p$ O- 嗡乩virtual server 閮剖,靘憒:! n' e _2 B, o
- #2014/10/02 add. }9 k/ l1 R `' ?6 `
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫- ]3 } x$ m% O! Q: [" U
- ServerAdmin root@av4u.com
; A1 C, S! i# y; E7 B5 a4 v+ u - DocumentRoot /home/coav4u/public_html
- f Y4 m" {& y+ }1 k+ x4 j - ServerName av4u.co7 m( x- l5 m7 C* U4 f
- ErrorLog logs/www.av4u.co-error_log
3 c9 j B1 h1 t- n - CustomLog logs/www.av4u.co-access_log common
6 ~( W5 K6 ]' n+ Y, H8 o - </VirtualHost> X2 A' W2 J: I+ C( v$ R1 x# E; [
- <VirtualHost 192.168.1.12:80>
9 h& f0 O R+ {' ? - ServerAdmin root@av4u.com( l: G7 i2 p. C
- DocumentRoot /home/coav4u/public_html
7 q: s5 }1 T) V3 q - ServerName www.av4u.co" I# U( @3 k3 }3 q% {" x
- ErrorLog logs/www.av4u.co-error_log$ e! Q; {( b7 a: {) t$ B
- CustomLog logs/www.av4u.co-access_log common
9 Q. X/ I" o( K; ^8 _, w* | - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺8 w6 U- U9 X. E9 q5 E
3. Apache
$ c) e8 e# A& z# R9 v! r/ y; g service httpd restart #隞叵oot頨怠 --->摰
* N, u% u) f4 |2 q 閮: service httpd start # ) `- F- u% u4 g4 W
service httpd start #甇/ U$ b: A* g4 Z. c3 k2 e
寞鈭5 Y( y; R! }) N5 M% O
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)1 d/ P7 ^6 X" Z
靘憒:
3 |7 j: f/ K5 Kvirtual1.conf
) X; q% B3 n9 X; ~- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
# d5 c/ @ U8 H3 Z. |$ c- s0 Y' O3 Y - ServerAdmin root@av4u.com2 B6 M0 F0 Q+ @& E" R/ S
- DocumentRoot /home/coav4u/public_html/ \# o/ w# m- E
- ServerName av4u.co2 a/ r5 y* J9 @ K7 Z
- ErrorLog logs/www.av4u.co-error_log
' y3 Y& a; q; J t' {8 r; Q6 H - CustomLog logs/www.av4u.co-access_log common
* E8 p8 W* S! I0 z: d+ Y - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf8 f$ T* ]4 D$ S& h- Q, _: ?& T6 m
- <VirtualHost 192.168.1.12:80>2 w ^2 @% V( W& {
- ServerAdmin root@av4u.com
. A# R8 m: X1 I" R! Q6 n$ @7 z6 v/ x - DocumentRoot /home/coav4u/public_html
1 a% o c% X2 N4 N' L) \/ p4 I: P - ServerName www.av4u.co5 I4 A; \* D! a% y) Z7 D7 N( p
- ErrorLog logs/www.av4u.co-error_log9 }6 D. V. R! f: O! k
- CustomLog logs/www.av4u.co-access_log common
8 ^9 S; J* k" f6 h( S - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd
# [# x* R( Y6 }+ g雿臬箇 error:, C/ Y6 S/ N' W: v8 a% B+ ]
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
- u# j& j8 Y% k1 M3 fSOL:
3 c3 N% B) N+ a/ b3 N7 Q望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:7 G6 ^+ ^* h. S2 _. d% T7 l! o2 [
httpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80
6 |( v5 x, R$ } `8 S/ \% Ihttpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> & I' t9 z$ Y# N( @
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
/ p6 _2 r8 [& |1 z: j+ [0 [% f; h; v8 T$ q: Z
' Z; x2 g6 v$ \+ b" Z$ [
; a. a; {2 ]: C9 s. F9 q, j! h
|
|