nginx 下配置https 访问php文件提示下载文件 解决方法
本地证书放入cert文件后 修改nginx 的配置文件 (这是正确的配置文件php为编译安装)
server {
listen 443 ssl;
server_name www.lvyanshi.com; ##域名
root /home/wwwroot/default; ##网站根目录位置
index index.html index.htm index.php; ##主页类型
ssl_certificate cert/www.lvyanshi.com.pem; ##证书
ssl_certificate_key cert/www.lvyanshi.com.key; ##秘钥
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
location / {
root /home/wwwroot/default; ##网站根目录位置
index index.html index.htm index.php; ##主页类型
}
location ~ .*\.php$ {
root /home/wwwroot/default; ##网站根目录位置
fastcgi_pass unix:/tmp/php-cgi.sock; ##出现502 报错主要确定这个文件的存储位置在哪
# fastcgi_pass 127.0.0.1:9000; ##开启这个会出现502报错
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;}
}