4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Docker で Laravel開発環境

Posted at

Nginxのconfを作成する

server {
    listen  80;
    root /usr/share/nginx/laravel/public;
    index index.php index.html index.htm;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ ^/.+\.php(/|$) {
        fastcgi_pass laravel-container:9000;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

DockerでPHP-FPMを作成する

FROM php:7.3-fpm-alpine
RUN apk add libzip-dev
RUN docker-php-ext-configure zip --with-libzip
RUN docker-php-ext-install pdo_mysql zip

docker-composeを作成する


version: "3.7"

services:

  laravel:
    build: .
    container_name: laravel-container
    working_dir: /usr/share/nginx/laravel
    networks:
      - laravel-docker
    volumes:
        - ./laravel:/usr/share/nginx/laravel

  nginx:
    image: nginx:1.16-alpine
    container_name: reverse-proxy
    working_dir: /usr/share/nginx/laravel
    networks:
      - laravel-docker
    ports:
        - "8080:80"
    volumes:
        - ./default.conf:/etc/nginx/conf.d/default.conf
        - ./laravel:/usr/share/nginx/laravel

  mysql:
    image: mysql:8.0
    container_name: mysql-server
    networks:
      - laravel-docker
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=homestead
      - MYSQL_USER=homestead
      - MYSQL_PASSWORD=secret
    ports:
      - 3306:3306

  redis:
    image: redis:5.0-alpine
    container_name: redis-server
    networks:
      - laravel-docker
    ports:
      - 6379:6379

networks:
  laravel-docker:
    driver: bridge

詳細は下記(ハンズオン)

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?