ubuntu LAMP 配置多虚拟主机站点

来源:互联网 发布:游戏陪玩软件 编辑:程序博客网 时间:2024/06/09 14:53

安装完毕apache后,不需要修改任何配置文件,包括 httpd.conf 、 httpd.conf 和 apache2.conf 配置文件。  

more /etc/apache2/sites-available/site1.xxxx.com 
代码: 
<VirtualHost *> 
         ServerAdmin webmaster@localhost 
         ServerName www.xxx.com 
         CustomLog   /var/log/apache2/site1.xxxx.com-access.log combined 
         DocumentRoot /var/www/site1/ 
         <Directory /var/www/site1/> 
                 Options Indexes FollowSymLinks MultiViews 
                 AllowOverride all 
                 Order allow,deny 
                 allow from all 
         </Directory> 
</VirtualHost>


more /etc/apache2/sites-available/site2.xxxx.com 
代码: 
<VirtualHost *> 
         ServerAdmin webmaster@localhost 
         ServerName www.zzz.com
         ServerAlias site2.yyyy.com 
         CustomLog   /var/log/apache2/site2.xxxx.com-access.log combined 
         DocumentRoot /web/site2 
         <Directory /web/site2> 
                 Options Indexes 
                 AllowOverride None 
                 Order allow,deny 
                 allow from all 
         </Directory> 
</VirtualHost>


创建完毕后,直接 
sudo ln -s /etc/apache2/sites-available/site1.xxxx.com /etc/apache2/sites-enabled/site1.xxxx.com 
sudo ln -s /etc/apache2/sites-available/site2.xxxx.com /etc/apache2/sites-enabled/site2.xxxx.com

当然还在/etc/hosts文件中下设置

127.0.0.1 www.xxx.com
127.0.0.1 www.zzz.com