[Linux]lnmp一键安装包,访问yii/tp5/laravel的时候,报错500或者
当你将默认的访问路径改后(nginx.conf中的root 之后的路径),同时应该将/home/wwwroot/default/.user.ini 中的路径也改了! .user.ini 是隐藏文件,需要 ls -a? 查看;
lnmp v1.1上,修改对应虚拟主机的配置文件(/usr/local/nginx/conf/vhost/域名.conf) 去掉#include pathinfo.conf前面的#,把try_files $uri =404; 前面加上# 注释掉。 1.2,1.3上,修改对应虚拟主机的配置文件(/usr/local/nginx/conf/nginx.conf)将include enable-php.conf;替换为include enable-php-pathinfo.conf; 修改pathinfo需要重启nginx生效。
? ? ? ? listen? ? ? ?80 ? ? ? ? server_name? www.aaa. ? ? ? ? root? ?"你的项目路径" ? ? ? ? ? enable-php-.conf;
? ? ? location / ? ? ? ? location ~ .*.(gif|jpg|jpeg|png|bmp| ? ? ? ?location ~ .*.(js|css)? ? ? ? ? location ~ /.well- ? ? ? ? location ~ /.
? ? ? ? location ~ /index. ? ? ? ? ? ? fastcgi_pass? ?127.0.0.1:9000 ? ? ? ? ? ? fastcgi_index? index. ? ? ? ? ? ? fastcgi_param? SCRIPT_FILENAME? /index. ? ? ? ? ? ? ? ? ? ? location / ? ? ? ? ? ?index? index.html index.htm index.php l. ? ? ? ? ? ? (!-e ? ? ? ? ? ? ? rewrite ^/(.*) /index. ? ? ? ? error_page? ?500 502 503 504? /50x. ? ? ? ? location = /50x. ? ? ? ? location ~ .php(.* ? ? ? ? ? ? fastcgi_pass? ?127.0.0.1:9000 ? ? ? ? ? ? fastcgi_index? index. ? ? ? ? ? ? fastcgi_split_path_info? ^((?U).+.php)(/?.+ ? ? ? ? ? ? fastcgi_param? SCRIPT_FILENAME? ? ? ? ? ? ? fastcgi_param? PATH_INFO? ? ? ? ? ? ? fastcgi_param? PATH_TRANSLATED? ? ? ? ? ? ? ? ? }
在你框架index.php开头,打开报错,如下: error_reporting(E_ALL); ini_set('display_errors','1');默认是没有开启报错的,设置如下: 1、先打开php的错误提示 ????将 php.ini中的 display_errors = Off 修改为 On; 2、开启nginx的报错 在 /usr/local/php/etc/php-fpm.conf 加上 php_admin_value[error_log] = /usr/local/php/var/log/php_errors.logphp_admin_flag[log_errors] = on 有时可能错误日志文件不自动创建,可以执行:touch /usr/local/php/var/log/php_errors.log && chown www:www /usr/local/php/var/log/php_errors.log
PHP?Warning:?():?open_basedir?restriction?in?effect.?(/home/wwwroot//laravel/bootstrap/autoload.php)?is?not?within?the?allowed?path(s):?(/home/wwwroot//laravel/:/tmp/://tmp/:/proc/)?in?/home/wwwroot//laravel//index.php?on?line?22 PHP?Warning:?(/home/wwwroot//laravel/bootstrap/autoload.php):?failed?to?open?stream:?Operation?not?permitted?in?/home/wwwroot//laravel//index.php?on?line?22 PHP?Fatal?error:?():?Failed?opening?required?‘/home/wwwroot//laravel//../bootstrap/autoload.php‘?(include_path=‘.:/usr/local/php/lib/php‘)?in?/home/wwwroot//laravel//index.php?on?line?22??
解决(1)检查php.ini的 open_basedir的参数 将其开启,写为自己的项目路径(2)如果是lnmp(nginx服务器),检查 path/nginx/conf/fastcgi.conf里的 $document_root参数fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/home/stone/dsales/"; (/home/stone/dsales/为项目路径)注意:如果在fastcgi.conf里没有 fastcgi_param PHP_ADMIN_VALUE……自行添加? ? ? ?如果这样还是报错的话,那就改为?fastcgi_param PHP_ADMIN_VALUE "open_basedir=NULL"; 这样的话你就应该可以访问到项目了。。。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |