安装需求
需求环境
需求镜像
安装步骤
配置Nginx-conf
web.conf
server {
listen 80;
listen [::]:80;
server_name example.site; #域名
return 301 https://$http_host$request_uri;
}
server {
listen 443 ssl;
ssl_certificate /etc/ssl/domain-certificate.pem; #域名ssl-certificate
ssl_certificate_key /etc/ssl/domain-key.key; #域名ssl_certificate_key
server_name example.site; #域名
index index.php;
root /var/www/html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$args;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass wordpress:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
参考链接
创建Docker Compose file
wordpress.yml
version: "3.9"
services:
nginx:
image: nginx
volumes:
- ~/nginx-setting/web.conf:/etc/nginx/conf.d/default.conf #nginx-conf挂载路径
- wordpress:/var/www/html
- ~/ssl:/etc/ssl:ro #证书挂载路径
ports:
- "80:80"
- "443:443"
links:
- "wordpress:wordpress"
wordpress:
image: wordpress:php8.0-fpm-alpine
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: exampleuser
WORDPRESS_DB_PASSWORD: examplepass
WORDPRESS_DB_NAME: exampledb
volumes:
- wordpress:/var/www/html
links:
- "db:db"
db:
image: mysql:5.7
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_RANDOM_ROOT_PASSWORD: '1'
volumes:
- db:/var/lib/mysql
volumes:
wordpress:
db:
参考链接
WordPress
容器启动
docker-compose -f ./wordpress.yml up -d