Linux Nginx Soft Load Implementation Tutorial

  

Slightly larger sites are inevitably load balanced, but hardware load balancing is expensive. There is cheap nginx under Linux as software load balancing.

I. Experimental environment configuration and topology diagram
Web01:rhel 6.4 x86_64 default desktop installation Web02:rhel 6.4 x86_64 default desktop installation Nginx:rhel 6.4 x86_64 basic installation

Second, configuration server
(1) Configuring Web01 server

  1. Turning off the firewall and selinux

    service iptables stop;setenforce 0
      Creating the main folder of the web application

      mkdir /var/www/Hjq
        Writing the main page

        echo ‘lythjq01.com’ > /var/www/hjq/index.html
          Editing /etc/httpd/conf/httpd.conf
          < Br>Enable NameVirtualHost *:80 (ie delete #) to add the following information at the end of the document <VirtualHost *:80> DocumentRoot /var/www/hjq ServerName lythjq01.com ErrorLog logs/dummy-host.example.com-error_log CustomLog logs/dummy-host.example.com-access_log common


          1. Restart httpd service

            service httpd restart
              Test access

              (2) Configure Web02 server configuration and Web01 is the same, only the main page display is changed to lythjq02.com (c) Configure the nginx server to download the latest nginx
              1. from the official website. Unzip the downloaded nginx

                tar -xvf nginx-1.9.2.tar. Gz
                  Go to the unzipped directory

                  cd nginx-1.9.2
                    Install the necessary compilation tools and other required packages (yum source configuration section is described here)

                    yum Install –y pcre-devel zlib-devel openssl-devel gcc gcc-c++
                      generate makefile

                    1. compile and install

                      make;make install
                        edit configuration File

                        vim /usr/local/nginx/conf/nginx.conf edit as shown below:
                          Create soft link

                          ln –s /usr/local/nginx/sbin/Nginx /usr/local/sbin
                            Turn off the firewall and selinux

                            service iptables stop;setenforce 0
                            1. Start nginx

                            2. Test page

                              Refresh to continue testing

                              Three, think
                              This is the simplest nginx load, but considering the real The situation will need to detect if a server can provide normal service will forward data access, there is the session sharing, the actual production environment needs. This is only used as a joke.

Copyright © Windows knowledge All Rights Reserved