Laravel 和 Docker 500(内部服务器错误)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45206228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
500 (Internal Server Error) with Laravel & Docker
提问by Janaka Pushpakumara
I create Laravel PHP application in Docker. First I setup Laravel app using
我在 Docker 中创建了 Laravel PHP 应用程序。首先我使用设置 Laravel 应用程序
laravel new laravelDockerApp
it creates successfully.I verify it's setup by built-in server
它创建成功。我验证它是由内置服务器设置的
php artisan serve
Then setup Local environment with Docker
然后使用 Docker 设置本地环境
docker-compose.yml
docker-compose.yml
version: '2'
services:
web:
build:
context: ./
dockerfile: web.docker
volumes:
- ./:/var/www
ports:
- "8080:80"
links:
- app
app:
build:
context: ./
dockerfile: app.docker
volumes:
- ./:/var/www
app.docker
应用程序
FROM php:7-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client \
&& docker-php-ext-install mcrypt pdo_mysql
WORKDIR /var/www
web.docker
网络码头工人
FROM nginx:1.10
ADD ./vhost.conf /etc/nginx/conf.d/default.conf
WORKDIR /var/www
vhost.conf
虚拟主机配置文件
server {
listen 80;
index index.php index.html;
root /var/www/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
I run docker-compose up -d
command. app & web containers up successfully.When I check app in Browser using
我运行docker-compose up -d
命令。应用程序和网络容器成功启动。当我在浏览器中检查应用程序时使用
localhost:8080
本地主机:8080
I got
我有
500(Internal Server Error)
500内部服务器错误)
Please, can you help to solve this? Thanks.
拜托,你能帮忙解决这个问题吗?谢谢。
回答by Janaka Pushpakumara
I found a solution. I set the permission on my Laravel app using:
我找到了解决办法。我使用以下方法在我的 Laravel 应用程序上设置权限:
sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache