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