所以我尝试通过在虚拟主机中添加重定向来强制站点范围内的https,现在apache不会启动。这是虚拟主机文件:
Listen 80 443
<VirtualHost *:80>
Redirect permanent / https://www.tedspikes.com/
</VirtualHost>
<VirtualHost *:443>
DocumentRoot /var/www/html
ServerName tedspikes.com
ServerAlias www.tedspikes.com
SSLEngine On
<Directory />
Require all granted
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
当我启动apache时,会抛出这个:
(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
我采取了#34;有人在听我的端口80&#34;。这是踢球者:
ted@Home:~$ sudo netstat -nlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 889/sshd
tcp 0 0 0.0.0.0:1723 0.0.0.0:* LISTEN 903/pptpd
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 987/mysqld
tcp6 0 0 :::22 :::* LISTEN 889/sshd
udp 0 0 188.166.36.165:123 0.0.0.0:* 1367/ntpd
udp 0 0 127.0.0.1:123 0.0.0.0:* 1367/ntpd
udp 0 0 0.0.0.0:123 0.0.0.0:* 1367/ntpd
udp6 0 0 fe80::601:37ff:fefd:123 :::* 1367/ntpd
udp6 0 0 ::1:123 :::* 1367/ntpd
udp6 0 0 :::123 :::* 1367/ntpd
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 9254 895/acpid /var/run/acpid.socket
unix 2 [ ACC ] STREAM LISTENING 9515 987/mysqld /var/run/mysqld/mysqld.sock
unix 2 [ ACC ] STREAM LISTENING 7004 1/init @/com/ubuntu/upstart
unix 2 [ ACC ] STREAM LISTENING 8919 691/dbus-daemon /var/run/dbus/system_bus_socket
unix 2 [ ACC ] SEQPACKET LISTENING 7651 324/systemd-udevd /run/udev/control
所以,阿帕奇不会因为某人占据80号港口而无法开始,但该港口没有人!发生了什么事?我在虚拟主机中破坏了什么吗?
答案 0 :(得分:1)
Listen
指令中存在错误。您不能提及具有单个Listen
指令的多个接口/端口,因此您必须使用多个接口/端口,例如,
Listen 80
Listen 8080
除此之外其他规则看起来很好。关于https重定向,您可以使用下面的规则,该规则更通用,可以避免意外问题。
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
除此之外,不确定为什么会出现Address already in use
错误。