1
1

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 1 year has passed since last update.

PHP laravel 新規作成方法まとめ

Last updated at Posted at 2022-11-13

Dockerでの新規作成方法まとめの自分用メモ

PHP

docker run -p 4000:80 -v ${PWD}:/var/www/html -d php:apache

参考:https://gray-code.com/blog/php-on-docker/
mysqlもつける場合: https://and-engineer.com/articles/Ybx0hREAACEAgRY9

laravel sail

curl -s https://laravel.build/<YOUR_PROJECT_NAME> |bash

とか

curl -s "https://laravel.build/<YOUR_PROJECT_NAME>?PHP=81" |bash

参考: Amazon プロフェッショナルWebプログラミング Laravel〈最新Laravel 9対応〉

laravel docker

参考: https://www.engilaboo.com/laravel-nginx-docker/
参考の手順で、と言うかdocker/Dockerfile以外参考見ればいける

  • docker/Dockerfile
FROM php:8.0-fpm 
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN apt-get update && apt-get install -y \
    git \
    zlib1g-dev \
    libzip-dev \
    unzip \
&& docker-php-ext-install pdo_mysql zip

  • docker-compose.yaml
version: "3.8"
services:
  app:
    build: ./docker
    volumes:
      - ./app:/var/www/app
  nginx:
    image: nginx
    ports:
      - 8083:80
    volumes:
      - ./app:/var/www/app
      - ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf

  db:
    image: mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: db
      MYSQL_USER: user
      MYSQL_PASSWORD: password
    ports:
      - 3306:3306

  • docker/nginx/default.conf
server {
    listen 80;
    root /var/www/app/public;
    index index.php;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        fastcgi_pass app:9000; 
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

作成して
appフォルダ作成して

docker compose up -d
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?