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 訪問它時我得到了。同樣,當我執行時,即使它似乎正在處理進入埠 80 的請求,我也得到了。我還註釋掉sudo service apache2 status
了,和in 。我在或中沒有看到任何錯誤,只有登錄Apache2 is NOT running.``NameVirtualHost *:443``LoadModule ssl_module``Listen 443``httpd.conf``/var/log/apache2/error.log``/var/log/apache2/access.log``/var/log/apache2
我在這裡找到了答案https://webmasters.stackexchange.com/questions/58650/what-steps-are-required-to-enable-ssl-on-apache2-with-ubuntu。我不得不執行
sudo a2ensite default-ssl
並重新啟動 apache2。