nginx(lnmp一键安装包)PHP项目配置

server

    {

        listen 80;

        #listen [::]:80;

        server_name test.bb.com;

        index index.html index.htm index.php default.html default.htm default.php;

        root  /home/wwwroot/test.bb.com/public;

       # include none.conf;

        #error_page  404  /404.html;

        # Deny access to PHP files in specific directory

        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        #include enable-php.conf;


      #将url中server_name之后的部分与 /tp5/public/* 匹配 如果匹配则改写URl为/tp5/public/index.php/*

  #lnmp一键安装包可直接  include thinkphp.conf

      location / {

                index index.html index.htm index.php;

                #autoindex on;

              if (!-e $request_filename) {

                    rewrite ^(.*)$ /index.php?s=/$1 last;

                    break;

              }

          }

    location ~ \.php(.*)$ {

            fastcgi_pass  unix:/tmp/php-cgi.sock; #请填写自己的路径

            fastcgi_index  index.php;

            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;

            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

            fastcgi_param  PATH_INFO  $fastcgi_path_info;

            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

            include        fastcgi_params;

        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

        {

            expires      30d;

        }

        location ~ .*\.(js|css)?$

        {

            expires      12h;

        }

        location ~ /.well-known {

            allow all;

        }

        location ~ /\.

        {

            deny all;

        }

        access_log  /home/wwwlogs/test.bb.com.log

    }


若网页出现Access denied.

在文件有读写权限的前提下 设置php.ini cgi.fix_pathinfo = 1

你可能感兴趣的:(nginx(lnmp一键安装包)PHP项目配置)