简体   繁体   English

使用LaraDock在Nginx上运行Laravel时找不到文件

[英]File Not Found when running Laravel with Nginx using LaraDock

I am learning Laravel using its tutorial. 我正在使用其教程学习Laravel。 I installed Laravel and the required stacks using LaraDock . 我使用LaraDock安装了Laravel和所需的堆栈。

Nginx returns File not found when I go to the IP where the app is running. 当我转到运行应用程序的IP时,Nginx返回找不到文件。 Below is my NGINX configuration. 以下是我的NGINX配置。

server {
        root /var/www/laravel/public/;
        listen 80 default_server;

        listen [::]:80 default_server ipv6only=on;
        index index.php index.html index.htm;
        location / {
             try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ \.php$ {
            try_files $uri /index.php =404;
            fastcgi_pass php-upstream;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location ~ /\.ht {
            deny all;
        }
}

This is the error from NGINX error log. 这是NGINX错误日志中的错误。

2016/08/19 08:53:06 [error] 47#47: *16 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.99.1, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://111.13.0.5:9000", host: "192.168.99.100" 2016/08/19 08:53:06 [错误] 47#47:* 16从上游读取响应标头时,stderr中发送了FastCGI:“主脚本未知”,客户端:192.168.99.1,服务器:,请求:“ GET / HTTP / 1.1”,上游:“ fastcgi://111.13.0.5:9000”,主机:“ 192.168.99.100”

To be sure you have index.php in /var/www/laravel/public/ 确保您在/var/www/laravel/public/有index.php

run command docker-compose exec nginx ls /var/www/laravel/public/ 运行命令docker-compose exec nginx ls /var/www/laravel/public/

If you don't have index.php in the folder, probably your project folder mounted wrong. 如果文件夹中没有index.php,则可能是您的项目文件夹安装错误。

Did you edit .env, or docker-compose.yml file? 您是否编辑了.env或docker-compose.yml文件?

Where you put laradock folder relative to your project folder 相对于项目文件夹放置laradock文件夹的位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM