ubuntu12 apache2部署多个网站的方法

由于对apache2的配置不是很精通。吃了不少瘪。

这里总结下,希望对碰到同样问题的人带来帮助:

假设需求是有两个站点,site1和site2.其端口分别为80和8080.

1. 配置监听端口

修改 ports.conf文件,通常位于 /etc/apache2下面。增加8080端口的监听即可,

NameVirtualHost *:8080
Listen 8080

2. 配置 httpd.conf 或者 sites-available/default文件,通常位于/etc/apache2下面。增加8080端口的虚拟主机,如下:

<VirtualHost *:8080>
   #LogLevel debug
   #CustomLog ${APACHE_LOG_DIR}/access.log combimed
   #ErrorLog ${APACHE_LOG_DIR}/error.log
   #具体其他配置

</VirtualHost>

  

3. 重启apache2

service apache2 restart