|
@@ -1,8 +1,8 @@
|
|
|

|
|
|
-## 基于官方 debian 配置 Docker 容器 nginx-php-fpm7.3 镜像
|
|
|
+## 基于 debian:unstable-slim 配置 Docker 容器 nginx-php-fpm7.4 镜像
|
|
|
|
|
|
```
|
|
|
-# 下载 nginx-php-fpm7.3 项目源码
|
|
|
+# 下载 nginx-php7.4-fpm 项目源码
|
|
|
git clone https://github.com/hongwenjun/nginx-php.git
|
|
|
|
|
|
cd nginx-php
|
|
@@ -10,7 +10,7 @@ cd nginx-php
|
|
|
# Docker 编译 Dockerfile
|
|
|
docker build -t nginx-php .
|
|
|
|
|
|
-# 测试启动 nginx-php-fpm7.3 容器
|
|
|
+# 测试启动 nginx-php7.4-fpm 容器
|
|
|
docker run -d -p 8888:80 --name nginx-php nginx-php
|
|
|
|
|
|
# 进入容器
|
|
@@ -33,17 +33,12 @@ docker push hongwenjun/nginx-php
|
|
|
|
|
|
```
|
|
|
|
|
|
-### 启动 nginx-php-fpm7.3 容器
|
|
|
-- 需要先建立映射目录,如果错误,需建立目录重启容器
|
|
|
-```
|
|
|
-# 建立映射目录
|
|
|
-mkdir -p /var/www/html
|
|
|
-mkdir -p /var/log/nginx
|
|
|
+### 启动 nginx-php-fpm7.4 容器
|
|
|
|
|
|
+```
|
|
|
docker run -d -p 80:80 -p 443:443 \
|
|
|
--cpus 0.8 --restart=always \
|
|
|
-v /var/www/html:/var/www/html \
|
|
|
- -v /var/log:/var/log \
|
|
|
--name nginx-php \
|
|
|
hongwenjun/nginx-php
|
|
|
```
|
|
@@ -51,24 +46,34 @@ docker run -d -p 80:80 -p 443:443 \
|
|
|
|
|
|
## Dockerfile 文件 使用 supervisor 启动 php-fpm 和 nginx 服务
|
|
|
```
|
|
|
-FROM debian
|
|
|
+FROM debian:unstable-slim
|
|
|
RUN apt update -y && \
|
|
|
- apt install -y --no-install-recommends nginx php-fpm supervisor && \
|
|
|
+ apt install -y --no-install-recommends --no-install-suggests nginx supervisor wget \
|
|
|
+ php7.4 php7.4-fpm php7.4-sqlite3 php7.4-xml php7.4-zip php7.4-pgsql php7.4-mbstring \
|
|
|
+ php7.4-bcmath php7.4-json php7.4-mysql php7.4-gd php7.4-cli php7.4-curl php7.4-cgi && \
|
|
|
mkdir -p /var/run/php /run/php && \
|
|
|
- rm -rf /var/lib/apt/lists/* && \
|
|
|
- rm -rf /var/cache/apt && \
|
|
|
+ wget https://raw.githubusercontent.com/hongwenjun/nginx-php/main/start.sh && \
|
|
|
+ wget https://raw.githubusercontent.com/hongwenjun/nginx-php/main/default && \
|
|
|
+ wget https://raw.githubusercontent.com/hongwenjun/nginx-php/main/supervisord.conf && \
|
|
|
+ mv ./default /etc/nginx/sites-enabled/default && \
|
|
|
+ mv ./supervisord.conf /etc/supervisord.conf && \
|
|
|
+ chmod +x /start.sh && \
|
|
|
+ ln -sf /dev/stdout /var/log/nginx/access.log && \
|
|
|
+ ln -sf /dev/stderr /var/log/nginx/error.log && \
|
|
|
echo "<?php phpinfo(); ?>" > /var/www/html/index.php && \
|
|
|
- printf '#!/bin/bash\n\n# Start supervisord and services\nexec /usr/bin/supervisord -n -c /etc/supervisord.conf\n' \
|
|
|
- > /start.sh && chmod +x /start.sh
|
|
|
-
|
|
|
-COPY ./default /etc/nginx/sites-enabled/default
|
|
|
-COPY ./supervisord.conf /etc/supervisord.conf
|
|
|
+ apt remove -y wget && \
|
|
|
+ rm -rf /var/lib/apt/lists/* /var/cache/apt
|
|
|
|
|
|
-VOLUME [/var/www/html /etc/nginx/sites-enabled /var/log]
|
|
|
+VOLUME [/var/www/html /etc/nginx/sites-enabled ]
|
|
|
EXPOSE 80/tcp 443/tcp
|
|
|
|
|
|
+# COPY ./default /etc/nginx/sites-enabled/default
|
|
|
+# COPY ./supervisord.conf /etc/supervisord.conf
|
|
|
+# COPY ./start.sh /start.sh
|
|
|
+
|
|
|
CMD ["/start.sh"]
|
|
|
|
|
|
+
|
|
|
```
|
|
|
|
|
|
-----
|
|
@@ -95,7 +100,7 @@ server {
|
|
|
location ~ .*\.php(\/.*)*$ {
|
|
|
include snippets/fastcgi-php.conf;
|
|
|
# # With php-fpm (or other unix sockets):
|
|
|
- fastcgi_pass unix:/run/php/php7.3-fpm.sock;
|
|
|
+ fastcgi_pass unix:/run/php/php7.4-fpm.sock;
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -138,3 +143,4 @@ docker run -d \
|
|
|
--restart unless-stopped \
|
|
|
ghcr.io/linuxserver/nginx
|
|
|
```
|
|
|
+
|