Implementation of Nginx load balancing under CentOS 7 virtual machine Simulation

Source: Internet
Author: User
Tags nginx load balancing

With CentOS 7 As an example, we simulate the implementation of Nginx to handle static resources, Apache to process PHP

1. First we will install Nginx

# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2. Create a Yum repository

# RPM-IVH nginx-release-centos-7-0.el7.ngx.noarch.rpm

3. Installing Nginx

Yum Install Nginx

4. Start Nginx and set to boot

Nginx start Nginx If the machine above has been installed Apache this will be an error. We need to modify the port

Systemctl Enable Nginx Boot

5. Modify the Nginx configuration file and set up a new port

Cd/etc/nginx--Enter Nginx directory

         VI nginx.conf            --Modify configuration

 # Include/etc/nginx/conf.d/*  .conf;                              Comment out this line, in order to avoid loading configuration server {Listen 88 in the CONF.D directory; Reset Port # server_name test.com;                 
Location/{root/usr/share/nginx/html; Default directory index index.html index.htm; } location ~ \.php$ {PHP route steering rule proxy_pass http://192.168.0.101 :80; # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { PHP Processing files and directories (native Apache) root/var/www/html; Fastcgi_pass 192.168.0.101:80; Fastcgi_index index.php; Fastcgi_param Script_filename/scripts$fastcgi_script_name; Include Fastcgi_params; }

This leaves the HTML resource on the localhost:88,php resource and turns to 192.168.0.101

Implementation of Nginx load balancing under CentOS 7 virtual machine Simulation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.