[英]Can't access virtualhost on CentOS 6 with apache 2.2.15
我一直在四处寻找并尝试对Apache 2.2.15服务器的httpd.conf文件进行不同的配置,但找不到解决方案。 因此,我将其发布在此处,以寻求Guru的帮助。
我在CentOS 6.7服务器上的/etc/httpd/conf/httpd.conf中具有此配置。
Listen 80
Listen 8080
<VirtualHost *:8080>
ServerName example.com (Corrected after the comment)
DocumentRoot /var/www/dbgui
ErrorLog logs/dbgui-8080-error_log
<Directory /var/www/dbgui>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/laravel/public
ErrorLog logs/example-80-error_log
<Directory /var/www/laravel>
AllowOverride All
</Directory>
</VirtualHost>
当我浏览到http://example.com时,我得到了Laravel页面(按预期),但是当我浏览到http://example.com:8080时,我得到了“连接超时”的信息 。
我已经在IP表上打开了8080的端口
output of netstat -nltup
tcp 0 0 :::8080 :::* LISTEN 13097/httpd
tcp 0 0 :::80 :::* LISTEN 13097/httpd
和
Output of iptables -L -nv
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
669 41648 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
我没有在日志中看到任何东西。 尽管似乎Apache正在监听8080端口,但8080端口并没有通过任何日志记录。
有解决这个问题的建议吗?
该端口不应该是ServerName
指令的一部分。
请从ServerName
指令中删除端口,如下所示:
<VirtualHost *:8080>
ServerName example.com
DocumentRoot /var/www/dbgui
ErrorLog logs/dbgui-8080-error_log
<Directory /var/www/dbgui>
AllowOverride All
</Directory>
</VirtualHost>
请参阅apache.org上的示例以供参考
您应该检查NameVirtualHost
参数,以确保可以从IP /端口组合中猜出虚拟主机
谢谢大家帮助。 经过大量研究并尝试了不同的方法,然后在扔椅子之前,我终于解决了。 它是这样的:确保iptables正确打开了tcp / 8080的端口和协议后,接下来,再次检查VirtualHost设置是否正确并且上述设置正确。 接下来我要做的是确保将全部禁用或将其设置为许可模式,从而确保selinux不会阻止端口8080。
#semanage port -l | grep http
http_cache_port_t tcp 3128, 8080, 8118, 8123, 10001-10010
http_cache_port_t udp 3130
http_port_t tcp 80, 81, 443, 488, 8008, 8009, 8443, 9000
pegasus_http_port_t tcp 5988
pegasus_https_port_t tcp 5989
可以看出,端口8080在http_cache_port_t中列出,现在确保selinux不会阻止该端口
#setsebool -P httpd_can_network_memcache 1
然后列出它以确保将其设置为“ on”或“ 1”
# getsebool httpd_can_network_memcache
以上所有命令均不能解决问题,而我正在调查日志/var/log/audit/audit.log
和/ var / log / httpd / access_log和/var/log/httpd/error_log
我什么也找不到与端口8080有关的错误毕竟,我开始认为它没有意义,因为所有配置均正确,但我无法通过。 所以我只看了iptables输出:
#iptables -L -nv
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
25 1316 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
24 1240 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:443
其中显示了0个数据包和0个字节通过服务器。 我找到这个网站
http://www.yougetsignal.com/tools/open-ports/
它表明端口8080被阻塞。 当最后把椅子举在空中的时候:),我联系了ISP,并被告知服务器前面有防火墙,端口8080被阻止,当他们打开它时,我放下椅子,因为我终于可以访问了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.