lnmp+laravel部署到服务器出现 "GET / HTTP/1.1" 500 5 - and大头 - 博客园

来源: lnmp+laravel部署到服务器出现 “GET / HTTP/1.1” 500 5 – and大头 – 博客园

lnmp一键安装包直接下载安装,就可以了,在此不多说。

虚拟机配置给个参考(lnmp安装包)

复制代码
server
    {
        listen 80;
        #listen [::]:80;
        server_name www.dtcode.cn dtcode.cn;
        index index.html index.htm index.php default.html default.htm default.php;
        set $root  /home/wwwroot/laravel;
        root    /home/wwwroot/laravel/public;

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

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

 location / {
                try_files $uri $uri/ /index.php?$query_string;
        }
location ~ \.php$ {
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index /index.php;

            fastcgi_split_path_info       ^(.+\.php)(/.+)$;
            fastcgi_param PATH_INFO       $fastcgi_path_info;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include                       fastcgi_params;
     }

 location ~ /\.
        {
           deny all;
        }

        access_log  /home/wwwlogs/laravel_log.log;
    }
复制代码

然后运行出现 500 Internal Server Error ,到这个我就怕了,解决方法

更改 laravel/storage   和 laravel/bootstrap/cache   权限为 777

同时修laravel改项目目录文件全限为 775,所属组 www

chown -R www   laravel

 chmod -R 775   laravel

错误继续出现: chown: changing ownership of `question/public/.user.ini’: Operation not permitted

发现root用户对该文件也没有-x执行权限。通过网上查找才知道,原来该文件被chattr锁定了。这里就了解了一下Linux的chattr和lsattr命令。

这两个命令是用来查看和改变文件目录属性的,和chmod相比,chmod只是改变文件的读写、执行权限,更底层的属性控制是由chattr来改变的。而lsattr命令是显示chattr命令设置的文件属性。所以,这里需要使用chattr命令对.user.ini文件解锁

解决办法,修改项目根目录,.user.ini文件

复制代码
1.先给.user.ini 可以修改的权限
#chattr -i .user.ini
2.然后修改
# vi .use.ini
3.修改.use.ini内容
open_basedir=/home/wwwroot/default/laravel/public:/tmp/:/proc/
改为
open_basedir=/home/wwwroot/default/laravel/:/tmp/:/proc/
4.最后更改.user.ini权限为不能修改
#chattr +i .user.ini
复制代码
赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏