I am trying to dockerise my Laravel project with Nginx and php-fpm. After running docker-compose up on terminal, all three containers work fine but I get stuck on where to display my own index.php. Instead ,it displays the error of File not found at the web page.
Provided here is the configuration files for docker-compose.yml and some dockerfiles.
#docker-compose.yml
version: '2'
services:
web:
container_name: web
build:
context: ./
dockerfile: web.dockerfile
volumes:
- ./:/var/www
ports:
- "8080:80"
links:
- app
app:
container_name: app
build:
context: ./
dockerfile: app.dockerfile
volumes:
- ./:/var/www
environment:
- "DB_PORT=3306"
- "DB_HOST=database"
db:
container_name: database
image: mysql:5.7
volumes:
- dbdata:/var/lib/mysql
environment:
- "MYSQL_DATABASE=homestead"
- "MYSQL_USER=root"
- "MYSQL_PASSWORD= "
- "MYSQL_ROOT_PASSWORD= "
ports:
- "33061:3306"
volumes:
dbdata:
#app.dockerfile
FROM php:7.0.4-fpm
RUN apt-get update && apt-get install -y libmcrypt-dev mysql-client\
#libmagickwand-dev --no-install-recommends \
#&& pecl install imagick \
#&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql
WORKDIR /var/www
#web.dockerfile
FROM nginx:1.10
ADD vhost.conf /etc/nginx/conf.d/default.conf
WORKDIR /var/www
#vhost.config
server {
listen 80;
index index.php;
root /var/www/public;
location / {
#sendfile off;
try_files $uri /index.php?$args;
}
location ~ \.php$ {
#try_files $uri /index.php =404;
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;
}
}
The expected output is to display index.php after linking my laravel project with docker. I am using docker toolbox on windows os. Anyone can help to solve this? Thanks in advance.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2PuodgM
via IFTTT
Aucun commentaire:
Enregistrer un commentaire