Nginx部署ThinkPHP3.x心得

使用LNMP一键安装之后,由于Nginx不支持pathinfo,所以对nginx和php做了修改

修改/usr/local/nginx/conf/nginx.conf

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name www.lnmp.org;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

        #error_page   404   /404.html;
#        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location / {
          try_files $uri @rewrite;
        }
       location @rewrite {
        set $static 0;
        if  ($uri ~ \.(css|js|jpg|jpeg|png|gif|ico|woff|eot|svg|css\.map|min\.map)$) {
            set $static 1;
        }
        if ($static = 0) {
            rewrite ^/(.*)$ /index.php?s=/$1;
        }
    }
    location ~ /Uploads/.*\.php$ {
        deny all;
    }
    location ~ \.php/ {
       if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
       fastcgi_pass unix:/tmp/php-cgi.sock;
       include fastcgi_params;
       fastcgi_param SCRIPT_NAME     $1;
       fastcgi_param PATH_INFO       $2;
       fastcgi_param SCRIPT_FILENAME $document_root$1;
    }
    location ~ \.php$ {
        fastcgi_pass unix:/tmp/php-cgi.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /\.
        {
            deny all;
        }


        access_log  /home/wwwlogs/access.log  access;
    }

修改 /usr/local/php/etc/php.ini

cgi.fix_pathinfo=1


你可能感兴趣的:(Nginx部署ThinkPHP3.x心得)