apache2 没有可用的监听套接字,但端口上没有任何监听

apache2 没有可用的监听套接字,但端口上没有任何监听

我正在尝试在 ubuntu 服务器上设置 SSL。我已经使用以下命令openssl genrsa -out mydomain.key 1024和生成了密钥和证书openssl req -new -key mydomain.key -x509 -out mydomain.crt。我添加LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so到 httpd.conf,我的 httpd.conf 的相关(我认为)摘录是

LoadModule ssl_module /usr/lib/apache2/modules/mod_ssl.so
NameVirtualHost *:80
NameVirtualHost *:443
Listen 80
Listen 443
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:443>
ProxyPass /software-suite http://localhost:8087/software-suite
ProxyPassReverse /software-suite http://localhost:8087/software-suite

SSLEngine on
SSLCertificateFile /etc/apache2/ssl.crt/hostname.crt
SSLCertificateKeyFile /etc/apache2/ssl.key/hostname.key
</VirtualHost>


<VirtualHost *:80>
ProxyPass /software-suite http://localhost:8087/software-suite
ProxyPassReverse /software-suite http://localhost:8087/software-suite

</VirtualHost>

当我跑步时sudo service apache2 start,我得到

* Starting web server apache2                                                                                                                                                                           Thu Feb 25 23:01:37 2016] [warn] module ssl_module is already loaded, skipping
[Thu Feb 25 23:01:37 2016] [warn] The Alias directive in /etc/apache2/httpd.conf at line 499 will probably never match because it overlaps an earlier Alias.
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
Unable to open logs
Action 'start' failed.
The Apache error log may have more information.

但当我跑步时,sudo netstat -ltnp | grep ':443'没有人在听

更新

我将<VirtualHost *:443>节点及其内容移至/etc/apache2/sites-available/default-ssl.当我启动 apache2 时,我得到

 * Starting web server apache2                                                                                                                                                                                                               [Fri Feb 26 16:36:43 2016] [warn] The Alias directive in /etc/apache2/httpd.conf at line 499 will probably never match because it overlaps an earlier Alias.
                                                                                                                                                                                                                                      [ OK ]

我现在可以在端口 80 上访问我的网站,但当ERR_SSL_PROTOCOL_ERROR我尝试使用 https 访问它时却出现问题。另外,当我执行时,我sudo service apache2 status得到Apache2 is NOT running.即使它似乎正在处理进入端口 80 的请求。我还注释掉了NameVirtualHost *:443LoadModule ssl_module和。我在或中没有看到任何错误,唯一的登录Listen 443httpd.conf/var/log/apache2/error.log/var/log/apache2/access.log/var/log/apache2

答案1

我在这里找到了答案https://webmasters.stackexchange.com/questions/58650/what-steps-are-required-to-enable-ssl-on-apache2-with-ubuntu。我必须执行sudo a2ensite default-ssl并重新启动 apache2。

相关内容