nginx配置分解分享,另存为xxxx.conf放在linux环境下的/etc/nginx/conf.d/ 目录下,即可支持TP(ThinkPHP)的伪静态

server {
listen 443 ssl http2 default_server;
#listen [::]:443 ssl;
server_name dskk.grapis.club;
if (KaTeX parse error: Expected '}', got 'EOF' at end of input: … rewrite ^/(.*) https://dskk.graphis.club/$1 permanent;
}
#error_page 404 /data/web/kezhilian/404.html;

 ssl on;    #开启ssl支持
 ssl_certificate      /data/ssl/dskk.graphis.club.pem;    #指定服务器证书路径
 ssl_certificate_key  /data/ssl/dskk.graphis.club.key;    #指定私钥证书路径
 ssl_session_timeout  5m;
 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;     #指定SSL服务器端支持的协议版本
 #ssl_ciphers  ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;    #指定加密算法
 #sl_prefer_server_ciphers   on;    #在使用SSLv3和TLS协议时指定服务器的加密算法要优先于客户端的加密算法 

 #	ssl_session_timeout 5m;
 #	ssl_session_cache shared:SSL:10m;
 #  ssl_protocols TLSv1 TLSv1.1 TLSv1.2 SSLv2 SSLv3;
 #	ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
 #	ssl_prefer_server_ciphers on;
 #	ssl_verify_client off;


root   /myweb/dskk;
location / {
    add_header Access-Control-Allow-Origin *;
    index  index.php index.html index.htm;
    if (!-e $request_filename) {
       rewrite  ^/(.*)$  /index.php/$1  last;
       break;
    }
}

location ~ \.php/?.*$ {
    add_header Access-Control-Allow-Origin *; 
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;

    #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            #Used in CentOS 20160801
            include        fastcgi_params;

     set $temp_script_name $fastcgi_script_name;
     if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {
        set $temp_script_name $1;
        set $path_info $2;
     }
    fastcgi_param   PATH_INFO $path_info;
    fastcgi_param   SCRIPT_FILENAME   $document_root$temp_script_name;
    fastcgi_param   SCRIPT_NAME   $temp_script_name;
}

location ~ /\.ht {
    deny  all;
}

}

server {
listen 80;
#listen somename:8080;
server_name dskk.graphis.club;
client_max_body_size 80m;
#error_page 404 /data/ymg280/404.html;
#error_page 500 502 503 504 /errors/default/50x.html;

    if ($host != 'dskk.graphis.club'){
	rewrite ^/(.*)$ http://dskk.graphis.club/$1 permanent;
}
root /myweb/dskk;
location / {
    index  index.php index.html index.htm;
    if (!-e $request_filename) {  
       rewrite  ^/(.*)$  /index.php/$1  last;  
       break;  
    }  
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php/?.*$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;   

    #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
	#Used in CentOS 20160801
	include        fastcgi_params;
	
	set $temp_script_name $fastcgi_script_name;  
     if ($fastcgi_script_name ~ "^(.+\.php)(/.+)$") {  
        set $temp_script_name $1;  
        set $path_info $2;  
     }  
    fastcgi_param   PATH_INFO $path_info; 
    fastcgi_param   SCRIPT_FILENAME   $document_root$temp_script_name;  
    fastcgi_param   SCRIPT_NAME   $temp_script_name;  
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
    deny  all; 
}

}

你可能感兴趣的:(PHP,THINKPHP,linux,nginx,TP,nginx)