EC2 ubuntu 上的多个虚拟主机 - 无法访问第二个主机,始终访问默认主机
第一次发帖,还请大家帮忙。我已经搜索和重新配置了 6 天,已经失去了几束头发。
问题: 我想要在我的 ubuntu 服务器上有 2 个以上的虚拟主机(1 个 IP) 但是 - 仅显示第一个“按字母顺序”列出的已启用站点。 000-默认 www.domain1.com www.domain2.com
单独而言,它们都可以工作(如果我 a2dissite 为每个离开 1)
配置: ubuntu 10.10 服务器 EC2 实例(不要因为这部分而向我开枪 - 希望这不是问题!) 阿帕奇2.2.16 DNS my.domain.com - 到我的公共 ec2 dns(这有效)
虚拟主机:
默认
<VirtualHost *:80>
DocumentRoot "/home/www/"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
<Directory /home/www>
Options Indexes Multiviews FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
LogLevel debug
ErrorLog /home/www/logs/error.log
CustomLog /home/www/logs/access.log "combined"
</VirtualHost>
虚拟主机 1 - 域 1
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain1.com
ServerAlias domain1.com www.domain1.com
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot "/home/www/www.domain1.com/"
# Directory directive
<Directory "/home/www/www.domain1.com">
Options Indexes Multiviews FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
</Directory>
# CGI Directory
ScriptAlias /cgi-bin/ /home/www/www.domain1.com/cgi-bin
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
LogLevel debug
ErrorLog "/home/www/www.domain1.com/logs/error.log"
CustomLog "/home/www/www.domain1.com/logs/access.log" combined
</VirtualHost>
我还在另一个具有不同域名的文档根目录中提供了上述的域 2
符号链接: 我的 apache2ctl -St 显示以下内容 - 虚拟主机配置:
*:80 is a NameVirtualHost
default server (/etc/apache2/sites-enabled/000-default:4)
port 80 namevhost (/etc/apache2/sites-enabled/000-default:4)
port 80 namevhost domain1.com (/etc/apache2/sites-enabled/www.domain1.com:4)
port 80 namevhost www.domain2.com (/etc/apache2/sites-enabled/www.domain2.com:4)
Syntax OK
我的 ports.conf: 名称虚拟主机 *:80 Listen 80
<IfModule mod_ssl.c>
NameVirtualHost *.443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
从默认值到我的 apache2.conf 没有任何变化,并且 httpd.conf 是空的。
我尝试过以下方法(以及大约一百个其他方法):
[URL="http://ubuntu-tutorials.com/2008/01/09/setting-up-name-based-virtual-hosting/"][/URL ] [URL =“http://httpd.apache.org/docs/2.2/rewrite/vhosts.html”]http://httpd.apache.org/docs/2.2/rewrite/vhosts.html[/ URL] [URL =“http://ubuntuforums.org/archive/index.php/t-1466665.html”]http://ubuntuforums.org/archive/index.php/t-1466665.html[/URL] [URL =“http://flurdy.com/docs/ec2/basics/index.html”]http://flurdy.com/docs/ec2/basics/index.html[/URL] [URL =“http://www.webmasterworld.com/apache/3282118.htm”]http://www.webmasterworld.com/apache/3282118.htm[/URL]
看来我已经尝试了其他人所做的一切有问题,但似乎没有什么可以解决我的问题。
可能性:
1)EC2
2) 文件权限 - 我将所有内容更改为 apache2 用户“www-data” - 没有骰子。
3)我是个傻瓜......希望是这样,并且你们中的一个好心人指出我的问题。 :)
很快聊天...我会在这里掉头发。
问候, 洛根萨诺
first time poster, but please help. I have been searching and reconfiguring for 6 days now and have lost several clumps of hair..
PROBLEM:
I want 2+ virtual hosts on my ubuntu server (1 ip)
BUT - Only the first "alphabetically" listed sites-enabled shows.
000-default
www.domain1.com
www.domain2.com
Individually they all work (if i a2dissite for each leaving 1)
CONFIG:
UBUNTU 10.10 Server
EC2 instance (dont shoot me for this part - hoping this isnt the issue!)
APACHE 2.2.16
DNS my.domain.com
- to my public ec2 dns (this works)
Virtual Hosts:
default
<VirtualHost *:80>
DocumentRoot "/home/www/"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Satisfy all
</Directory>
<Directory /home/www>
Options Indexes Multiviews FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
LogLevel debug
ErrorLog /home/www/logs/error.log
CustomLog /home/www/logs/access.log "combined"
</VirtualHost>
Virtual Host 1 - domain1
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain1.com
ServerAlias domain1.com www.domain1.com
# Indexes + Directory Root.
DirectoryIndex index.php
DocumentRoot "/home/www/www.domain1.com/"
# Directory directive
<Directory "/home/www/www.domain1.com">
Options Indexes Multiviews FollowSymLinks
AllowOverride none
Order allow,deny
Allow from all
</Directory>
# CGI Directory
ScriptAlias /cgi-bin/ /home/www/www.domain1.com/cgi-bin
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
LogLevel debug
ErrorLog "/home/www/www.domain1.com/logs/error.log"
CustomLog "/home/www/www.domain1.com/logs/access.log" combined
</VirtualHost>
I also have the above for domain2 in another document root with a different domain name
sym links are in place:
my apache2ctl -St shows the following -
VirtualHost configuration:
*:80 is a NameVirtualHost
default server (/etc/apache2/sites-enabled/000-default:4)
port 80 namevhost (/etc/apache2/sites-enabled/000-default:4)
port 80 namevhost domain1.com (/etc/apache2/sites-enabled/www.domain1.com:4)
port 80 namevhost www.domain2.com (/etc/apache2/sites-enabled/www.domain2.com:4)
Syntax OK
My ports.conf:
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
NameVirtualHost *.443
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
No changes from default to my apache2.conf and httpd.conf is empty.
I have tried the following (and about a hundred others):
[URL="http://ubuntu-tutorials.com/2008/01/09/setting-up-name-based-virtual-hosting/"][/URL]
[URL="http://httpd.apache.org/docs/2.2/rewrite/vhosts.html"]http://httpd.apache.org/docs/2.2/rewrite/vhosts.html[/URL]
[URL="http://ubuntuforums.org/archive/index.php/t-1466665.html"]http://ubuntuforums.org/archive/index.php/t-1466665.html[/URL]
[URL="http://flurdy.com/docs/ec2/basics/index.html"]http://flurdy.com/docs/ec2/basics/index.html[/URL]
[URL="http://www.webmasterworld.com/apache/3282118.htm"]http://www.webmasterworld.com/apache/3282118.htm[/URL]
it seems i have tried everything that everyone else is having issues with but nothing seems to fix mine.
Possibilities:
1) EC2
2) Permissions on the files - I changed everything to the apache2 user "www-data" - no dice.
3) I am a dope...lets hope its that and one of you kind people point me to my issue. :)
Chat soon...ill be over here losing my hair.
Regards, Logansanoh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,Slicehost 即将关闭,但它有一些关于如何实现虚拟主机的很好的文档。
访问:
http://articles.slicehost.com /2010/5/19/apache-virtual-hosts-on-ubuntu-part-1
http://articles.slicehost.com /2010/5/19/apache-virtual-hosts-on-ubuntu-part-2
我已经不再使用 slicehost,但他们的文档仍然非常方便。
作为旁注,您可能不会在这里得到很多回复,因为这个问题更适合:
http://serverfault.com
祝你好运,让我们知道出了什么问题,干杯!
unfortunately Slicehost is slated to go down, but it has some good documentation on how to implement virtual hosts.
visit :
http://articles.slicehost.com/2010/5/19/apache-virtual-hosts-on-ubuntu-part-1
http://articles.slicehost.com/2010/5/19/apache-virtual-hosts-on-ubuntu-part-2
I have shifted away from slicehost but their documentation still comes very handy.
As a side note, You are probably not getting a lot of response here because this question is better suited for :
http://serverfault.com
Best of luck, let us know how what was going wrong, Cheers!
DNS 是罪魁祸首。
EC2、Ubuntu 和 Apache 中的一切都按预期通过。问题是我在 DNS 上使用 URL 重定向。这是愚昧啊!非常简单,我设置了一个 ANAME,而不是使用我的公共 IP 地址作为别名 (www.domain1.com),对于 (www.domain2.com) 也使用相同的地址,一切都运行良好。
现在,如果我能让 TOMCAT 与 mod_proxy 一起运行,我将 100% 成功!
DNS was the culprit.
Everything was being passed as expected in both EC2, Ubuntu and Apache. The problem was I was using URL redirect at the DNS. This is stoopid! It was so simple, I set up an ANAME instead using my public IP address for the alias (www.domain1.com) and the same for the (www.domain2.com) and it all worked perfectly.
Now if i could only get TOMCAT to behave with mod_proxy i will be 100% there!!