以DockerCompose的形式搭建基于nginx与wordpress镜像的博客系统

因为习惯使用nginx,又需要配置https证书,使用原生的wordpress镜像需要转端口会出现各种问题,所以最后以DockerCompose的形式结合nginx与wordpress镜像完美解决了相关问题。

  • 新建docker-compose.yml

version: "2"services:  nginx:    image: nginx:alpine   restart: always   volumes:        - ./cert:/etc/nginx/cert        - ./conf/nginx.conf:/etc/nginx/nginx.conf        - /home/wordpress:/var/www/html    ports:      - "443:443"    links:        - wordpress wordpress:    image: wordpress:4.9.4-php7.0-fpm   ports:      - 9000:9000    volumes:      - /home/wordpress:/var/www/html    restart: always   environment:        - WORDPRESS_DB_NAME=wordpress        - WORDPRESS_TABLE_PREFIX=wp_        - WORDPRESS_DB_HOST=修改为数据库的IP地址        - WORDPRESS_DB_PASSWORD=密码        - WORDPRESS_DB_USER=用户
  • 修改nginx.conf
    下面值粘贴重要部分

server {         listen 443;         server_name www.test.com;  #修改为自己的域名                  ssl on;         root /var/www/html;         index index.php index.html;         ssl_certificate   cert/test.pem;   #修改为自己的证书地址         ssl_certificate_key  cert/test.key;  #修改为自己的密钥地址         ssl_session_timeout 5m;         ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;         ssl_prefer_server_ciphers on;         location / {             try_files $uri $uri/ /index.php?$args;         }           location ~ \.php$ {             try_files $uri =404;             fastcgi_split_path_info ^(.+\.php)(/.+)$;             fastcgi_pass wordpress:9000;   #wordpress地址             fastcgi_index index.php;            include fastcgi_params;             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;             fastcgi_param PATH_INFO $fastcgi_path_info;         }     }

作者:褪色的记忆1994
链接:https://www.jianshu.com/p/72f36becd117

原文链接:https://www.imooc.com/article/49049

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享