zoukankan      html  css  js  c++  java
  • Nginx-虚拟主机配置问题

    Nginx-虚拟主机配置问题

    标签(空格分隔): linux,php,nginx,larave


    这两天突然想配置lnmp环境,学习下Nginx配置结果就遇到了下边的问题

    Nginx: server下的配置

        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        #root  /home/wwwroot/default;
        root  /home/wwwroot/web.laravel.cn/public;
    
    1 如果我把root 写到跟目录 /home/wwwroot/web.laravel.cn/ 那么我访问就得 ip地址/public 
    2 如果我把root 写到入口文件 /home/wwwroot/web.laravel.cn/public 那么 ip访问 就HTTP500
    3 还有相同的地方是 只能打开首页 其他的路由/页面都403
    
    这几天一直再纠结这个问题,第一种的话,不报错,让我挺无奈的 网上查了一下需要打开 php.ini [display_errors=On] 打开这一项 会显示错误
        
        Warning: require(): open_basedir restriction in effect. File(/home/wwwroot/web.laravel.cn/bootstrap/autoload.php) is not within the allowed path(s): (/home/wwwroot/web.laravel.cn/public/:/tmp/:/proc/:/home/wwwroot/web.laravel.cn/public:) in /home/wwwroot/web.laravel.cn/public/index.php on line 22
    
    Warning: require(/home/wwwroot/web.laravel.cn/bootstrap/autoload.php): failed to open stream: Operation not permitted in /home/wwwroot/web.laravel.cn/public/index.php on line 22
    
    Fatal error: require(): Failed opening required '/home/wwwroot/web.laravel.cn/public/../bootstrap/autoload.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/web.laravel.cn/public/index.php on line 22
    

    上网查了这个问题 open_basedir 这个配置选型问题 但我记得都配置过把需要有权限的目录加进去就行了
    但是还不行。就在今天闲着没事在看tp5手册 发现了问题

     "open_basedir=$document_root/:/tmp/:/proc/:/home/wwwroot/web.laravel.cn/public:";
     
    多写了/public 写到根目录就可以了!   /home/wwwroot/web.laravel.cn
    

  • 相关阅读:
    js的单元测试
    如何嵌入HTML 页面
    使用JQuery时间比较
    @page指令ValidateRequest的作用
    时间的正则表达式(比较简单)
    [置顶] Android代码 监控手机电池的状态
    [置顶] Android代码传感器光传感
    [置顶] Android问题ViewPager实现左右两个屏幕的切换
    [置顶] Android代码传感器测试手机支持那几种传感
    [置顶] Android代码检测手机耳机插拔
  • 原文地址:https://www.cnblogs.com/yanweifeng/p/10246053.html
Copyright © 2011-2022 走看看