Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

500 (Internal Server Error) with Laravel & Docker

I create Laravel PHP application in Docker. First I setup Laravel app using

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-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

localhost:8080

I got

500(Internal Server Error)

Please, can you help to solve this? Thanks.

like image 631
Janaka Pushpakumara Avatar asked Jul 20 '17 05:07

Janaka Pushpakumara


People also ask

Why do I keep getting 500 internal server error?

The HTTP status code 500 is a generic error response. It means that the server encountered an unexpected condition that prevented it from fulfilling the request. This error is usually returned by the server when no other error code is suitable.

What causes 500 errors PHP?

If your PHP script makes external network connections, the connections may time out. If too many connections are attempted and time out, this will cause a "500 Internal Server Error." To prevent these time outs and errors, you'll want to make sure that PHP scripts be coded with some timeout rules.


1 Answers

I found a solution. I set the permission on my Laravel app using:

sudo chmod -R 777 storage && sudo chmod -R 777 bootstrap/cache
like image 146
Janaka Pushpakumara Avatar answered Sep 19 '22 18:09

Janaka Pushpakumara