我有一个由Apache服务的网站。 它适用于IPv4,但不适用于IPv6。 我有一个500错误。
这是我的ports.conf文件:
# If you just change the port or add more ports here, you will likely also # have to change the VirtualHost statement in # /etc/apache2/sites-enabled/000-default.conf Listen 80 NameVirtualHost *:80 <IfModule ssl_module> Listen 443 </IfModule> <IfModule mod_gnutls.c> Listen 443 </IfModule>
而我的VHost:
<VirtualHost *:80 [::]:80> DocumentRoot "/var/www/html/mysite.ca/www.mysite.ca" ServerName mysite.ca <Directory "/var/www/html/mysite.ca/www.mysite.ca"> allow from all Options +Indexes </Directory> ServerAlias www.mysite.ca </VirtualHost>
当我做netstat-tlnpt ,我有这个:
Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 3577/master tcp 0 0 0.0.0.0:453 0.0.0.0:* LISTEN 4484/perl tcp 0 0 0.0.0.0:360 0.0.0.0:* LISTEN 3254/sshd tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 3307/mysqld tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 2923/vsftpd tcp6 0 0 ::1:25 :::* LISTEN 3577/master tcp6 0 0 :::443 :::* LISTEN 7240/apache2 tcp6 0 0 :::360 :::* LISTEN 3254/sshd tcp6 0 0 :::80 :::* LISTEN 7240/apache2
看来apache已经在监听IPv6地址了。
我试图添加:
Listen [::]:80 Listen [::]:443
到我的端口文件,但我有这个结果,当我重新启动Apache:
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 (98)Address already in use: AH00072: make_sock: could not bind to address [::]:443
我试图通过静态地址来改变wildcars,我有同样的问题。
我有其他网站在同一台服务器上使用IPv6。 这是唯一不行的。
我能做什么 ?
确保apache2完全closures。 可能无论是pipe理服务不知道在后台手动启动的副本。 (运行netstat时应该停止,并确保没有任何东西仍然在听)
根据你的apache版本,你可能不需要NameVirtualHost。 请参阅https://httpd.apache.org/docs/current/upgrading.html
如果你得到了500错误,那么肯定是在监听端口和响应。 这应该logging在你的error.log。 如果没有,您可能需要调整日志选项以包含它。 我没有看到任何指示您是运行apache2.2还是2.4,并且日志configuration在两者之间不同。
编辑:看到这个页面关于LogLevel https://httpd.apache.org/docs/2.4/mod/core.html#loglevel
确保每个IP每个端口具有一个Listen 端口 ,每个服务器每个完整的configuration可以注释掉,直到它开始而没有抱怨,看看它是否仍然在端口80/443上启动
对于ipv6和ipv4,你只需要
listen 80 listen 443 https
find /etc/httpd/ | xargs grep -sniH "listen"
我在你的netstat输出中看到这个:
tcp6 0 0 ::: 443 ::: * LISTEN 3254 / sshd
这意味着你有一个ssh进程监听你的IPv6端口443,实际上Apache不能绑定到这个端口:
(98)已经在使用的地址:AH00072:make_sock:无法绑定到地址[::]:443