服务器里有许多应用模板,这些应用装上应可以运行,非常方便,但配置https踩了许多坑,记录一下吧
以WordPress 腾讯云插件版为例,应用信息如下
SSL证书安装
点击Nginx服务器证书安装,按照教程做,一般可以顺利安装成功。
坑 的地方在于怎么将网页跳到php应用上,教程中可以看到Https请求Nginx的欢迎页面,按照网上教程或Nginx官网文档怎么设置fastcgi_pass都不好使
解决方案:
在 /usr/local/lighthouse/softwares/nginx/conf/include
这个文件夹下有一个conf文件,需要修改这个文件(把域名改为你的域名)
server {
listen 443 ssl;
server_name 域名;
ssl_certificate /root/域名_bundle.crt;
ssl_certificate_key /root/域名.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
server_tokens off;
keepalive_timeout 5;
root /usr/local/lighthouse/softwares/wordpress-plugin;
index index.php index.html;
access_log logs/wordpress.log combinediox;
error_log logs/wordpress.error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
client_max_body_size 20m;
fastcgi_connect_timeout 30s;
fastcgi_send_timeout 30s;
fastcgi_read_timeout 30s;
fastcgi_intercept_errors on;
}
}
server {
listen 80 default_server;
server_tokens off;
keepalive_timeout 5;
root /usr/local/lighthouse/softwares/wordpress-plugin;
index index.php index.html;
access_log logs/wordpress.log combinediox;
error_log logs/wordpress.error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
client_max_body_size 20m;
fastcgi_connect_timeout 30s;
fastcgi_send_timeout 30s;
fastcgi_read_timeout 30s;
fastcgi_intercept_errors on;
}
}
配置好之后可以访问到WP主页了,但主页没有样式,还需要配置WP
vi /usr/local/lighthouse/softwares/wordpress-plugin/wp-config.php
在你的 wp-config.php 文件中粘贴这段代码,
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
如果配置http跳转https, /usr/local/lighthouse/softwares/nginx/conf/include
的conf文件使用下面的配置(把域名改为你的域名)
server {
listen 443 ssl;
server_name 域名;
ssl_certificate /root/域名_bundle.crt;
ssl_certificate_key /root/域名.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
server_tokens off;
keepalive_timeout 5;
root /usr/local/lighthouse/softwares/wordpress-plugin;
index index.php index.html;
access_log logs/wordpress.log combinediox;
error_log logs/wordpress.error.log;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~* \.php$ {
fastcgi_pass 127.0.0.1:9000;
include fastcgi.conf;
client_max_body_size 20m;
fastcgi_connect_timeout 30s;
fastcgi_send_timeout 30s;
fastcgi_read_timeout 30s;
fastcgi_intercept_errors on;
}
}
server {
listen 80 default_server;
server_tokens off;
keepalive_timeout 5;
root /usr/local/lighthouse/softwares/wordpress-plugin;
index index.php index.html;
access_log logs/wordpress.log combinediox;
error_log logs/wordpress.error.log;
server_name 域名;
server_name www.域名;
rewrite ^ https://域名$request_uri? permanent;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)