thinkphp 6.x 5.x nginx php fpm 配置

thinkphp 6.x 5.x nginx 配置

server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /www/php/public/host.access.log  main;
    #error_log /www/php/public/error.log;

    #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
    #		expires      30d;
    #}
    #location ~ .*\.(js|css)?$ {
    #		expires      12h;
    #}
    root /www/php/public;

    index index.html index.htm index.php;

    location / {
        #try_files $uri $uri/ /index.php$is_args$args;

        if ( -f $request_filename) {
            break;
        }
        if (!-e  $request_filename) {
            #rewrite  ^/index.php/(.*)  /index.php?s=/$1  last;
            #rewrite ^/(.*)$ /index.php?s=$1 last;
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }
        try_files $uri $uri/ /index.php$uri?$query_string;
    }

    #error_page  404              /404.html;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }


    location ~ \.php($|/) {
        set $script $uri;
        set $path_info "";
        if ($uri ~ "^(.+\.php)(/.+)") {
            set $script $1;
            set $path_info $2;
        }
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_param    PATH_INFO    $path_info;
        fastcgi_param    SCRIPT_NAME    $script;
        try_files $uri =404;

    }

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

注意
fastcgi_pass 127.0.0.1:9000; 为 PHP的地址和端口

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页