Browse Source

废弃PHP 7.4

main
xiaoz 3 weeks ago
parent
commit
47f07f0aed
  1. 12
      README.md
  2. 4
      dnmp.sh
  3. 29
      docker-compose.yaml
  4. 2
      nginx/conf/nginx.conf
  5. 10
      nginx/conf/vhost/site.conf.example

12
README.md

@ -17,10 +17,10 @@ bash dnmp.sh install phpmyadmin
| 版本 | 容器名 | FastCGI 端口 | 目录 | | 版本 | 容器名 | FastCGI 端口 | 目录 |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| PHP 7.4(默认启动) | php-7.4 | 127.0.0.1:9074 | php74 | | PHP 8.3(默认启动) | php-8.3 | 127.0.0.1:9083 | php83 |
| PHP 8.3(按需启动) | php-8.3 | 127.0.0.1:9083 | php83 | | PHP 7.4(按需启动) | php-7.4 | 127.0.0.1:9074 | php74 |
`bash dnmp.sh run` 只会启动 PHP 7.4;需要 PHP 8.3 时执行 `bash dnmp.sh start php83`(`bash dnmp.sh start all` 也会一并启动)。站点使用哪个版本由 nginx vhost 里的 `fastcgi_pass` 端口决定,参考 `nginx/conf/vhost/site.conf.example`。 `bash dnmp.sh run` 启动的是 PHP 8.3;需要 PHP 7.4 时执行 `bash dnmp.sh start php74`。站点使用哪个版本由 nginx vhost 里的 `fastcgi_pass` 端口决定,参考 `nginx/conf/vhost/site.conf.example`。
PHP 8.3 镜像需要自行构建并推送(Docker Hub 上的 `helloz/php` 只提供 7.4): PHP 8.3 镜像需要自行构建并推送(Docker Hub 上的 `helloz/php` 只提供 7.4):
@ -36,9 +36,9 @@ docker push helloz/php:8.3-fpm-alpine
# reload nginx config # reload nginx config
docker exec -it nginx xc.sh reload docker exec -it nginx xc.sh reload
# start / stop PHP 8.3 on demand # start / stop PHP 7.4 on demand
bash dnmp.sh start php83 bash dnmp.sh start php74
bash dnmp.sh stop php83 bash dnmp.sh stop php74
# check php version # check php version
docker exec php-8.3 php -v docker exec php-8.3 php -v

4
dnmp.sh

@ -18,8 +18,8 @@ then
export GROUP_ID=${GROUP_ID} export GROUP_ID=${GROUP_ID}
fi fi
# 服务列表 # 服务列表(默认启动 PHP 8.3,7.4 可通过 start php74 按需启动)
services=(nginx mysql php74 php83) services=(nginx mysql php83)
# 安装运行环境 # 安装运行环境
install_rumtime(){ install_rumtime(){

29
docker-compose.yaml

@ -12,18 +12,35 @@ services:
- ./nginx/ssl:/usr/local/nginx/conf/ssl - ./nginx/ssl:/usr/local/nginx/conf/ssl
restart: always restart: always
php-fpm: # PHP 7.4(按需启动:bash dnmp.sh start php74)
image: helloz/php:7.4-fpm-alpine # php-fpm:
# image: helloz/php:7.4-fpm-alpine
# network_mode: host
# container_name: php-7.4
# environment:
# - USER_ID=${USER_ID}
# - GROUP_ID=${GROUP_ID}
# user: "${USER_ID}:${GROUP_ID}"
# volumes:
# - ./php74/www.conf:/usr/local/etc/php-fpm.d/www.conf
# - ./php74/php.ini:/usr/local/etc/php/conf.d/php.ini
# - ./php74/log:/usr/local/log
# - ./wwwroot:/var/www/html
# restart: on-failure
# PHP 8.3(默认启动)
php83-fpm:
image: helloz/php:8.3-fpm-alpine
network_mode: host network_mode: host
container_name: php-7.4 container_name: php-8.3
environment: environment:
- USER_ID=${USER_ID} - USER_ID=${USER_ID}
- GROUP_ID=${GROUP_ID} - GROUP_ID=${GROUP_ID}
user: "${USER_ID}:${GROUP_ID}" user: "${USER_ID}:${GROUP_ID}"
volumes: volumes:
- ./php74/www.conf:/usr/local/etc/php-fpm.d/www.conf - ./php83/www.conf:/usr/local/etc/php-fpm.d/www.conf
- ./php74/php.ini:/usr/local/etc/php/conf.d/php.ini - ./php83/php.ini:/usr/local/etc/php/conf.d/php.ini
- ./php74/log:/usr/local/log - ./php83/log:/usr/local/log
- ./wwwroot:/var/www/html - ./wwwroot:/var/www/html
restart: on-failure restart: on-failure

2
nginx/conf/nginx.conf

@ -104,7 +104,7 @@ http {
# PHP 配置 # PHP 配置
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
include fastcgi_params; include fastcgi_params;
fastcgi_pass 127.0.0.1:9074; fastcgi_pass 127.0.0.1:9083;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
} }

10
nginx/conf/vhost/site.conf.example

@ -1,7 +1,7 @@
# PHP 版本通过 fastcgi_pass 的端口选择: # PHP 版本通过 fastcgi_pass 的端口选择:
# 127.0.0.1:9074 => PHP 7.4(默认) # 127.0.0.1:9083 => PHP 8.3(默认)
# 127.0.0.1:9083 => PHP 8.3 # 127.0.0.1:9074 => PHP 7.4(按需启动:bash dnmp.sh start php74)
# 把下面 location ~ \.php$ 中的端口改成 9083 即可让本站点使用 PHP 8.3 # 把下面 location ~ \.php$ 中的端口改成 9074 即可让本站点使用 PHP 7.4
server { server {
listen 80; listen 80;
@ -14,7 +14,7 @@ server {
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params; include fastcgi_params;
fastcgi_pass 127.0.0.1:9074; fastcgi_pass 127.0.0.1:9083;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404; try_files $uri =404;
@ -62,7 +62,7 @@ server {
location ~ \.php$ { location ~ \.php$ {
include fastcgi_params; include fastcgi_params;
fastcgi_pass 127.0.0.1:9074; fastcgi_pass 127.0.0.1:9083;
fastcgi_index index.php; fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
try_files $uri =404; try_files $uri =404;

Loading…
Cancel
Save