啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf* K: G) @* ~( n* {: Y
2. 曉 # VirtualHost example:- _3 c4 L: ?& {/ I) U
- 嗡乩virtual server 閮剖,靘憒: p# ?& I( S% v" j$ ^! L: R
- #2014/10/02 add
9 `8 q* k% q$ R6 Z' \3 j/ S - <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
8 H3 D {6 J. |$ p - ServerAdmin root@av4u.com8 v6 _" q2 T: r8 G. J8 }
- DocumentRoot /home/coav4u/public_html
9 C( f3 N: [' e Q. z9 K - ServerName av4u.co
( v. v* T# U% |% u0 I: F - ErrorLog logs/www.av4u.co-error_log) W6 ]9 t+ V6 | N$ d% L; c
- CustomLog logs/www.av4u.co-access_log common
4 E3 `& F. _8 t6 U( j - </VirtualHost>9 M2 b6 p# V G9 V- N0 p7 c! s
- <VirtualHost 192.168.1.12:80>
7 i& \: s6 {4 \ - ServerAdmin root@av4u.com0 _, {) X% t* ] }& o
- DocumentRoot /home/coav4u/public_html
" D5 x% ?& M: E* l& Z! t - ServerName www.av4u.co, V4 b8 r2 K" r8 |# Y8 ?- M; N
- ErrorLog logs/www.av4u.co-error_log
2 a1 d P, O, E5 r3 A$ }7 r! G' V - CustomLog logs/www.av4u.co-access_log common
: H6 w+ b8 ~% P& v( A1 z - </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
4 K4 A7 A# z, W7 F$ r5 B4 q' T3. Apache " y6 n+ E! I C; e0 P- R; u
service httpd restart #隞叵oot頨怠 --->摰
( S# q- g2 K: {- E2 d 閮: service httpd start # % N" K/ Z/ l) f9 ?, M0 Y; _3 f
service httpd start #甇% S$ A1 ~# I9 k$ v! _
寞鈭
& M u' w B5 P! ?5 E5 O. s/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host); {& o6 m5 l+ u* t# M
靘憒: 0 A: E0 K* ]/ x
virtual1.conf
% w5 K0 B# m) c$ o" d3 c- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
' t5 E/ m: p& Z: i - ServerAdmin root@av4u.com9 I& s8 o7 l6 E: I
- DocumentRoot /home/coav4u/public_html
# V% @* W! ?& T& i6 I - ServerName av4u.co
1 J) J3 m7 T5 n( ]8 s; V% y - ErrorLog logs/www.av4u.co-error_log
$ X( p* I5 l# P2 C" f+ W - CustomLog logs/www.av4u.co-access_log common
9 j7 l1 x- Z4 B- h0 x8 h7 b - </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
6 Q, O9 Y2 e) g2 E( d3 [! @- <VirtualHost 192.168.1.12:80>; U+ j6 z7 U5 Q, k s5 w% K0 u
- ServerAdmin root@av4u.com
! V2 Q! \! A, E# V* ?6 j l; l - DocumentRoot /home/coav4u/public_html d$ t V" h9 w+ l7 l( s7 ^
- ServerName www.av4u.co* A0 x# |" Z- R
- ErrorLog logs/www.av4u.co-error_log
! x& a* t/ n+ G5 Y - CustomLog logs/www.av4u.co-access_log common
5 b. U" W2 r6 R" o) `% [) J - </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd! E" h h1 T& X, g
雿臬箇 error:
8 c+ d8 r3 r/ Q. u# l" J' T8 \ [warn] _default_ VirtualHost overlap on port 80, the first has precedence
/ A: p, l P* S% qSOL:
3 g$ A5 u0 `" `8 o* b! s望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:5 x+ V, K. {' `) |. t& K0 \
httpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 ; a3 r5 r7 V% {# `1 s; y
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
1 b @1 g4 C: t! @+ y& Zhttpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
" t- |8 O! E. h& Z0 m9 ]& O
$ e; }8 P- I) F* L. l% S. c: m& s3 ]* W' m
0 N1 b6 ?' F" u; {( _6 H1 m; e2 ?5 h. V; m |
|