2017-10-16 174 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; 
    } 
相关问题