May 17th, 2023
WordPress + MySQL + Nginx

WordPress using docker on Nginx without SSL

https://medium.com/swlh/wordpress-deployment-with-nginx-php-fpm-and-mariadb-using-docker-compose-55f59e5c1a

 

				
					// uploads.ini
file_uploads = On
memory_limit = 512M
upload_max_filesize = 256M
post_max_size = 256M
max_execution_time = 300
max_input_time = 1000
				
			
				
					// docker-compose.yml
version: '3'
services:
  mysql:
    image: mariadb
    volumes:
      - /data/mysql:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: mysql_root_pass
      MYSQL_DATABASE: db_name
      MYSQL_USER: user_name
      MYSQL_PASSWORD: user_pass
    restart: always
  wordpress:
    image: wordpress:php7.3-fpm-alpine
    volumes:
      - ./wordpress:/var/www/html
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
    depends_on:
      - mysql
    environment:
      WORDPRESS_DB_HOST: mysql
      MYSQL_ROOT_PASSWORD: mysql_root_pass
      WORDPRESS_DB_NAME: db_name
      WORDPRESS_DB_USER: user_name
      WORDPRESS_DB_PASSWORD: user_pass
      WORDPRESS_TABLE_PREFIX: wp_
    links:
      - mysql
    restart: always
  nginx:
    image: nginx:alpine
    volumes:
      - ./nginx:/etc/nginx/conf.d
      - ./wordpress:/var/www/html
    ports:
      - 80:80
    links:
      - wordpress
				
			
				
					// nginx.conf
server {
  listen 80;
  listen [::]:80;
  access_log off;

  root /var/www/html;
  index index.php;
  server_name example.com;
  server_tokens off;

  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;
  }
  
  # pass the PHP scripts to FastCGI server listening on wordpress:9000
  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    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;
  }
}

				
			
				
					CONTAINER ID   IMAGE                         COMMAND                  CREATED          STATUS          PORTS                               NAMES
0a9f6944090a   nginx:alpine                  "/docker-entrypoint.…"   49 minutes ago   Up 49 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp   wordpress_nginx-nginx-1
0a8ae0a6bcc6   wordpress:php7.3-fpm-alpine   "docker-entrypoint.s…"   51 minutes ago   Up 49 minutes   9000/tcp                            wordpress_nginx-wordpress-1
d264ceb8fb32   mariadb                       "docker-entrypoint.s…"   51 minutes ago   Up 49 minutes   3306/tcp                            wordpress_nginx-mysql-1

				
			

Leave a Reply

Your email address will not be published. Required fields are marked *