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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章