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
    

  • 相关阅读:
    算法-对分查找(二分查找)C++实现
    Android Studio简单设置
    一起talk C栗子吧(第八回:C语言实例--素数)
    Maven生命周期
    java8_api_日期时间
    UITableviewcell的性能问题
    iOS开发25个性能调优技巧
    iOS9新特性
    iOS9 3DTouch、ShortcutItem、Peek And Pop技术一览
    iOS网络访问之使用AFNetworking
  • 原文地址:https://www.cnblogs.com/yanweifeng/p/10246053.html
Copyright © 2011-2022 走看看