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

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