
# Docker로 php 기본 개발환경을 만들어 보았습니다.
## 세부 파일내용
./docker-compose.yml
version: '3.1'
services:
app:
image: php:8.3-fpm
container_name: php-app
volumes:
- ./app:/var/www/html
depends_on:
- db
networks:
- app-network
db:
image: mariadb:11.4
container_name: mariadb-db
restart: always
environment:
MARIADB_ROOT_PASSWORD: 1111
MARIADB_DATABASE: aitools
MARIADB_USER: aitools
MARIADB_PASSWORD: aiGon2025!#
volumes:
- ./db/data:/var/lib/mysql
ports:
- "3308:3306" # 외부에서 접근 가능하도록 포트 개방
networks:
- app-network
nginx:
image: nginx:latest
container_name: nginx-server
ports:
- "9080:80"
volumes:
- ./app:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- app
networks:
- app-network
volumes:
db-data:
networks:
app-network:
driver: bridge
./db/conf.d/my.cnf
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
./db/initdb.d/table.sql
-- create table 쿼리 및 기본 데이터 insert 쿼리
./app/index.php
<?php
echo "php 시작페이지 입니다.";
?>
./nginx/default.conf
server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass app:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
## 폴더 구조( cmd 명령어 : tree /f)
│ docker-compose.yml
│
├─app
│ index.php
│
├─db
│ ├─conf.d
│ │ my.cnf
│ │
│ ├─data
│ └─initdb.d
│ table.sql
│
└─nginx
default.conf
'프로그래밍 정보' 카테고리의 다른 글
| TypeScript란? JavaScript보다 안전하고 강력한 프로그래밍 언어! (1) | 2025.03.07 |
|---|---|
| MySQL TIMESTAMP vs DATETIME: 차이점 완벽 정리 (0) | 2025.03.06 |
| yt-dlp를 사용하여 YouTube 영상을 MP4로 다운로드하는 방법과 문제 해결 방법 (0) | 2025.03.05 |
| [해결 방법] aria-hidden 사용 시 "Blocked aria-hidden" 오류 해결하기 (1) | 2025.02.25 |
| Cursor AI 사용 후기: AI 코딩 도구, 정말 실무에 도움이 될까? (1) | 2025.02.22 |