先决条件
- 安装前先确保系统是干净的, 没有安装过任何环境, 如: Apache/Nginx/PHP/MySQL/MariaDB, 否则会存在端口冲突。
- 请自行安装 docker、docker-compose:
- docker 安装方法: https://docs.docker.com/engine/install/
- docker-compose 安装方法: https://docs.docker.com/compose/install/
支持的操作系统
- 支持主流 Linux 发行版本(基于 Debian / RedHat macOS 包括 OpenKylin 等国产操作系统)
操作系统 | 架构 | 软件要求 |
---|---|---|
linux/amd64 | x86_64 | docker、docker compose |
linux/arm64 | aarch64 | docker、docker compose |
LDNMP 支持的技术栈
服务 | 版本 |
---|---|
Nginx | 1.27.x |
MySQL | 9.0.x、9.1.x |
PHP | 8.3.x、8.4.x |
Adminer | latest |
Redis | 7.x |
目录结构
相对目录 | 描述 |
---|---|
./apps/mysql/conf | MySQL配置文件所在路径 |
./apps/mysql/data | MySQL数据存放目录 |
./apps/mysql/logs | MySQL日志存放路径 |
./apps/nginx | Nginx配置文件目录 |
./apps/nginx/ssl | Nginx证书存放目录 |
./apps/nginx/logs | Nginx日志存放目录 |
./web | 网站存放目录 |
./apps/php | PHP配置文件目录 |
./apps/php/logs | PHP-FPM日志目录 |
./apps/php/etc | php.ini php-fpm.conf 配置目录 |
./apps/redis/conf | Redis 配置文件所在目录 |
./apps/redis/data | 数据存储目录 |
docker-compose.yaml
修改。已安装并支持的PHP扩展
Extension | PHP 8.4 | PHP 8.3 |
---|---|---|
amqp | ✓ | ✓ |
apcu | ✓ | ✓ |
apcu_bc | ||
ast | ✓ | ✓ |
bcmath | ✓ | ✓ |
bitset | ✓ | ✓ |
blackfire | ✓ | |
brotli | ✓ | ✓ |
bz2 | ✓ | ✓ |
calendar | ✓ | ✓ |
cassandra* | ||
cmark | ||
csv | ✓ | ✓ |
dba | ✓ | ✓ |
ddtrace* | ✓ | ✓ |
decimal | ✓ | ✓ |
ds | ✓ | ✓ |
ecma_intl* | ✓ | |
enchant | ✓ | ✓ |
ev | ✓ | ✓ |
event | ✓ | ✓ |
excimer | ✓ | ✓ |
exif | ✓ | ✓ |
ffi | ✓ | ✓ |
ftp | ✓ | ✓ |
gd | ✓ | ✓ |
gearman | ✓ | |
geoip | ||
geos* | ✓ | ✓ |
geospatial | ✓ | ✓ |
gettext | ✓ | ✓ |
gmagick | ✓ | ✓ |
gmp | ✓ | ✓ |
gnupg | ✓ | ✓ |
grpc | ✓ | ✓ |
http | ✓ | ✓ |
igbinary | ✓ | ✓ |
imagick | ||
imap | ✓ | ✓ |
inotify | ✓ | ✓ |
interbase | ||
intl | ✓ | ✓ |
ion | ✓ | ✓ |
ioncube_loader | ✓ | |
jsmin | ||
json_post | ✓ | ✓ |
jsonpath | ✓ | ✓ |
ldap | ✓ | ✓ |
luasandbox | ✓ | ✓ |
lz4* | ✓ | ✓ |
lzf | ✓ | ✓ |
mailparse | ✓ | ✓ |
maxminddb | ✓ | ✓ |
mcrypt | ✓ | |
md4c | ✓ | ✓ |
memcache | ✓ | ✓ |
memcached | ✓ | ✓ |
memprof* | ✓ | ✓ |
mongo | ||
mongodb | ✓ | ✓ |
mosquitto | ||
msgpack | ✓ | ✓ |
mssql | ||
mysql | ||
mysqli | ✓ | ✓ |
newrelic | ✓ | |
oauth | ✓ | ✓ |
oci8 | ✓ | ✓ |
odbc | ✓ | ✓ |
opcache | ✓ | ✓ |
opencensus | ||
openswoole | ||
opentelemetry | ||
parallel* | ✓ | ✓ |
parle* | ✓ | ✓ |
pcntl | ✓ | ✓ |
pcov | ✓ | ✓ |
pdo_dblib | ✓ | ✓ |
pdo_firebird | ✓ | ✓ |
pdo_mysql | ✓ | ✓ |
pdo_oci | ✓ | ✓ |
pdo_odbc | ✓ | ✓ |
pdo_pgsql | ✓ | ✓ |
pdo_sqlsrv | ✓ | ✓ |
pgsql | ✓ | ✓ |
phalcon | ✓ | |
php_trie | ✓ | ✓ |
phpy* | ✓ | ✓ |
pkcs11 | ✓ | ✓ |
pq | ✓ | ✓ |
propro | ||
protobuf | ✓ | ✓ |
pspell | ✓ | ✓ |
psr | ✓ | ✓ |
pthreads* | ||
raphf | ✓ | ✓ |
rdkafka | ✓ | ✓ |
recode | ||
redis | ✓ | ✓ |
relay | ✓ | ✓ |
saxon* | ✓ | ✓ |
seasclick | ✓ | ✓ |
seaslog | ✓ | |
shmop | ✓ | ✓ |
simdjson* | ✓ | ✓ |
smbclient | ✓ | ✓ |
snappy | ✓ | ✓ |
snmp | ✓ | ✓ |
snuffleupagus | ✓ | ✓ |
soap | ✓ | ✓ |
sockets | ✓ | ✓ |
sodium* | ||
solr | ✓ | |
sourceguardian | ✓ | |
spx | ✓ | ✓ |
sqlsrv* | ✓ | ✓ |
ssh2 | ✓ | ✓ |
stomp | ✓ | ✓ |
swoole | ✓ | ✓ |
sybase_ct | ||
sync | ✓ | ✓ |
sysvmsg | ✓ | ✓ |
sysvsem | ✓ | ✓ |
sysvshm | ✓ | ✓ |
tensor | ||
tideways | ✓ | ✓ |
tidy | ✓ | ✓ |
timezonedb | ✓ | ✓ |
uopz | ✓ | |
uploadprogress | ✓ | ✓ |
uuid | ✓ | ✓ |
uv | ✓ | ✓ |
vips* | ✓ | ✓ |
vld | ✓ | |
wddx | ||
wikidiff2* | ✓ | ✓ |
xdebug | ✓ | ✓ |
xdiff | ✓ | ✓ |
xhprof | ✓ | ✓ |
xlswriter | ✓ | ✓ |
xmldiff | ✓ | ✓ |
xmlrpc | ✓ | ✓ |
xpass* | ✓ | ✓ |
xsl | ✓ | ✓ |
yac | ✓ | ✓ |
yaml | ✓ | ✓ |
yar | ✓ | ✓ |
zephir_parser | ✓ | ✓ |
zip | ✓ | ✓ |
zmq | ✓ | ✓ |
zookeeper | ||
zstd | ✓ | ✓ |
此扩展来自 https://github.com/mlocati/docker-php-extension-installer 参考示例文件
PS: the pre-installed PHP extensions are excluded from this list. You can list them with the following command (change php:8.4.2-fpm-alpine
to reflect the PHP version you are interested in):
$ docker run --rm php:8.4.2-fpm-alpine php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
random
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
快速开始
启动过程: 拉取代码 – 拉取镜像 – 启动服务, 其中 PHP 镜像是基于官方 PHP 镜像默认安装了所有 PHP 扩展, 因此无需再安装 PHP 扩展, 开箱即用。
- 下载在线部署包
wget
https://renwole.com/ldnmp/ldnmp-1.4.1.tar.gz - 解压
tar zxf ldnmp-1.4.1.tar.gz
- 设置目录权限
chmod -R 777 ldnmp*
- 进入项目目录, 执行以下命令启动服务
docker-compose up -d 或 docker compose up -d
- 安装完成后,在浏览器中访问:http://localhost:8084 或 https://localhost:8085 (自签名HTTPS) 就能看到安装后的效果, PHP代码在文件./web/index.php
- 可访问 http://localhost:8086 访问 Adminer 管理 MySQL 数据库
- 安装完成后,执行如下命令可查看 MySQL 密码,账号默认:root
cat docker-compose.yaml | grep MYSQL_ROOT_PASSWORD
自定义安装
- 默认会自动安装
docker-compose.yaml
中所有的服务, 即: Nginx, MySQL, PHP, Adminer - 只安装 Nginx
docker-compose up -d nginx
- 只安装 PHP
docker-compose up -d php
- 只安装 MySQL
docker-compose up -d mysql
PHP 扩展
- 可根据需要编辑
docker-compose.yaml
找到PHP_EXTENSIONS
默认是所有的 PHP 扩展, 根据需要删除或增加https://github.com/mlocati/docker-php-extension-installer
中支持的 PHP 扩展, 多个扩展以空格分隔(构建支持多平台操作,可参考:https://docs.docker.com/build/building/multi-platform/) - 编辑完成后, 执行如下命令开始构建
docker-compose build
或
docker compose build
- 执行如下命令启动构建后的服务
docker-compose up -d
或
docker compose up -d
管理
重启 Nginx
docker restart nginx
重启 MySQL
docker restart mysql
重启 PHP
docker restart php
重启 Adminer
docker restart adminer
可选参数: docker <stop|start|restart> servicename
默认端口
服务 | 容器暴露端口 | 默认端口 |
---|---|---|
Nginx | 8084(http)/ 8085(https) | 80/443 |
PHP | 9000 | 9000 |
MySQL | 3307 | 3306 |
Adminer | 8086 | 8080 |
Redis | 6379 | 6379 |
docker-compose.yaml
修改对应服务的容器暴露端口卸载
- 找到 docker-compose.yaml 文件所在目录,执行如下命令停止服务
docker-compose down
- 在终端执行如下命令可删除所有数据
rm -rf apps docker-compose.yaml web
- 在终端执行如下命令删除 Docker 镜像
docker rmi $(docker images | grep 'php|nginx|mysql' | awk '{print $3}')
卸载删除意味着所有数据将不复存在且不可逆, 请先备份。卸载删除意味着所有数据将不复存在且不可逆, 请先备份。
nginx怎么配置伪静态啊,苹果cms10进不去后台
用的哪个版本。
安装完成在,源码可以不删除吗,比如,php需要增加模块,需要源码
可以,下个版本优化此选项。
mysql 源报错,换个源,安装失败,提示:centos7 mysql The server quit without updating PID file
请使用这个脚本 https://renwole.com/archives/2288
为什么php编译参数中要: –disable-fileinfo 现在很多框架是必须的。
以前的虚拟机内存小,所以关闭后不至于在编译的时候内存不足导致Kill掉,不过现在随着机器规格的提高和性价比,该参数可以根据自己的需求关闭或开启。