Support Online
Skip to main content

WordPress Deployment Guide in Production (DNS, HAProxy and Decoupled Architecture)

In this guide, we will move WordPress beyond the limits of a single server and move it to an architecture that complies with production standards.
Aim; To ensure high availability with load balancing, database parsing and private DNS.

What Will You Learn in This Guide?

  • Deploying WordPress on multiple servers
  • Manage traffic safely with load balancer
  • Separating database and application layers
  • Establishing an architecture suitable for the production environment

Architecture Overview

The installation consists of the following server roles:

  1. Private DNS Servers (ns1, ns2)
  2. Database Server (db1 – MySQL)
  3. Application Servers (app1, app2 – Apache + PHP)
  4. Load Balancer (lb1 – HAProxy + SSL)

Servers communicate via DNS names over the private network.


1. Private DNS Configuration

Using a name instead of an IP address simplifies maintenance processes.
You can access servers by name by establishing a private network DNS structure with BIND.

Example DNS names:

  • db1.tr1-node01.ornek.com
  • app1.tr1-node01.ornek.com

Thanks to this structure, configuration files are not updated during server changes.


2. Installing the Database Server (db1)

Separating the database is critical for horizontal scaling.

sudo apt-get update
sudo apt-get -y install mysql-server
  • This command installs the MySQL server.

MySQL configuration allows it to listen only from the private network:


bind-address = db1.tr1-node01.ornek.com

  • Database and user creation:

CREATE DATABASE app;
CREATE USER 'appuser'@'app1.tr1-node01.ornek.com' IDENTIFIED BY 'sifre';
GRANT ALL PRIVILEGES ON app.* TO 'appuser'@'app1.tr1-node01.ornek.com';
FLUSH PRIVILEGES;
  • These queries provide the necessary access to WordPress.

3. Installing Application Servers (app1, app2)

  1. Apache and PHP are installed on both servers:

sudo apt-get install apache2 php5 php5-mysql libapache2-mod-php5
  • This command installs the web server and PHP components.

  1. Apache is set to listen only from the private network:

Listen private_IP:80
  • WordPress files are copied to /var/www/html directory.
  • In wp-config.php the database address is defined by the DNS name:


define('DB_HOST', 'db1.tr1-node01.ornek.com');
  • Synchronization solutions such as GlusterFS are recommended for file consistency.

4. HAProxy Load Balancer Setup (lb1)

  1. The load balancer is the entry point for all traffic.
  2. SSL certificate is prepared in .pem format.


sudo apt-get -y install haproxy
  • This command installs HAProxy.

Sample backend configuration:


backend app-backend
redirect scheme https if !{ ssl_fc }
server app1 app1.tr1-node01.ornek.com:80 check
server app2 app2.tr1-node01.ornek.com:80 check
  • This structure balances requests to two application servers.

5. Logging and Service Activation

  1. UDP listening via rsyslog is turned on for HAProxy logs.
  2. Then the service is restarted:

sudo service haproxy restart
  • This command activates the configuration.

  1. Completing the WordPress Installation
  • The following address opens from the browser:

https://www.example.com/wp-admin/install.php
  • When the installation screen is completed, the system is ready for use.

Frequently Asked Questions (FAQ)

1. Why should I use private DNS? In case of IP changes, only the DNS record changes instead of updating the entire configuration.

2. Is it mandatory to separate the database? It is definitely recommended in a production environment, not in small projects.

3. What is HAProxy SSL termination? SSL resolution is done on the load balancer, leaving the application servers relieved.

4. How many application servers can I add? The architecture is suitable for horizontal scaling, it can be added as needed.

Result

With this guide, you have moved WordPress to a production-standard, scalable and secure architecture. You can try this structure immediately on the GenixNode infrastructure for your high-traffic projects.