zoukankan      html  css  js  c++  java
  • laravel项目在lnmp环境上线出现404错误

    项目上传到服务器后出现了404的错误,查看了错误日志:

    PHP message: PHP Warning: Unknown: failed to open stream: Operation not permitted in Unknown on line 0
    

      

    Unable to open primary script: /www/wwwroot/yjx.ycqmd.top/public/index.php (Operation not permitted)" while reading response header from upstream, client: 118.78.36.242, server: yjx.ycqmd.top, request: "GET /home/index HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi-71.sock:", host: "tk.ycqmd.top"
    

      

    2020/02/29 18:06:16 [error] 24746#0: *1267 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/www/wwwroot/yjx.ycqmd.top/public/index.php) is not within the allowed path(s): (/www/wwwroot/xiaoying/:/tmp/:/proc/) in Unknown on line 0
    

      

    查看问题描述以及资料,发现是open_basedir的问题,php不能引入其授权目录上级及其以上的文件。

    关于open_basedir有三个方法可以修改:

    1、默认配置在php.ini(/www/server/php/72/etc/php.ini)。

    不过我的php.ini中是默认的配置:

    ;open_basedir =

    可以在等号后添加网站的根目录路径,

    2、在fastcgi.conf(/www/server/nginx/conf/fastcgi.conf)

    fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

    或者把$document_root改为网站根目录路径

    但是如果服务器有多个项目,这样改就不合适了,这时候可以用第三种方法

    3、在.user.ini(根目录)
    open_basedir=/www/wwwroot/yjx.ycqmd.top:/tmp/:/proc/

    如果这几个文件都没有问题,可能是网站的访问入口地址不在根目录(我也是这种问题)

    在laravel项目中,会把访问入口地址改为/public,所以.user.ini文件也要放到/public目录下。

  • 相关阅读:
    深入c#的String类
    C#语法快速热身
    【BZOJ】1676: [Usaco2005 Feb]Feed Accounting 饲料计算
    【BZOJ】2056: gift? 高精度?
    【BZOJ】3036: 绿豆蛙的归宿
    【BZOJ】2321: [BeiJing2011集训]星器
    【VIJOS】P1401复制CS
    【BZOJ】2453: 维护队列&&【BZOJ】2120: 数颜色 二分+分块 双倍经验
    【BZOJ】3343: 教主的魔法
    【BZOJ】1452: [JSOI2009]Count 树状数组
  • 原文地址:https://www.cnblogs.com/guanzelin/p/12384696.html
Copyright © 2011-2022 走看看