🎂
php8.0 + Laravel 8、docker環境の作成
概要:
php8.0 + laravel 8の、docker構成の例となります。
- 来年リリースされそうなLaravel 9が、php7は非対応になるらしいので
php8 環境を準備した関係になります
構成
- php8.0
- laravel 8
- nginx
- mysql
- docker, dokcer-compose
参考のコード
- docker-compose.yml
docker-compose.yml
version: '3'
services:
web:
build: ./docker-nginx
ports:
- 80:80
depends_on:
- app
volumes:
- ./:/var/www/html
- ./docker-nginx/default.conf:/etc/nginx/conf.d/default.conf
links:
- app
app:
build: ./docker-php
depends_on:
- db
links:
- db
volumes:
- ./:/var/www/html
db:
image: mysql:5.7
ports:
- 3306:3306
volumes:
- ./mysql_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel
MYSQL_USER: db_user
MYSQL_PASSWORD: password
- Dockerfile
docker-php/Dockerfile
FROM php:8.0-fpm
RUN apt-get update && apt-get install -y \
vim \
zip \
unzip \
iputils-ping \
git
RUN docker-php-ext-install pdo_mysql
- 起動
sudo docker-compose up
- php version:
root@3a046f95a5e9:/var/www/html# which php
/usr/local/bin/php
root@3a046f95a5e9:/var/www/html# php -v
PHP 8.0.14 (cli) (built: Dec 21 2021 20:50:32) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.14, Copyright (c) Zend Technologies
- laravel 8,add
php composer.phar create-project --prefer-dist laravel/laravel myblog "8.*"
....
Discussion