1.准备工作
本教程基于 Ubuntu 22.04.2 LTS (GNU/Linux 5.15.0-71-generic x86_64)进行操作
LNMP(mysql5.7+nginx1.22+php7.4)环境部署指导
2.配置防火墙
3.安装docker和配置网络
安装参考其它教程
3.部署mysql
安装mysql5.7版本
创建数据存储目录
启动mysql
配置数据库字符集,使用下面这条命令把配置文件复制出来docker cp mysql:/etc/my.cnf ~/mysql/conf
在配置文件中添加如下配置
重启之后验证字符集
show variables like 'character%';
配置数据库用户权限,达到不同的用户只能操作操作不同的数据库名
4.部署nginx
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting "/home/nginx/conf/nginx.conf" to rootfs at "/etc/nginx/nginx.conf": mount /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf (via /proc/self/fd/6), flags: 0x5000: not a directory: unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
启动nginx
4.2.部署nginx:1.27.1-alpine3.20-perl(推荐)
使用docker-compose启动nginx