啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf
7 ]* [9 \( t5 X( Y2. 曉 # VirtualHost example:% P. B3 y- q; t& l) x8 P
- 嗡乩virtual server 閮剖,靘憒:
8 ~! b6 D5 |9 h$ h( i/ s - #2014/10/02 add
. |2 G3 r) C6 X' X/ |2 { - <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
( s+ r: K' \, C7 `& ]+ N! }0 g" ]$ S - ServerAdmin root@av4u.com
2 f# L- m6 |* f4 }' r% G - DocumentRoot /home/coav4u/public_html8 j% t6 `. u. a4 I4 v
- ServerName av4u.co
! ?2 M. A$ t/ [6 E8 T - ErrorLog logs/www.av4u.co-error_log
: A+ ^8 ?: J l* u1 z2 i - CustomLog logs/www.av4u.co-access_log common
6 e1 ~! G% r0 {3 ?2 f8 n - </VirtualHost>2 ?/ F' l' U9 |: A( S; m. p
- <VirtualHost 192.168.1.12:80>( V! M1 h6 R: `/ B
- ServerAdmin root@av4u.com
" X$ w( a( r& a$ d& ]4 ~2 M& E - DocumentRoot /home/coav4u/public_html
3 I' d9 ^/ t1 [! a- _2 V* Q - ServerName www.av4u.co
! g$ c3 r8 W" i5 n$ x. r - ErrorLog logs/www.av4u.co-error_log
7 C) Q! H- u, j" W7 c4 t5 r - CustomLog logs/www.av4u.co-access_log common0 a9 o& l# s2 M3 X$ S$ A
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
- {5 E5 @# [5 u m( n3. Apache . w- T4 J* e1 f5 P4 j
service httpd restart #隞叵oot頨怠 --->摰
; V( }7 g3 Z4 ]" Z; k 閮: service httpd start # # b' }- b# k$ T3 S( j8 S- a
service httpd start #甇' _. ~/ h- f. z- u0 R8 N
寞鈭2 B) z9 q0 S/ P* g4 g
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host): u U0 Q; B6 @+ P+ ^
靘憒: ) T0 P/ j! q/ P$ q/ l% d" j
virtual1.conf6 G% q0 o' V8 S4 [8 r/ L
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫1 Y9 Z! _- J2 p2 L3 S4 j
- ServerAdmin root@av4u.com+ f; o1 M+ }# C; j! ~! o
- DocumentRoot /home/coav4u/public_html
. ~( p/ Z; P U5 { - ServerName av4u.co
& c" r2 T1 v) q+ U3 ? - ErrorLog logs/www.av4u.co-error_log& l4 x h$ I/ g$ B& q" L! a5 C
- CustomLog logs/www.av4u.co-access_log common
' P2 t2 j% C% i" A* z2 E3 s - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf C- k; \+ P [
- <VirtualHost 192.168.1.12:80>
) K- q6 C9 V8 ]0 D, Y- j- `0 _. q - ServerAdmin root@av4u.com5 q- [( |" x: U
- DocumentRoot /home/coav4u/public_html
, ]" L/ A" Q+ c - ServerName www.av4u.co8 ]/ K- h4 ^9 Y) J! m8 a8 i9 c
- ErrorLog logs/www.av4u.co-error_log
3 N* ?+ [+ S. N& v- d( ` - CustomLog logs/www.av4u.co-access_log common
+ n6 D3 J5 ?: W- u1 U+ t$ Z, s - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd/ i$ ?9 y0 M A, G6 T+ m# K
雿臬箇 error:
* w3 |1 t. {& P& w* f [warn] _default_ VirtualHost overlap on port 80, the first has precedence
0 ]( I# E3 h3 [) q( DSOL:* \0 _& L" ^: k
望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
) H& q$ Z6 `5 R" J! I, O: Shttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 * F z7 g9 A# ^( i q$ c
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
* W" b4 a7 A5 X. a' Chttpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
& G; Y9 j. k2 m; m2 d
; f* v! u4 a8 o( A! g
" {* a) b( U0 [6 y$ K5 g
9 j& _) t1 W; E! E7 h1 W" |- e) S |
|