使用nginx设置laravel应用程序

时间:2014-05-06 12:00:52

标签: php nginx laravel

我正在尝试在我的nginx设置上安装一个全新的Laravel。

我看到一个空白页面,我的错误日志说明如下:

PHP message: PHP Fatal error:  require(): Failed opening required '/srv/laravel/public/../bootstrap/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /srv/laravel/public/index.php on line 21" while reading response header from upstream, client: **.***.***.**, server: laravel.{domain}.nl, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fcgi-laravel-php-fcgi-0.sock:", host: "laravel.{domain}.nl"

我已检查文件是否存在。如果我使用

,它实际上会返回1
php -r "echo file_exists(__DIR__.'../bootstrap/autoload.php');"

我还检查了我的PHP版本是否是最新的。版本号为5.4.4

我还在应用程序根文件夹中运行了composer update,但无济于事。

我认为这与我的nginx设置无关,因为它会加载index.php。 我对nginx没有太多经验,所以我可能错了。

更新:我将在这里发布nginx配置

server {
    listen *:80;


    server_name laravel.{domain}.nl;

    access_log /var/log/nginx/laravel.access.log;
    error_log /var/log/nginx/laravel.error.log;

    root /srv/laravel/public;
    index index.html index.htm index.php;

    # serve static files directly
        location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
                                access_log off;
                                expires max;
                }

        location / {
                index  index.html index.htm index.php; #try static .html file first
                ##try_files $uri $uri/ /index.php;  <<Wrong!! this will break bundles like OneAuth for example
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

    # catch all
        error_page      404 /index.php;



    location ~ [^/]\.php(/|$) {



        fastcgi_index index.php;
        include fcgi.conf;
        fastcgi_pass unix:/var/run/php-fcgi-laravel-php-fcgi-0.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    }

}

此刻我很茫然......任何人都可以帮助我吗?

如果需要,我会提供更多信息。对不起英文不好,谢谢。

3 个答案:

答案 0 :(得分:1)

1 - 你是如何安装Laravel的?

2 - 您是否曾尝试再次转储自动加载文件?如果不是:

composer dump-autoload

来源:Laravel docs

答案 1 :(得分:0)

我发现open_basedir没有设置,所以我无法访问该文件夹。将open_basedir设置为%app%/ public让它对我有用。

答案 2 :(得分:0)

您可以为该特定域禁用open_basedir,请按照以下步骤操作:

  1. 在ispconfig3选项卡中,单击“站点”选项卡 2.单击基于laravel的站点域 3.现在单击选项选项卡 3.put&#34; none&#34;在PHP open_basedir字段中

  2. 4.然后在nginx指令中,将此用于网址:

     location / {
              try_files $uri $uri/ /index.php?q=$uri&$args;
            }