docker部署wordpress
version: '2'services:nginx:image: registry.cn-hangzhou.aliyuncs.com/xylink/nginx:1.13.12_v1container_name: nginxrestart: alwaysports:- 80:80volumes:...
·
docker-compose.yml文件内容:
version: '2'
services:
nginx:
image: nginx:1.13.12
container_name: nginx
restart: always
depends_on:
- wordpress
ports:
- 80:80
networks:
extnetwork:
ipv4_address: 172.19.0.100
volumes:
- '/app/nginx/nginx.conf:/etc/nginx/nginx.conf:ro'
- '/app/nginx/conf.d:/etc/nginx/conf.d'
mysql:
image: mysql:5.7
container_name: mysql
volumes:
- /app/mysql:/var/lib/mysql
restart: always
ports:
- '3306:3306'
networks:
extnetwork:
ipv4_address: 172.19.0.101
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: root
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- mysql
image: wordpress:5.2.1
container_name: wordpress
ports:
- '8080:80'
restart: always
networks:
extnetwork:
ipv4_address: 172.19.0.102
volumes:
- /app/wordpress:/var/www/html
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: wordpress
networks:
extnetwork:
ipam:
config:
- subnet: 172.19.0.0/16
gateway: 172.19.0.1
我们在docker-compose里面配置了mysql的账号,以及wordpress的连接池账号
创建应用目录
mkdir -p /app/nginx
mkdir -p /app/mysql
mkdir -p /app/wordpress
进入nginx目录并新建配置文件
这里创建nginx主配置文件
cd /app/nginx
touch nginx.conf
root@iZuf6hvlnilb22btlcji2yZ:/app/nginx# cat nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
然后创建nginx子配置文件
mkdir conf.d
touch conf.d/default.conf
root@iZuf6hvlnilb22btlcji2yZ:/app/nginx/conf.d# cat default.conf
server {
listen 80;
server_name localhost hechaojie.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://wordpress;
}
}
配置完成后执行:
docker-compose up -d
浏览首页就可以安装wordpress了
http://hechaojie.com/
管理页面地址
http://hechaojie.com/admin
更多推荐
已为社区贡献8条内容
所有评论(0)