绑定到端口 80 时出现问题:无法绑定到 IPv4 或 IPv6

绑定到端口 80 时出现问题:无法绑定到 IPv4 或 IPv6

我有两个项目在不同的端口上运行 - 同一台服务器上的 80 和 8005。这些端口分别指向 example1.com 和 example2.com。我使用以下代码为 example1.com 安装了 SSL 证书https://tecadmin.net/install-lets-encrypt-create-ssl-ubuntu/并且成功了。但是当我尝试 example2.com 时,出现了这个错误 -Problem binding to port 80: Could not bind to IPv4 or IPv6.

我猜想它需要 example2.com 的端口为 80,有解决方法吗?如何为 example2.com 安装 SSL 证书?

/sites-enabled 的样子如下

example1.com-le-ssl.conf example1.com.conf example2.com.conf

example1.com-le-ssl.conf -

<IfModule mod_ssl.c>
<VirtualHost *:443>

        ServerName example1.com
        ServerAlias www.example1.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/example1/public

        <Directory /var/www/html/example1/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
       </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example1.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example1.com/privkey.pem
</VirtualHost>

</IfModule>

example1.com.conf-

<VirtualHost *:80>

        ServerName example1.com
        ServerAlias www.example1.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/html/example1/public

        <Directory /var/www/html/example1/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
       </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


RewriteEngine on
RewriteCond %{SERVER_NAME} =example1.com [OR]
RewriteCond %{SERVER_NAME} =www.example1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

example2.com.conf

<VirtualHost *:80>

        ServerName example2.com
        ServerAlias www.example2.com
        #ServerAdmin [email protected]
        DocumentRoot /var/www/html/example2/public

        <Directory /var/www/html/example2/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        </Directory>
</VirtualHost>

<VirtualHost *:8001>


        ServerName example2.com
        ServerAlias www.example2.com
        #ServerAdmin [email protected]
        DocumentRoot /var/www/html/example2/public

        <Directory /var/www/html/example2/public>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

             SSLEngine on

        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/example2.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example2.com/privkey.pem
</VirtualHost>

相关内容