apache 换成 nginx

https://www.howtoforge.com/tutorial/dockerizing-wordpress-with-nginx-and-php-fpm/

之前在DO的VPS上搭建的博客(LAMP),如果不开swap space 有时会因为内存不过杀掉mysql,导致网站无法打开。虽然最近打开了swap space, 情况大幅度好转,但从网上看到说nginx比apache 省内存。所以,动手试试:). 这篇文章根据网上教程写的(链接在最上面), 内容非原创. 因为,网上已经有教程了。所以,我也就只把配置文件贴出来就好了,具体请看教程.

docker-compose.yml

version: '2'

services:

   nginx:
    image: nginx:latest
    ports:
        - '80:80'
    volumes:
        - ./nginx:/etc/nginx/conf.d
        - ./logs/nginx:/var/log/nginx
        - ./wordpress:/var/www/html
    links:
        - wordpress
    restart: always

   db:
     image: mariadb:latest
     ports:
       - '3306:3306'
     volumes:
       - ./db-data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: qinjingfei
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress
     container_name: qinjingfei_db

   wordpress:
     depends_on:
       - db
     image: wordpress:4.7.1-php7.0-fpm
     volumes:
       - ./wordpress:/var/www/html
     restart: always
     ports:
       - "9000:9000"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
     container_name: qinjingfei_wp

效果:比apache省100MB内存