Nginx+https+php 设置

编辑:nginx.conf
1 将80端口 申请重定向到https
server {
listen 80;
server_name 45.77.16.164;
return 301 https://$host$request_uri;
}
2 设置Https及Fast-cgi php解析
server {
listen 443 ssl;
server_name server name;

ssl_certificate /etc/nginx/server.crt; #证书
ssl_certificate_key /etc/nginx/server.key; #key
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;

location / {
root /var/www; # 页面路径
index index.html index.php;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$ {
root /var/www; # 页面路径
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
} 

Leave a Reply