1. Install the ngix dependency Module
Ngix depends on the following modules: PCRE, zlib, OpenSSL, MD5/sha1 (if the corresponding modules are not installed in the system, install them as follows)
1. Install the PCRE module (8.35)
Http://www.pcre.org/
Installation command:
# Unzip pcre-8.35.zip
# Cd pcre-8.35
#./Configure
# Make & make install
In a 64-bit Linux system, the library location searched by nginx is lib64. Therefore, you need to establish a soft connection:
# Ln-S/usr/local/lib/libpcre. so.1/lib64/
# Ln-S/usr/local/lib/libpcre. so.1/lib/
# Ln-S/usr/local/lib/libpcre. so.1/usr/local/lib64/
2. Install the zlib module (1.2.8)
Http://www.zlib.net/
Installation command:
# Tar zxvf zlib-1.2.8.tar.gz
# Cd zlib-1.2.8
#./Configure
# Make & make install
3. Install the OpenSSL module (1.0.1h)
Http://www.openssl.org/
Installation command:
# Tar zxvf openssl-1.0.1h.tar.gz
# Cd openssl-1.0.1h
#./Config
# Make & make install
4. decompress the nginx plug-in
1) nginx_upstream_hash plug-in
Load Balancing hash policy plug-in.
Https://github.com/evanmiller/nginx_upstream_hash
# Unzip nginx_upstream_hash-master.zip
2) nginx-sticky-module plug-in
Server Load balancer is a cooki-based session bonding plug-in. Reverse Proxy Sessions direct to the same backend server. Note: The source code downloaded from the official website is incorrectly compiled in line 295 of ngx_http_sticky_module.c. You need to put ngx_http_sticky_srv_conf_t * conf = iphp-> sticky_conf in line 295th.
Https://github.com/yaoweibin/nginx-sticky-module
# Unzip nginx-sticky-module-master.zip
3) ngx_pagespeed plug-in
Front-end webpage access speed-up optimization plug-in.
Https://github.com/pagespeed/ngx_pagespeed
Https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
# Unzip ngx_pagespeed-master.zip
# Cp 1.8.31.4.tar.gz./ngx_pagespeed-master
# Cd ngx_pagespeed-master
# Tar-xzvf 1.8.31.4.tar.gz
Ii. Install nginx
1. Install nginx (1.6.0)
Http://nginx.org/
Installation command:
# Tar zxvf nginx-1.6.0.tar.gz
# Cd nginx-1.6.0
#./Configure -- user = TSP \
-- Prefix =/usr/local/nginx \
With-http_ssl_module \
With-http_stub_status_module \
With-http_realip_module \
-- Add-module =/home/TSP/nginx/plugin/nginx_upstream_hash-master \
-- Add-module =/home/TSP/nginx/plugin/nginx-sticky-module-master \
-- Add-module =/home/TSP/nginx/plugin/ngx_pagespeed-master
# Make & make install
The nginx directory structure after installation is complete:
[[Email protected] nginx-1.6.0] # ll/usr/local/nginx/
Total 16
Drwxr-XR-x 2 root Root 4096 Jun 24 Conf
Drwxr-XR-x 2 root Root 4096 Jun 24 14:42 html
Drwxr-XR-x 2 root Root 4096 Jun 24 logs
Drwxr-XR-x 2 root Root 4096 Jun 24 sbin
2. Modify the listening port in the configuration file to prevent other programs from occupying the port.
Modify the configuration file:/usr/local/nginx/CONF/nginx. conf
Modify port: 80> 9090
2.1 set the Linux Firewall and open port 9090
Run the following command:
#/Sbin/iptables-I input-P TCP -- dport 9090-J accept
Save setting command:
#/Etc/rc. d/init. d/iptables save
Command to view port opening:
#/Etc/init. d/iptables status
Restart the Firewall Service
#/Etc/rc. d/init. d/iptables restart
3. Start and Stop nginx
A. Start the command
#/Usr/local/nginx/sbin/nginx
B. Stop command
#/Usr/local/nginx/sbin/nginx-s stop
C. Check the configuration file
#/Usr/local/nginx/sbin/nginx-t-c/usr/local/nginx/CONF/nginx. conf
D. Check the nginx version and the complete version.
#/Usr/local/nginx/sbin/nginx-V
Nginx version: nginx/1.6.0
#/Usr/local/nginx/sbin/nginx-V
Nginx version: nginx/1.6.0
Built by GCC 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)
Configure arguments: -- prefix =/usr/local/nginx -- With-OpenSSL =/usr/local/OpenSSL -- with-http_stub_status_module
Compile and configure the nginx Load Balancing optimization plug-in