啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf. r" P n- z5 z4 Z1 {, S) o* `
2. 曉 # VirtualHost example:
- X" T" r$ I2 n- _8 N- 嗡乩virtual server 閮剖,靘憒:
2 t. j% f# Q1 t+ f5 j6 ^5 n9 X! d# x - #2014/10/02 add
) L) g$ G/ R, J - <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
2 R+ u. |# X! h6 P - ServerAdmin [email protected]
" P( K1 O" d0 i3 a - DocumentRoot /home/coav4u/public_html; A5 N$ [$ o- P( d' K2 \
- ServerName av4u.co
$ r1 z+ J2 D: |2 n2 H$ {8 b - ErrorLog logs/www.av4u.co-error_log3 f8 s; @+ T: }1 g" f" m/ D7 n* F
- CustomLog logs/www.av4u.co-access_log common: v2 o% N$ u: v: M
- </VirtualHost>
7 U9 a4 K% { h% X0 I1 _! \( g - <VirtualHost 192.168.1.12:80>
* k# [& x; S; L$ i7 z( n/ h2 U - ServerAdmin [email protected]" s" C: G# Z+ Q
- DocumentRoot /home/coav4u/public_html
$ {8 u* |; A1 S3 Y - ServerName www.av4u.co
1 m5 e5 U! G8 g - ErrorLog logs/www.av4u.co-error_log
2 k. f+ B I0 H$ W - CustomLog logs/www.av4u.co-access_log common
* T& R! P1 n Y2 t5 k( h2 b0 `$ } - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
8 A0 h! [- e$ l' T; a9 [( E v3. Apache
; X# p# a; M& K; B service httpd restart #隞叵oot頨怠 --->摰
; r8 N0 G; E8 m3 q1 v1 d 閮: service httpd start #
! v+ g6 r$ R; I' J' {6 {* V service httpd start #甇9 D% T( B" Y+ I1 T6 m4 T7 q
寞鈭$ Q* z7 {" w& u+ R
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)
( t8 \/ n2 Z% m3 h靘憒: & V+ C+ c& n1 @& p" E
virtual1.conf
$ g' j, \) J0 R" ?% Z8 x; d- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
5 B0 |7 t4 }" L, H; _8 U8 ` - ServerAdmin [email protected]
* T3 u0 q. r* G0 Q/ n - DocumentRoot /home/coav4u/public_html
% E$ n8 T- Q( U. e$ E) [5 S- a - ServerName av4u.co. u& P; e, { t( ~5 c4 m A
- ErrorLog logs/www.av4u.co-error_log
5 ]" S! S& T: w* v( k6 R/ Z - CustomLog logs/www.av4u.co-access_log common! J3 Z, [5 \. p$ r/ N4 S- @
- </VirtualHost>
銴鋆賭誨蝣 virtual2.conf" t# k' X6 C3 d9 [
- <VirtualHost 192.168.1.12:80>
0 q; C w- w( |; Q3 h - ServerAdmin [email protected]$ a. W6 t1 E9 j6 p: }
- DocumentRoot /home/coav4u/public_html
% O. U: J0 v3 @& `6 [ - ServerName www.av4u.co/ H9 N/ e- m8 s$ s6 J- I
- ErrorLog logs/www.av4u.co-error_log( `2 U1 w$ @# t3 W4 S
- CustomLog logs/www.av4u.co-access_log common8 Y' O; z- s% W+ K+ F7 w! j
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd& [5 j) ~3 q& e: v- ^
雿臬箇 error:
* R7 }1 H& ^" A( S [warn] _default_ VirtualHost overlap on port 80, the first has precedence: V% E2 C" ]1 X
SOL:
5 s4 Z2 t* ]7 i5 @$ T望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:
5 v/ o2 h- \( O: jhttpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80
. \# i. W% |/ X- N9 Xhttpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80> 6 k7 ^3 M) e' J
httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
. G& t) p' D8 p G0 b( Y: z# c/ C! q! _$ e- ~* J3 L2 U
1 p1 V& j: B% ~9 ]' p4 p" f7 h$ }, q# ]! E0 H5 b( t' y6 O
|
|