lnmp1.4 一键安装包 nginx配置thinkphp5

来源:互联网 发布:标准偏差计算软件 编辑:程序博客网 时间:2024/06/12 21:25
此问题困扰了我好几天,今天终于重坑里面爬出来了,留下笔记,希望对大家有帮助!
环境:Nginx1.12.1  PHP5.6  Coentos7.2
修改网站配置文件 
例如 /usr/local/nginx/conf/vhost/test.bb.com

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
    }


至此配置文件修改完毕,重启nginx 

若网页出现   Access denied.
在文件有读写权限的前提下 设置php.ini   cgi.fix_pathinfo = 1

若网页出现    scandir() has been disabled for security reasons


在你的php.ini 将  disable_functions  整句注释掉  将scandir 去掉

然后重启php 和nginx ; 熟悉的界面就出现了!


参考文章

1.http://blog.csdn.net/w6611415/article/details/40716563
2.http://blog.csdn.net/qq_35912734/article/details/78557701



原创粉丝点击