啣 <Linux CENTOS 6 + Apache + mysql> 寞銝 1. vi /etc/httpd/httpd.conf7 g% J4 [6 H( m
2. 曉 # VirtualHost example:- 嗡乩virtual server 閮剖,靘憒:
- #2014/10/02 add
- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
- ServerAdmin root@av4u.com
- DocumentRoot /home/coav4u/public_html
- ServerName av4u.co
- ErrorLog logs/www.av4u.co-error_log
- CustomLog logs/www.av4u.co-access_log common
- </VirtualHost>
- <VirtualHost 192.168.1.12:80>
- ServerAdmin root@av4u.com
- DocumentRoot /home/coav4u/public_html
- ServerName www.av4u.co
- ErrorLog logs/www.av4u.co-error_log
- CustomLog logs/www.av4u.co-access_log common
- </VirtualHost>
銴鋆賭誨蝣 臬摰2 Domain name (av4u.comwww.av4u.com)啣銝祉征,典隡潔瘥 nginx 閮剖蝔敺桅獄拐暺
& H+ n& X. E! U8 Y- B1 m& L M2 T& R3. Apache $ k0 K! w' G$ w) u/ W9 W5 g2 C
service httpd restart #隞叵oot頨怠 --->摰
/ C/ v" @% Q# T7 o& @ 閮: service httpd start #
* ^! T, L7 ^/ `1 d service httpd start #甇
/ B8 q9 E) J+ e' l* n寞鈭+ w" [! I0 y8 ^* t# w7 }
/etc/httpd/conf.d/匐撱箔函瑼(閮剖銝virtual host)2 D: d/ I, i. u7 Q6 V
靘憒:
3 _7 b6 b$ q( m7 m& Uvirtual1.conf
' p1 i7 ]9 r1 X' ?5 j- g- <VirtualHost 192.168.1.12:80> # <VirtualHost 127.0.0.1:80> #蝚西箄酉閫
- ServerAdmin root@av4u.com
- DocumentRoot /home/coav4u/public_html
- ServerName av4u.co
- ErrorLog logs/www.av4u.co-error_log
- CustomLog logs/www.av4u.co-access_log common
- </VirtualHost>
銴鋆賭誨蝣 virtual2.conf
3 W' |6 R0 e& q8 F4 s' {; v- <VirtualHost 192.168.1.12:80>
- ServerAdmin root@av4u.com
- DocumentRoot /home/coav4u/public_html
- ServerName www.av4u.co
- ErrorLog logs/www.av4u.co-error_log
- CustomLog logs/www.av4u.co-access_log common
- </VirtualHost>
銴鋆賭誨蝣 摮瑼嗅 httpd) V0 l4 i8 y8 i- J
雿臬箇 error:) L& Q" H: ]: q* @& n0 X4 P
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
9 ^ L6 T( V+ h) |& F$ _. cSOL:
% O' r3 W/ F' U+ M) i! {3 v, C望 /etc/httpd/conf/httpd.conf NameVirtualHost *:80 virtual1.confvirtual2.conf 折質身摰 <VirtualHost 192.168.1.12:80> 銝寥,甇蝣箇閮剖:' @' Q& z+ e# t& E# F
httpd.conf virtual1.confvirtual2.conf(砌蜓璈閮剖瑼)銝舫賜 *:80 撠望舫賜 192.168.1.12:80 % I- ]) y" j" Q0 t! Y# ]' \5 t, ~: _
httpd.conf ===> NameVirtualHost *:80 , virtual1.confvirtual2.conf ===> <VirtualHost *:80>
& L0 S) M, R+ t' e1 P. W, p- ?httpd.conf ===> NameVirtualHost 192.168.1.12:80 , virtual1.confvirtual2.conf ===> <VirtualHost 192.168.1.12:80>
! @$ D* I' h/ y5 D2 s# I
# R5 ^" J5 O. F. w, G3 y& H: r4 b4 r/ I
* c+ m" ~: w& A" h8 i: _' \ |
|