LNMP一键安装包的坑-thinkphp,Zend Framework,laravel等提示500错误

最近安装LNMP运行环境,因为贪图方便,就用了https://lnmp.org/来安装,安装过程还是挺方便的,按照步骤输入即可;

安装完就可以直接显示了,确实方便;

但是运行框架thinkphp,Zend Framework,laravel等的时候,一直显示返回500,懵逼。。。

查了资料,整理问题如下;

1 不允许跨目录访问

该类错误一般都是在Thinkphp、CI、Laravel等框架下,网站目录一般是在public下,但是public下的程序要跨目录调用public上级目录下的文件,因为LNMP默认是不允许跨目录访问的,所以需要将防跨目录访问的设置去掉,进行设置,有时候这些框架类的程序也可能会提示500错误,也可能是这个问题引起的。解决:

/usr/local/nginx/conf/fastcgi.conf 里面的fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 在该行行前添加 # 或删除改行,需要重启nginx。

2 pathinfo配置

其实lnmp一键包里面的pathinfo军哥已经都写好了,在nginx.conf中我们只需要把include enable-php.conf;修改成include enable-php-pathinfo.conf;然后重启lnmp就搞定了。

#include enable-php.conf;或者,你直接注释掉这一行,在下面添加新的一行

include enable-php-pathinfo.conf;

就是这样简单。下面顺便附上在url里隐藏模块的方法

配置文件:

server
    {
        listen 82 default_server;
        server_name _dbe;
        index index.html index.htm index.php;
        root  /home/wwwroot/default/dbe/public;

        #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;或者,你直接注释掉这一行,在下面添加新的一行
		include enable-php-pathinfo.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        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/access.log;
    }
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章