Published January 20, 2018 by

Create a Simple Load Balancer in Apache Web Server

This article described how to create load balancer in Apache for your website or application server.



  • 1 Main load balancer server
  • 2 Web application server


  • Apache Web Server on All 3 Server

Install Apache

Install Apache on all 3 servers using the following command:

# sudo yum update -y
# sudo yum install httpd -y
# sudo systemctl start httpd.service
# sudo systemctl enable httpd.service

After installing apache you can run an application on your both web server.

Server Configuration

Now create a load balancer we edit main load balancer server's apache virtual host file /etc/httpd/conf/httpd.conf

# vim /etc/httpd/conf/httpd.conf

Insert following code into your httpd.conf file. And replace highlighted data:

<VirtualHost *:80>
        ProxyRequests off

        <Proxy balancer://mycluster>
                # WebServer1
                BalancerMember loadfactor=1
                # WebServer2
                BalancerMember loadfactor=2

                # In this example all requests are allowed.
                Require all granted
                # Load Balancer Settings
                ProxySet lbmethod=byrequests

        # balancer-manager
        <Location /balancer-manager>
                SetHandler balancer-manager
                Require host

        # Point of Balance
        ProxyPass /balancer-manager !
        ProxyPass / balancer://mycluster/


Restart Apache Server

# sudo systemctl restart httpd.service

Now test your load balancer using the main server_IP or domain name.