2017-10-16 186 views
0

我已經用Nginx和Laravel設置了一個新的LEMP服務器。所有正確的設置和2個新的默認laravel項目運行良好。現在我準備好了,並希望從其他服務器添加2個現有的laravel項目。但是我現在總是在重定向到登錄頁面後,在瀏覽器中得到Nginx的404錯誤(如果我從公用文件夾輸入地址和端口,會自動)。腳本在其他服務器上效果很好,並且它的唯一可能是來自「Laravelproject/storage」或其他的「Permission」文件夾錯誤,我認爲。我已經嘗試了很多事情,從緩存清理並重新啓動nginx,php和檢查所有文件夾的權限,現在全部777,是的,我知道它不安全,但我總是在我的nginx error.log文件中出現「Permission denied」錯誤。Laravel現有Project to NGINX Server「Permission denied」404瀏覽器錯誤

這裏的錯誤,我總是得到日誌文件中:

[error] 29564#0: *16 directory index of "/var/www/html/project/" is forbidden, client: ::1, server: localhost, request: "GET /project/ HTTP/1.1", host: "localhost" 

PHP message: PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/project/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 

    [error] 28854#0: *1 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/project/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107 

最誤差爲laravel.log,但它現在777具有的權限。

我的nginx的配置:

server { 
    listen 7171 ; 
    listen [::]:7171; 

    # SSL configuration 
    # 
    # listen 443 ssl default_server; 
    # listen [::]:443 ssl default_server; 
    # 
    # Self signed certs generated by the ssl-cert package 
    # Don't use them in a production server! 
    # 
    # include snippets/snakeoil.conf; 

    root /var/www/html/project/public; 

    # Add index.php to the list if you are using PHP 
    index index.php index.html index.htm index.nginx-debian.html; 

    server_name localhost; 

    location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     try_files $uri $uri/ =404; 
    } 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
    } 



    # deny access to .htaccess files, if Apache's document root 
    # concurs with nginx's one 
    # 
    location ~ /\.ht { 
     deny all; 
    } 
} 

我還不能與

php artisan serve 

運行項目中,我得到這個錯誤:

[ErrorException]         
    passthru() has been disabled for security reasons 

但我不認爲這就是一個問題,它的只是現在阻止它的nginx。

任何想法?我現在已經在這個項目上工作了幾個月,現在它非常令人沮喪....我現在24小時都在谷歌上搜索並嘗試了所有我沒有找到結果的東西。我使用Laravel 5.4。之前的服務器是apache而不是nginx。

回答

0

解決方案!編輯這一行:

#try_files $uri $uri/ =404; 

,並添加

try_files $uri $uri/ /index.php; 

例如:

location/{ 
     # First attempt to serve request as file, then 
     # as directory, then fall back to displaying a 404. 
     # try_files $uri $uri/ =404; 
      try_files $uri $uri/ /index.php; 
    } 

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 
    # 
    location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
    } 
相關問題