当你将默认的访问路径改后(nginx.conf中的root 之后的路径),同时应该将/home/wwwroot/default/.user.ini 中的路径也改了!

.user.ini 是隐藏文件,需要 ls -a  查看;

第一步:你先确定你的pathinfo路由开启了,配置如下:

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生效。

第二步:路由重写设置成功

 server {
        listen       80;
        server_name  www.aaa.com;
        root   "你的项目路径";
        include  enable-php-pathinfo.conf;//开启pathinfo
      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;
        }
        location ~ /index.php {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
            include        fastcgi_params;
            fastcgi_param APPLICATION_ENV dev;
        }
        location / {
           index  index.html index.htm index.php l.php;
           autoindex  on;
           if (!-e $request_filename){
              rewrite ^/(.*) /index.php last;
           }
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            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;
        }
    }

第三步:再次访问,如果是500/空白页面

在你框架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.log
php_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: require(): open_basedir restriction in effect. File(/home/wwwroot/default/laravel/bootstrap/autoload.php) is not within the allowed path(s): (/home/wwwroot/default/laravel/public:/tmp/:/var/tmp/:/proc/) in /home/wwwroot/default/laravel/public/index.php on line 22  
  
PHP Warning: require(/home/wwwroot/default/laravel/bootstrap/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/default/laravel/public/index.php on line 22  
  
PHP Fatal error: require(): Failed opening required ‘/home/wwwroot/default/laravel/public/../bootstrap/autoload.php‘ (include_path=‘.:/usr/local/php/lib/php‘) in /home/wwwroot/default/laravel/public/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";

  这样的话你就应该可以访问到项目了。。。

[Linux]lnmp一键安装包,访问yii/tp5/laravel的时候,报错500或者空白页面的更多相关文章

  1. lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php

    tp5 url 线上访问 在nginx 上 出现404错误 那是因为pathinfo没有被支持 修改如下:找到   /usr/local/nginx/config/vhost/项目名.config s ...

  2. LNMP一键安装包

    http://www.aliweihu.com/333.html LNMP一键安装包是什么? LNMP一键安装包是一个用Linux Shell编写的可以为CentOS/RadHat.Debian/Ub ...

  3. 安装lnmp一键安装包(转)

    系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP,OpenVZ的另外 ...

  4. CentOS下Web服务器环境搭建LNMP一键安装包

    CentOS下Web服务器环境搭建LNMP一键安装包 时间:2014-09-04 00:50来源:osyunwei.com 作者:osyunwei.com 举报 点击:3797次 最新版本:lnmp- ...

  5. LNMP一键安装包 V1.1 通告

    LNMP一键安装包 是一个用Linux Shell编写的能够为CentOS/RadHat.Debian/Ubuntu VPS(VDS)或独立主机安装LNMP(Nginx.MySQL/MariaDB.P ...

  6. Linode和DigitalOcean lnmp一键安装包哪个好?

    Linode和DigitalOcean都是非常棒的VPS厂商,512MB内存的VPS每月低到5美元,搭建wordpress网站,非常方便,甚至可以多人共用,服务器足够强悍,跑几个wordpress博客 ...

  7. LNMP一键安装包添加虚拟主机、删除虚拟主机及如何使用伪静态

    本文主要介绍LNMP一键安装包添加虚拟主机.删除虚拟主机及如何使用伪静态. 一.添加虚拟主机通俗点就是在VPS/服务商上添加一个网站(域名). 需要执行如下命令:/root/vhost.sh 执行后会 ...

  8. lnmp 一键安装包

    系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要5GB以上硬盘剩余空间 需要128MB以上内存(如果为128MB的小内存VPS,Xe ...

  9. 安装 - LNMP一键安装包

    https://lnmp.org/ 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要5GB以上硬盘剩余空间 需要128MB以上内存( ...

随机推荐

  1. Java 判断两个对象是否相等

    一.使用 == 与 equals == : 它的作用是判断两个对象的地址是不是相等.即,判断两个对象是不是同一个对象.(基本数据类型==比较的是值,引用数据类型==比较的是内存地址) equals() ...

  2. For、Foreach、和Parallel.For等简单的速度检测

    控制台代码  直接复制即可 static void Main(string[] args) { List<int> testData = new List<int>(); Ra ...

  3. Spring Boot(八):RabbitMQ 详解

    RabbitMQ 即一个消息队列,主要是用来实现应用程序的异步和解耦,同时也能起到消息缓冲,消息分发的作用. 消息中间件在互联网公司的使用中越来越多,刚才还看到新闻阿里将 RocketMQ 捐献给了 ...

  4. JAVA面试题-数组字符串基础

    1.大写的Integer和String是可变类还是不可变类?怎么定义不可变类?不可变.用final关键字,如public final class Integer extends Number 2.比较 ...

  5. OS之进程管理---多线程模型和线程库(POSIX PTread)

    多线程简介 线程是CPU使用的基本单元,包括线程ID,程序计数器.寄存器组.各自的堆栈等,在相同线程组中,所有线程共享进程代码段,数据段和其他系统资源. 传统的的单线程模式是每一个进程只能单个控制线程 ...

  6. C# Windows异步I/O操作

    1.简介 关于Windows的异步I/O操作,只要解决的是同步I/O操作的线程利用率问题,通过异步I/O Api来提升线程的利用率,提升系统的吞吐能力,将各种I/O操作交给线程池然后交由硬件设备执行, ...

  7. sql server 备份与恢复系列三 简单恢复模式下的备份与还原

    一.概述 前面讲了备份的一些理论知识,这篇开始讲在简单恢复模式下的备份与还原.在简单模式下是不能做日志备份的,发生灾难后,数据库最后一次备份之后做的数据修改将是全部丢失的,所以在生产环境下,数据又很重 ...

  8. mysql 开发基础系列14 字符集

    字符集是一套文字符号及其编码,比较规则的集合.第一个字符集是ascll(american standard code for information interchange).  1.  选择合适的字 ...

  9. Centos7搭建邮件服务器-Postfix+Cyrus-sasl+Courier-authlib+Dovecot+ExtMail+Centos7

    1.环境介绍 MTA: Postfix 3.1.4 SASL: Cyrus-sasl 2.1.26 ; Courier-authlib 0.66.1(Cyrus-sasl使用Courier-authl ...

  10. Perl函数:字符串相关函数

    Perl字符串相关函数 字符串的内置函数有: chomp, chop, chr, crypt, fc, hex, index, lc, lcfirst, length, oct, ord, pack, ...