我试图在我的EC2帐户上设置一个子域名,但无法弄清楚发生了什么事情。 我找了几个小时,一直没有find答案: – /
我试图build立一个使用虚拟主机的子域,但无论我尝试浏览器无法find子域:-(
我有以下的vhosts文件设置:
apache2 / sites-available / mysite (这个网站目前有效)
<VirtualHost *:80> ServerName mysite.com ServerAdmin webmaster@localhost DocumentRoot /home/sites/mysite <Directory /home/sites/mysite> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/mysite-error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/mysite-access.log combined </VirtualHost>
apache2 / sites-available / red (这是我试图设置的子域)
<VirtualHost *:80> ServerName red.mysite.com ServerAdmin webmaster@localhost DocumentRoot /var/www/red <Directory /var/www/red> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/red-error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/red-access.log combined </VirtualHost>
Apache mod_rewrite已启用。
我已经启用了这两个网站使用a2ensite,我确保我重新启动Apache每次我做出改变。
/ etc / hosts文件
127.0.0.1 localhost 127.0.0.1 mysite.com 127.0.0.1 red.mysite.com
任何帮助,将不胜感激。
谢谢!
如何debugging所有类似的错误:
1)确保域red.whatever.com指向正确的IP
这个怎么做? 在linux / osx上使用像DIG这样的工具,或者使用在线工具 。
浏览器在这种情况下报告的常见错误是COULD NOT FIND DOMAIN …
2)如果IP是正确的,请检查Apache日志(error.log和access.log)
如果这些日志中没有任何信息,请检查防火墙,查看端口80是否处于打开状态。
在这种情况下浏览器报告的常见错误是可以不连接…
3)IP是正确的,端口是开放的,Apache没有提供你期望的内容
您的问题的解决scheme将由日志文件给出
浏览器将显示404或类似的服务器发送的HTTP错误…
编辑:从你的评论你的问题是在1号。
NameVirtualHost指令(例如, NameVirtualHost *:80 )是否出现在虚拟主机部分之前的configuration文件中? 如果不是的话,所有的请求都会去第一个虚拟主机。