可能重复:
多个IP地址上的多个虚拟主机
我正在运行Ubuntu 11.10,我有两个IP地址分配给我的VPS(Linode)。
我已经按照他们的指导启用静态地址(可以在这里find: http : //www.linode.com/wiki/index.php/Configure_Static_IPs )
目前的情况是,我有3个网站在这个Linode,我想设置它们,所以site1和site2将使用IP1,site3将使用IP3
/etc/apache2/sites-available/site1.com
<VirtualHost 1.1.1.1:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin [email protected] ServerName site1.com ServerAlias www.site1.com # Index file and Document Root (where the public files are located) DirectoryIndex index.html index.php DocumentRoot /home/site1/public_html # Custom log file locations LogLevel warn ErrorLog /home/site1/public_html/log/error.log CustomLog /home/site1/public_html/log/access.log combined </VirtualHost>
/etc/apache2/sites-available/site2.com
<VirtualHost 1.1.1.1:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin [email protected] ServerName site2.com ServerAlias www.site2.com # Index file and Document Root (where the public files are located) DirectoryIndex index.html index.php DocumentRoot /home/site2/public_html # Custom log file locations LogLevel warn ErrorLog /home/site2/public_html/log/error.log CustomLog /home/site2/public_html/log/access.log combined </VirtualHost>
/etc/apache2/sites-available/site3.com
<VirtualHost 2.2.2.2:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin [email protected] ServerName site3.com ServerAlias www.site3.com # Index file and Document Root (where the public files are located) DirectoryIndex index.html index.php DocumentRoot /home/site3/public_html # Custom log file locations LogLevel warn ErrorLog /home/site3/public_html/log/error.log CustomLog /home/site3/public_html/log/access.log combined </VirtualHost>
ports.conf相关摘录:
NameVirtualHost 1.1.1.1:80 NameVirtualHost 2.2.2.2:80 Listen 1.1.1.1:80 Listen 2.2.2.2:80
问题是,我正在获取所有三个站点上的site1的内容。 我不知道为什么会这样。 你能协助吗?
注:我已经运行了所有3个网站的a2ensite,当我启动apache2服务时,没有错误/警告。
假设你的configuration如上所述,这是完美的。 确保你已经启用了所有网站的网站,但可以使用,例如a2ensite site3.com 。 该命令所做的是从站点中的文件创build符号链接 – 可用于站点启用。 在Ubuntu上默认的Apacheconfiguration为parsing任何网站启用,但没有任何网站可用; 网站可用只是一个存储库。
还要确保你的VirtualHost指令中没有使用*:80。
如果没有这些,运行apache2ctl -t -D DUMP_VHOSTS ,看看你的活动虚拟主机是什么。 在这里发布输出。