Docker
前提:关闭防火墙,开放端口!! 创建docker网络
docker network create myapps #默认创建的就是bridge
MySQL
安装
docker run -p 3306:3306 --name mysql \
-v /home/docker/mysql/conf:/etc/mysql \
-v /home/docker/mysql/logs:/var/log/mysql \
-v /home/docker/mysql/data:/var/lib/mysql \
--network myapps \
-e MYSQL_ROOT_PASSWORD=mysql密码 \
-d mysql:5.7
注意修改mysql密码
Nginx
安装
# 拷贝配置文件
docker run --name nginx01 -d nginx:latest
docker cp nginx01:/etc/nginx/nginx.conf /home/docker/nginx/conf/nginx.conf #把容器中的nginx.conf文件复制到conf目录下
docker rm -f nginx01 #删除镜像
docker run --rm -d -p 80:80 --name nginx \
-v /home/docker/nginx/www:/usr/share/nginx/html \
-v /home/docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /home/docker/nginx/conf/conf.d:/etc/nginx/conf.d \
-v /home/docker/nginx/logs:/var/log/nginx \
--network myapps \
nginx
配置nginx
在conf.d中添加文件
# client.test.zway.top 前端
server {
listen 80;
server_name client.test.zway.top;
root /usr/share/nginx/html;
charset utf-8;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
# server.test.zway.top 后端
server {
listen 80;
server_name server.test.zway.top;
charset utf-8;
location / {
expires 0;
proxy_pass https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js;
# proxy_set_header Host $host:$proxy_port;
proxy_set_header x-forwarded-for $remote_addr;
}
}
Redis
配置文件
从6.2.1的官方包中取出redis.conf
并修改
bind 127.0.0.1 #要注释掉这部分,这是限制redis只能本地访问
protected-mode no #默认yes,开启保护模式,限制为本地访问
daemonize no#默认no,改为yes意为以守护进程方式启动,可后台运行,除非kill进程,改为yes会使配置文件方式启动redis失败
dir /data #输入本地redis数据库存放文件夹(可选)
————————————————
版权声明:本文为CSDN博主「祗是辉哥哥」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42456466/article/details/87270959
安装
mkdir /home/docker/redis/conf
cd /home/docker/redis/conf
vim redis.conf # 写入配置文件
docker run -it -p 6379:6379 --network myapps \
-v /home/docker/redis/conf/redis.conf:/usr/local/etc/redis/redis.conf \
-v /home/docker/redis/data:/data \
--name redis:6.2.1 \
redis redis-server /usr/local/etc/redis/redis.conf --appendonly yes