| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- mysql
- Rocky
- OpenWrt
- Apache
- 시놀로지
- 알뜰폰
- nginx
- jQuery
- iptime
- 티스토리
- 가상서버호스팅
- 알리익스프레스
- 아파치
- php
- 복현오거리
- centos
- KB국민카드
- PHP-FPM
- SKT
- 킹북이초월
- Linux
- 보르비스초월
- 스톤에이지
- proxmox
- 윈도우10
- 소비전력
- KB증권
- 자바스크립트
- 램가스초월
- 리눅스
- Today
- Total
맛집 여행 캠핑 일상 생활
[Linux] Docker nginx with php-fpm 설치 방법 본문
728x90
도커 허브에는 nginx + php-fpm이 같이 있는 이미지를 못찾겠네요~
따로 따로 조합해서 사용하는 방법 말고 하나의 이미지에서 서비스하는 방법입니다.
1. docker-compose.yml
services:
nginx:
#image: nginx:latest
container_name: nginx-php82
build:
context: .
dockerfile: ./Dockerfile-nginx
restart: always
ports:
- "8080:80"
volumes:
- ./www:/var/www/html
- ./nginx/logs:/var/log/nginx
- ./nginx/conf:/etc/nginx/conf.d
2. Dockerfile-nginx
FROM nginx:latest
RUN apt update
RUN apt-get -y install nginx php-fpm php-mysqli
RUN apt clean
RUN sed -i 's/www-data/nginx/g' /etc/php/8.2/fpm/pool.d/www.conf
RUN sed -i '/^;security.limit_extensions/asecurity.limit_extensions = .php .php3 .php4 .php5 .php7 .htm .html' /etc/php/8.2/fpm/pool.d/www.conf
RUN echo "/usr/sbin/php-fpm8.2 -D" > /docker-entrypoint.d/40-php82-fpm.sh
RUN chmod +x /docker-entrypoint.d/40-php82-fpm.sh
3. nginx/conf/example.conf
server {
listen 80;
server_name www.example.com;
access_log "/var/log/nginx/example.access.log";
error_log "/var/log/nginx/example.error.log";
root /var/www/html;
index index.php index.html;
location / {
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
}
location ~ [^/]\.(php|htm|html)(/|$) {
try_files $uri =404;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
위 3개의 파일을 생성한 다음에
docker compose up -d --build
해주시면 됩니다.
다음글에는 php-apache 설치 방법에 대해서 알아보겠습니다.
728x90
반응형
'LINUX' 카테고리의 다른 글
| [Linux] Docker 각 버전별 php-apache 설치 방법 (1) | 2025.05.20 |
|---|---|
| [MariaDB] Errcode: 13 Permission denied (0) | 2025.04.29 |
| [Rocky] docker certbot duckdns 인증서 발급 방법 (0) | 2025.04.29 |
| [Linux] Apache NGINX duckdns.org certbot 인증서 발급 방법 (0) | 2025.04.29 |
| [Linux] PHPExcel 대체용 PHPSpreadSheet 설치 방법 (1) | 2025.04.24 |
Trackback : | Comments :