线上 Lnmp 环境布置 Laravel 出现 500 错误?
大哥们,小弟在网上找了各种的答案还是没解决,是在是迫不得已才来提问;
小弟我使用的是Lnmp 一键安装包 1.4 没设置虚拟机所以还没有 .usr.ini
文件
已经给了当前项目 chmod -R 755 *
权限了 然后在给了目录 chmod -R 777 storage
和chmod -R 777 bootstrap
权限了,chown -R www:www /项目名称 这个也给了
nginx.conf 配置文件里面也配置了:
index index.html index.htm index.php default.html default.htm default.php;
66 root /home/wwwroot/haojifang/public;
67 location /
68 {
69 try_files $uri $uri/ /index.php?$query_string;
70 }
71 #error_page 404 /404.html;
72 # Deny access to PHP files in specific directory
73 #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
74 include enable-php.conf;
63 #listen [::]:80 default_server ipv6only=on;
64 server_name 192.168.1.244;
65 index index.html index.htm index.php default.html default.htm default.php;
66 root /home/wwwroot/haojifang/public;
67 location /
68 {
69 try_files $uri $uri/ /index.php?$query_string;
70 }
71 #error_page 404 /404.html;
72 # Deny access to PHP files in specific directory
73 #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }
74 include enable-php.conf;
75 location /nginx_status{
76 stub_status on;
77 access_log off;
78 }
79 location ~ \.php$ {
80 #try_files $uri /index.php =404;
81 fastcgi_split_path_info ^(.+\.php)(/.+)$;
82 fastcgi_pass unix:/tmp/php-cgi.sock;
83 fastcgi_index index.php;
84 include fastcgi_params;
85 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
86 }
87 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
88 {
89 expires 30d;
90 }
91 location ~ .*\.(js|css)?$
92 {
93 expires 12h;
94 }
95 location ~ /.well-known
96 {
97 allow all;
98 }
99 location ~ /\.
100 {
101 deny all;
102 }
103 access_log /home/wwwlogs/access.log;
104 }
105 include vhost/*.conf;
我在项目下面的public/index.php 文件中 测试了下
echo '加载之前';
require __DIR__.'/../bootstrap/autoload.php';
echo '加载之后';
结果是走到加载之前,这里就开始不走了,
加载之前
Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/haojifang/bootstrap/autoload.php) is not within the allowed path(s): (/home/wwwroot/haojifang/public/:/tmp/:/proc/) in /home/wwwroot/haojifang/public/index.php on line 22
Warning: require(/home/wwwroot/haojifang/bootstrap/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/haojifang/public/index.php on line 22
Fatal error: require(): Failed opening required '/home/wwwroot/haojifang/public/../bootstrap/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/haojifang/public/index.php on line 22
现在的我是毫无办法了,求各位大哥帮帮忙
https://serverfault.com/questions/431200/h...
这个项的意思是php可以操作的目录
如果上面的看不懂,可以看这个
https://segmentfault.com/q/101000000377788...
@ruke 我是把 fastcgi.conf 里面的 fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/"; 注释掉了这种方法有什么区别呢
@麦迪文 区别不知道,因为从来没使用过这个配置项,也没有用过一键安装包。
线上部署推荐一篇我整理的参考文章点我传送
@Jimmy9876 大哥是使用的是 centos 系统的
你好,请问你这个问题解决了吗?我也遇到了同样的问题,被困扰整整2天了,到处找不到答案,能解答一下吗?谢谢啦。感激不尽!
都一年了还没有答案吗?
直接去 lnmp 的下载目录下的 tools 文件夹,执行
./remove_remove_open_basedir_restriction.sh*
Lnmp 一键安装包 2.0版本,在lnmp的解压目录下的tools文件夹执行
./remove_open_basedir_restriction.sh
脚本