按照我在网上可以找到的每个指南,用完了几个小时。如何在一个apache实例上运行多个站点
我希望有一个单一的Apache运行两个网站,像这样 - 192.168.2.8/site1 和 192.168.2.8/site2
我在圈子里被兜了一圈,但在那一刻我在“网站可用(符号链接到网站启用 - )”,看起来像这 -
<VirtualHost *:2000>
ServerAdmin [email protected]
ServerName site1
ServerAlias site1
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /home/user/site1/
# CGI Directory
ScriptAlias /cgi-bin/ /home/user/site1/cgi-bin/
Options +ExecCGI
# Logfiles
ErrorLog /home/user/site1/logs/error.log
CustomLog /home/user/site1/logs/access.log combined
</VirtualHost>
和
<VirtualHost *:3000>
ServerAdmin [email protected]
ServerName site2
ServerAlias site2
# Indexes + Directory Root.
DirectoryIndex index.html
DocumentRoot /home/user/site2/
# CGI Directory
ScriptAlias /cgi-bin/ /home/user/site2/cgi-bin/
Options +ExecCGI
# Logfiles
ErrorLog /home/user/site2/logs/error.log
CustomLog /home/user/site2/logs/access.log combined
</VirtualHost>
个conf文件
的http.conf看起来像这 -
NameVirtualHost *:2000
NameVirtualHost *:3000
目前我得到这个错误 -
[error] VirtualHost *:80 — mixing * ports and non-* ports with a NameVirtualHostaddress is not supported, proceeding with undefined results
Ports.conf看起来是这样的 - (虽然没有导游提到任何需要编辑这个)
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
任何人都可以给一些简单的指示,让这个运行?我发现的每一个指南都是以不同的方式去做,而每一个指南都会导致不同的错误。我显然做错了事,但没有找到可能的解释。
只想要一个站点可以在端口2000上访问,另一个站点可以在端口3000上访问(或者其他,只需选择那些端口来测试)。
我运行Ubuntu服务器12.04 ...
=============
编辑
接着一个 '引导' ......
我现在已经在此设置站点可用:
<VirtualHost *:80>
DocumentRoot "/home/user/site1/"
ServerName 192.168.2.10/site1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/home/user/site2/"
ServerName 192.168.2.10/site2
</VirtualHost>
已经将这个在apache2.conf:
ServerName site1
ServerName site2
已经加入这个ports.conf:
Listen 192.168.2.10:80
==============
编辑
现在的工作,我把它放在启用了site的conf文件中:
我在ports.conf中有这个:
Listen *:80
Listen *:81
Listen *:82
我在apache2有这个。CONF:
ServerName site1
ServerName site2
我没有在我刚刚才通过试错的一整天工作的任何指南找到这个,所以我不知道这是一个很好的解决方案。但至少现在我正在努力工作。
在我看来,你需要在NameVirtualHost中指定虚拟主机名。 –
干杯,我已经尝试了很多事情,你能更具体地说我应该尝试放在那里吗? – Exbi
经过整整一天的努力才得以发挥作用,我终于偶然发现了答案。我感到精神枯竭,我要去睡觉了。 我怀疑我的狡猾的apache黑客解决方案会对任何人都感兴趣,但我会将其编辑到我的问题的最后。 – Exbi