1 NginxBasic Knowledge1.1 NginxIntroduction
Nginx ("Engine x") is a high-performance HTTP and reverse proxy server, also a IMAP/POP3/SMTP proxy server. Currently the official Nginx does not support Windows, can onlybe installed and used in Linux, UNIX, BSD system. Nginx itself is only an HTTP and reverse proxy server, it can not be like Apache by installing various modules to support different page scripts, such as PHP, CGI and so on.
1.2 Nginxfunction
Nginx support simple load balancing and fault tolerance, support functions as basic HTTP server, such as log, compress, Byte ranges, Chunked responses, SSL, virtual host and so on.
2 NginxDeployment Method2.1Preparing the Media
Nginx before deployment, first select the components that need to be installed based on your project's needs, and the actual environment will generally consider the need to support gzip compression and rewrite modules. So the first step of installation is to download Nginx and Nginx related components.
1) Nginx itself
: http://nginx.org/en/download.html
2) gzip compression dependent library: zlib
: http://www.zlib.net
3) Rewrite module's regular expression Dependency library: pcre (abbreviation: perl-compatible regular expression)
: http://www.pcre.org
2.2Installation Steps
Actual condition: RedHat 6.5 64bit
System comes with components:
zlib is: 1.2.3 version
[Email protected] ~]# Rpm-qa zlib
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/03/wKioL1TE9KnDHkD4AABCX73Q62s610.jpg "style=" float: none; "title=" 22.png "alt=" Wkiol1te9kndhkd4aabcx73q62s610.jpg "/>
Pcre is: 7.8 version
[Email protected] ~]# Rpm-qa pcre
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/05/wKiom1TE883yNEy9AAA7YnJUHns243.jpg "title=" 21.png "Style=" Float:none; "alt=" wkiom1te883yney9aaa7ynjuhns243.jpg "/>
Upload nginx-0.8.55.tar.gz to Folder/usr/local/src and unzip the installation:
[Email protected] ~]# CD/USR/LOCAL/SRC
[[email protected] src]# ls
[Email protected] src]# tar zxvf nginx-0.8.55.tar.gz
[Email protected] src]# CD nginx-0.8.55
[Email protected] nginx-0.8.55]#/configure--prefix=/usr/local/nginx
Error: (guess is because pcre-7.8 version is too high, nginx-0.8.55 version is too low)650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/59/05/ Wkiom1te883jlld_aaeqhg-b5cq501.jpg "title=" 23.png "style=" Float:none; "alt=" wkiom1te883jlld_aaeqhg-b5cq501.jpg "/ >
Try to install a higher version of nginx-1.6.2:
[Email protected] nginx-0.8.55]# CD.
[[email protected] src]# ls
[Email protected] src]# tar zxvf nginx-1.6.2.tar.gz
[Email protected] src]# CD nginx-1.6.2
[Email protected] nginx-1.6.2]#./configure--prefix=/usr/local/nginx
The problem will still occur:
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/03/wKioL1TE9KnjFT57AAEwSfQM1Mc251.jpg "title=" 24.png "Style=" Float:none; "alt=" wkiol1te9knjft57aaewsfqm1mc251.jpg "/>
Online Search information, Solution:
Install Pcre-devel (rpmfind.net download or get from CD against OS version)
pcre-devel-7.8-6.el6.x86_64.rpm , and upload to/USR/LOCAL/SRC)
[[email protected] src]# ls
[Email protected] src]# RPM-IVH pcre-devel-7.8-6.el6.x86_64.rpm
[Email protected] src]# CD nginx-0.8.55
[Email protected] nginx-0.8.55]#./configure--prefix=/usr/local/nginx
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/05/wKiom1TE882CtUi4AAMU3XUlUjs157.jpg "title=" 25.png "Style=" Float:none; "alt=" wkiom1te882ctui4aamu3xulujs157.jpg "/>
[[email protected] src]# make
[[email protected] nginx-0.8.55]# make install
2.3ManagementNginx
Check nginx configuration file:
[[Email protected]]#/usr/local/nginx/sbin/nginx–t
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/03/wKioL1TE9KmiPL9BAAC2FcLJYFA977.jpg "title=" 26.png "Style=" Float:none; "alt=" wkiol1te9kmipl9baac2fcljyfa977.jpg "/>
Nginx Start and Status View:
[[Email protected]]#/usr/local/nginx/sbin/nginx
[Email protected]]# netstat-tunlp |grep Nginx
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/05/wKiom1TE883wMBWMAAB3FcnV2Xg374.jpg "title=" 27.png "Style=" Float:none; "alt=" wkiom1te883wmbwmaab3fcnv2xg374.jpg "/>
To view Nginx main process number:
[[Email protected]]# ps-ef | grep "Nginx:master Process" | Grep-v "grep" | Awk-f ' {print $} '
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/03/wKioL1TE9KnQmksWAABwnqeNWXI068.jpg "title=" 28.png "Style=" Float:none; "alt=" wkiol1te9knqmkswaabwnqenwxi068.jpg "/>
To stop Nginx:
[email protected] nginx-0.8.55]# kill-term 26614 (main process number) or
[Email protected] nginx-0.8.55]#/usr/local/nginx/sbin/nginx-sstop
Restart Nginx:
[Email protected] nginx-0.8.55]#/usr/local/nginx/sbin/nginx-s Reload
Configure boot automatically start Nginx:
[Email protected] nginx-0.8.55]# vi/etc/rc.local
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/05/wKiom1TE89CCd0ewAAC_uUeW6D0817.jpg "title=" 30.png "Style=" Float:none; "alt=" wkiom1te89ccd0ewaac_uuew6d0817.jpg "/>
To view Nginx manually installed modules:
[email protected] nginx-0.8.55]#/usr/local/nginx/sbin/nginx–v
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/03/wKioL1TE9WLT2EhaAAC_uUeW6D0747.jpg "style=" float: none; "title=" 30.png "alt=" Wkiol1te9wlt2ehaaac_uuew6d0747.jpg "/>
3 NginxUpgrade Steps
View the currently used version and record the previously compiled parameters:
[Email protected] src]#/usr/local/nginx/sbin/nginx–v
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/59/05/wKiom1TE9IayVempAAC4gp5prpc395.jpg "title=" 31.png "Style=" Float:none; "alt=" wkiom1te9iayvempaac4gp5prpc395.jpg "/>
Unzip, compile, and do not install (make install) according to the previously compiled parameters:
[[email protected] src]# ls
[Email protected] src]# tar zxvf nginx-1.6.2.tar.gz
[Email protected] src]# CD nginx-1.6.2
[Email protected] nginx-1.6.2]#./configure--prefix=/usr/local/nginx
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/03/wKioL1TE9WLS_UIuAAMauOyKF3w232.jpg "title=" 33.png "Style=" Float:none; "alt=" wkiol1te9wls_uiuaamauoykf3w232.jpg "/>
[[email protected] nginx-1.6.2]# make
Replace Nginx file:
[Email protected] nginx-1.6.2]# mv/usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.bak20141231
[Email protected] nginx-1.6.2]# Find/-name Nginx
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/05/wKiom1TE9IbA2oR4AAByxW6wjlw349.jpg "title=" 34.png "Style=" Float:none; "alt=" wkiom1te9iba2or4aabyxw6wjlw349.jpg "/>
[email protected] nginx-1.6.2]# CP Objs/nginx/usr/local/nginx/sbin/nginx
Test whether the new file is in effect:
[Email protected] nginx-1.6.2]#/usr/local/nginx/sbin/nginx–t
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/03/wKioL1TE9WLgmibdAADKEpA4MFg214.jpg "title=" 35.png "Style=" Float:none; "alt=" wkiol1te9wlgmibdaadkepa4mfg214.jpg "/>
View the latest version:
[Email protected] nginx-1.6.2]#/usr/local/nginx/sbin/nginx–v
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/59/05/wKiom1TE9IbBwbteAABZYVYr9lE082.jpg "title=" 37.png "Style=" Float:none; "alt=" wkiom1te9ibbwbteaabzyvyr9le082.jpg "/>
This article is from the "Aerfa21_myhome" blog, make sure to keep this source http://aerfa21.blog.51cto.com/6656626/1608143
RedHat 6.5 and upgrade to the latest version