nginx-php的相关配置信息

2021-04-01  本文已影响0人  Mracale

nginx.conf文件配置如下

#http强制跳转到https
server {
    listen 80;
    server_name test.baidu.com;
    rewrite ^(.*)$ https://$host$1 permanent;
}
server {
 listen 443 ssl default_server;
 listen [::]:443 ssl default_server;
 #配置HTTPS的默认访问端口为443。
 #如果未在此处配置HTTPS的默认访问端口,可能会造成Nginx无法启动。
 #如果您使用Nginx 1.15.0及以上版本,请使用listen 443 ssl代替listen 443和ssl on。
 server_name  test.baidu.com;
 ssl_certificate cert/test.baidu.com.pem;  #需要将cert-file-name.pem替换成已上传的证书文件的名称。
 ssl_certificate_key cert/test.baidu.com.key; #需要将cert-file-name.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; #表示使用的TLS协议的类型。
 ssl_prefer_server_ciphers on;
 
 #开启和关闭gzip模式
 gzip on;
 index index.php index.html index.htm index.nginx-debian.html;
 root   /usr/share/nginx/test/public;
 
#phpinfo模式
 location / {
    try_files $uri $uri/ =404;
    if (!-e $request_filename){
        rewrite ^/(.*)$ /index.php?s=/$1 last;
    }
 }

 error_page   500 502 503 504  /50x.html;

 location ~ .php$ {
   fastcgi_pass   127.0.0.1:9000;
   fastcgi_index  index.php;
   fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
   include        fastcgi_params;
 }
}
上一篇 下一篇

猜你喜欢

热点阅读