{"id":2773,"date":"2025-09-22T08:22:17","date_gmt":"2025-09-21T23:22:17","guid":{"rendered":"https:\/\/skanto.co.kr\/?p=2773"},"modified":"2025-09-23T08:04:42","modified_gmt":"2025-09-22T23:04:42","slug":"deploying-wordpress-using-docker","status":"publish","type":"post","link":"https:\/\/skanto.co.kr\/?p=2773","title":{"rendered":"Deploying WordPress using Docker"},"content":{"rendered":"\n<p>Deploying WordPress with Nginx using Docker involves setting up multiple containers that work together.&nbsp;This typically includes a WordPress container (often using PHP-FPM), a database container (like MySQL or MariaDB), and an Nginx container to act as a reverse proxy.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Here&#8217;s a general outline of the process:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Project Setup<\/strong>:&nbsp;Create a project directory to hold your Docker Compose file and Nginx configuration.<\/li>\n\n\n\n<li><strong>Docker Compose File<\/strong>:&nbsp;Create a&nbsp;<code>docker-compose.yml<\/code>&nbsp;file to define the services (containers) for WordPress, the database, and Nginx.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>version: '3.8'\nservices:\n  wordpress:\n    image: wordpress:fpm-alpine # Or another suitable WordPress FPM image\n    restart: always\n    user: 1000:1003 # the id of user and group of skanto\n    depends_on:\n      - db\n    environment:\n      WORDPRESS_DB_HOST: db\n      WORDPRESS_DB_USER: wordpressuser\n      WORDPRESS_DB_PASSWORD: wordpresspassword\n      WORDPRESS_DB_NAME: wordpressdb\n    volumes:\n      - .\/wordpress_data:\/var\/www\/html\n\n  db:\n    image: mysql:8.0 # Or mariadb\n    restart: always\n    user: 1000:1003 # the id of user and group of skanto\n    environment:\n      MYSQL_RANDOM_ROOT_PASSWORD: '1'\n      MYSQL_DATABASE: wordpressdb\n      MYSQL_USER: wordpressuser\n      MYSQL_PASSWORD: wordpresspassword\n    volumes:\n      - .\/db_data:\/var\/lib\/mysql\n\n  nginx:\n    image: nginx:stable-alpine\n    depends_on:\n      - wordpress\n    ports:\n      - \"80:80\"\n      - \"443:443\" # For SSL, if needed\n    volumes:\n      - .\/nginx\/conf.d:\/etc\/nginx\/conf.d\n      - .\/wordpress_data:\/var\/www\/html:ro # Read-only access to WordPress files\nnetworks:\n  default:\n    driver: bridge<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>WordPress Configuration<\/strong>: Navigate to <code>.\/wordpress_data<\/code> and open <code>wp-config-docker.php<\/code> file for editing. Adjust database connection information like below<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ ** Database settings - You can get this info from your web host ** \/\/\n\/** The name of the database for WordPress *\/\ndefine( 'DB_NAME', getenv_docker('WORDPRESS_DB_NAME', 'wordpressdb') );\n\n\/** Database username *\/\ndefine( 'DB_USER', getenv_docker('WORDPRESS_DB_USER', 'wordpressuser') );\n\n\/** Database password *\/\ndefine( 'DB_PASSWORD', getenv_docker('WORDPRESS_DB_PASSWORD', 'wordpresspassword') );<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Nginx Configuration<\/strong>:&nbsp;Create an Nginx configuration file (e.g.,&nbsp;<code>default.conf<\/code>) inside a directory like&nbsp;<code>.\/nginx\/conf.d<\/code>.&nbsp;This file will configure Nginx to act as a reverse proxy, forwarding requests to the WordPress container (specifically, the PHP-FPM process within it).<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 80;\n    server_name your_domain.com; # Replace with your domain or IP\n\n    root \/var\/www\/html;\n    index index.php index.html index.htm;\n\n    location \/ {\n        try_files $uri $uri\/ \/index.php?$args;\n    }\n\n    location ~ \\.php$ {\n        include fastcgi_params;\n        fastcgi_pass wordpress:9000; # 'wordpress' is the service name in docker-compose\n        fastcgi_index index.php;\n        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n    }\n}<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Deployment<\/strong>:&nbsp;Navigate to your project directory and run&nbsp;<code>docker-compose up -d<\/code>&nbsp;to build and start the containers.<\/li>\n\n\n\n<li><strong>Access WordPress<\/strong>:&nbsp;Once the containers are running, you can access your WordPress site by navigating to the configured&nbsp;<code>server_name<\/code>&nbsp;or the host&#8217;s IP address in your web browser.<\/li>\n<\/ul>\n\n\n\n<p>This setup provides a robust and scalable environment for running WordPress, leveraging Nginx for efficient request handling and Docker for containerization and isolation.&nbsp;You can further enhance this with SSL certificates (e.g., using Certbot in a separate container) and persistent storage for data.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Deploying WordPress with Nginx using Docker involves setting up multiple containers that work together.&nbsp;This typically includes a WordPress container (often using PHP-FPM), a database container (like MySQL or MariaDB), and an Nginx container to act as a reverse proxy. Here&#8217;s a general outline of the process: This setup provides a robust and scalable environment for running WordPress, leveraging Nginx for efficient request handling and Docker for containerization and isolation.&nbsp;You can further enhance this with SSL certificates (e.g., using Certbot in&#8230;<\/p>\n<p class=\"read-more\"><a class=\"btn btn-default\" href=\"https:\/\/skanto.co.kr\/?p=2773\"> Read More<span class=\"screen-reader-text\">  Read More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[14],"tags":[170,79,273,272],"class_list":["post-2773","post","type-post","status-publish","format-standard","hentry","category-sw-development","tag-docker","tag-mysql","tag-nginx","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2773"}],"version-history":[{"count":3,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2773\/revisions"}],"predecessor-version":[{"id":2777,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/2773\/revisions\/2777"}],"wp:attachment":[{"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2773"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/skanto.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}