【问题标题】:Wordpress can't reach a page after added SSL certificate to my VPS将 SSL 证书添加到我的 VPS 后,Wordpress 无法访问页面
【发布时间】:2019-07-07 15:04:57
【问题描述】:

您好,我尝试在线添加 WordPress 网站,但 SSL (LetsEncrypt) 存在一些问题。在我完全按照下面的链接安装它之后:

https://websiteforstudents.com/switch-wordpress-from-http-to-https-on-ubuntu-with-lets-encrypt-and-apache2/

页面只是加载了一段时间,然后它只显示 ERR_CONNECTION_TIMED_OUT。

我认为一切都应该没问题,但不知道为什么它不起作用。

.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
</IfModule>
# END WordPress

wordpress-ls-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/wordpress/
     ServerName example.com
     ServerAlias www.ecample.com

     <Directory /var/www/html/wordpress/>
        Options +FollowSymlinks
        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/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>

apache2 wordpress.conf


<VirtualHost *:80>
     ServerAdmin admin@example.com
     DocumentRoot /var/www/html/wordpress/
     ServerName example.com
     ServerAlias www.example.com

     <Directory /var/www/html/wordpress/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

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

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

没有 SSL 它可以正常工作。而且我还更改了数据库 wordpress 链接到 https://

【问题讨论】:

  • 您是否将网络服务器暴露在正确的端口上? HTTPS 通常连接超过 443,而 HTTP(无 S)使用 80。我真的不知道如何阅读 .htaccess 文件,但 RewriteCond ${SERVER_PORT} 80 似乎很可疑,&lt;VirtualHost *:80&gt; 似乎也很奇怪。
  • 不,不是那个问题,但谢谢你意识到我可能已经阻塞了端口。 THX 它有效。
  • 您应该将该答案作为答案发布,而不是在问题中。
  • 为您的虚拟主机使用端口号80,当尝试通过端口443https 使用的端口)获取页面时,无法找到您的页面看看那里...
  • 看你写的是www.ecample.com而不是www.example.com。要让它发挥作用,你需要纠正很多东西。

标签: php linux wordpress apache ubuntu


【解决方案1】:

我忘记解锁端口了。

sudo ufw allow https

【讨论】:

  • 更糟!!!如果您还有防火墙,那么您将遇到的问题不仅仅是端口号。 :)
  • 那你很幸运! :)
猜你喜欢
  • 2014-11-15
  • 2020-03-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多