簡體   English   中英

使用Nginx設置laravel應用程序

[英]Setting up laravel application with nginx

我正在嘗試在我的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"

我檢查了文件是否存在。 從cli它實際上返回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;

    }

}

此刻我很茫然……有人可以幫助我嗎?

如果需要,我將提供更多信息。 對不起,英語不好,謝謝。

1-您是如何安裝Laravel的?

2-您是否嘗試過再次轉儲自動加載文件? 如果不:

composer dump-autoload

資料來源: Laravel文件

我發現未設置open_basedir,因此無法訪問該文件夾。 將open_basedir設置為%app%/ public可以為我工作。

您可以按照以下步驟,為該特定域禁用open_basedir:

  1. 在ispconfig3選項卡中,單擊站點選項卡2.單擊基於laravel的站點的域3.現在單擊選項選項卡3.在PHP open_basedir字段中輸入“ none”

    沒有

4.然后在nginx指令中,將其用於url即可:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM