Nginx配置SSL之后访问PHP变成下载解决
今天给博客添加阿里的免费SSL证书的时候,需要修改nginx.conf文件,操作如下:
- 找到nginx目前启动用到的配置文件,在/etc/init.d/nginx里面可以看到配置文件所在的路径。比如“CONFIG=’/usr/local/nginx/conf/nginx.conf‘”
- 备份一下配置文件就开始修改吧
- vi nginx.conf
- 开始的时候配置文件添加server段落给https,漏了“ include enable-php.conf;”,导致访问的时候页面直接下载。
- 参考配置信息如下。
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name www.heliang.net.cn heliang.net.cn;
index index.html index.htm index.php;
root /home/wwwroot/default;
ssl_certificate "/home/wwwroot/ssl/heliang.net.cn.pem";
ssl_certificate_key "/home/wwwroot/ssl/heliang.net.cn.key";
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
# ssl_ciphers PROFILE=SYSTEM;
ssl_prefer_server_ciphers on;
ssl_session_tickets off;
keepalive_timeout 70;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
include enable-php.conf;
location /nginx_status
{
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ /.well-known {
allow all;
}
location ~ /\.
{
deny all;
}
access_log /home/wwwlogs/access.log;
}