Nginx
1. Preparatory work
Download Install:nginx.org download 1.10 Package
put it in the home directory . Unzip
TAR-ZXF nginx-1.10.1.tar.gz
source installation takes three steps:
Operation in the directory after Nginx decompression (make sure the port is not occupied)
1../configure
./configure--prefix=/usr/local/lnmp/nginx(default installation location) --with-http_ssl_module (auto Compile)- -with-http_stub_status_module(test module)
Hint Error: Missing installation package
Yum install pcre-devel-y yum install-y openssl-devel
2. make (compile)
3. make Install (build)
cd/usr/local/lnmp/nginx/sbin/./nginx (open nginx)
Curl-i 172.25.15.11 ( can be viewed )
or use Firefox to view can see the
2. Remove the uninstalled Nginx
Execute under /usr/local/lnmp/nginx/sbin/ ./nginx-s Stop ( stop nginx)
Rm-fr/usr/local/lnmp/nginx
Make clean in the extracted directory
or simply point: delete the home directory Extracted Files re-unzip.
3. Hide nginx version number turn off Test mode (will cause large software)
after re-decompression Enter the extracted directory
Vim src/core/nginx.h ( hidden version number )
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/87/43/wKioL1fZLeShNZYtAAA8DDL5bfc319.png-wh_500x0-wm_3 -wmp_4-s_3185836682.png "title=" image 1.png "alt=" Wkiol1fzleshnzytaaa8ddl5bfc319.png-wh_50 "/>
Vim AUTO/CC/GCC ( turn off test mode )
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M02/87/45/wKiom1fZLh-Bzt4QAAAnyHotMeY052.png-wh_500x0-wm_3 -wmp_4-s_257637982.png "title=" image 2.png "alt=" Wkiom1fzlh-bzt4qaaanyhotmey052.png-wh_50 "/>
comment out The 179 line and proceed ./configure && make && made install
link nginx to the system can directly execute the nginx command
Ln-s/usr/local/lnmp/nginx/sbin/nginx/usr/local/sbin/
Which Nginx ( can be viewed to nginx)
under the system input nginx (Open)
Nginx-s Stop ( off )
Nginx-s Reload ( heavy Duty )
Nginx-t checking configuration file syntax issues
4. Dynamic modules and static modules
reconfigure an nginx
./configure--prefix=/tmp/nginx--with-ngx_mail_module=dynamic ( add dynamic Module )
One more modules under the/tmp/nginx/ (the module in the directory is a dynamic module)
dynamic modules can be called in the first row in the configuration file /tmp/nginx/conf/nginx.conf
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/87/43/wKioL1fZLnXRnek3AABHQe7wkWE888.png-wh_500x0-wm_3 -wmp_4-s_561720154.png "title=" image 3.png "alt=" Wkiol1fzlnxrnek3aabhqe7wkwe888.png-wh_50 "/>
(Apache has long supported nginx just out)
5. Add user to Nginx process
PS aux can see the Nobody of the nginx process worker
Create an nginx User:useradd-s/sbin/nologin nginx
Modify the/usr/local/lnmp/nginx/conf/nginx.conf in the master configuration file
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M00/87/43/wKioL1fZLw_wqnTEAABxQLnM4rg606.png-wh_500x0-wm_3 -wmp_4-s_3534066550.png "title=" image 4.png "alt=" Wkiol1fzlw_wqnteaabxqlnm4rg606.png-wh_50 "/>
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/45/wKiom1fZLzngsPTYAAAqpLp_xsc488.png-wh_500x0-wm_3 -wmp_4-s_1788637289.png "title=" image 5.png "alt=" Wkiom1fzlzngsptyaaaqplp_xsc488.png-wh_50 "/>
Io Negative method: Useepoll
Number of concurrent Links:worker_connections 4096 X 2 ( number of CPUs )
User is 2 bound task to Two cores of CPU for Nginx thread Count
6.set the maximum number of processes for the user, number of files
Vim/etc/security/limits.conf
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M00/87/43/wKioL1fZL7Kw8XJtAABa3Jz8Ppo918.png-wh_500x0-wm_3 -wmp_4-s_1317141422.png "title=" image 6.png "alt=" Wkiol1fzl7kw8xjtaaba3jz8ppo918.png-wh_50 "/>
maximum number of processes is 100
Shell Bomb::() {:|:&}; : ( Unlimited Call function until system resources are exhausted and then stuck, so limit the maximum number of processes for normal users )
7,nginx open 443 Port
Web testing:
Modify configuration file: /usr/local/lnmp/nginx/conf/nginx.conf
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/87/43/wKioL1fZMCbwIUR3AAA7Jo2d9zg446.png-wh_500x0-wm_3 -wmp_4-s_896634119.png "title=" image 7.png "alt=" Wkiol1fzmcbwiur3aaa7jo2d9zg446.png-wh_50 "/>
NGINX-T ( detect syntax Errors )
Nginx-s Reload ( heavy-duty Nginx)
test on Web : server1.example.com/status Refresh
650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/87/43/wKioL1fZMJuQiP-TAABFmvCS1Yw809.png-wh_500x0-wm_3 -wmp_4-s_3012558672.png "title=" image 8.png "alt=" Wkiol1fzmjuqip-taabfmvcs1yw809.png-wh_50 "/>
Modify configuration file: /usr/local/lnmp/nginx/conf/nginx.conf server{} is a virtual host
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/87/45/wKiom1fZMNjQBi46AACgt_HUy4U447.png-wh_500x0-wm_3 -wmp_4-s_3359430874.png "title=" image 9.png "alt=" Wkiom1fzmnjqbi46aacgt_huy4u447.png-wh_50 "/>
enter directive make Cert.pem ( the CA Certificate you want to generate ) under/etc/pki/tls/certs/
Enter information about the certificate. Move the certificate to /usr/local/lnmp/nginx/conf/
Nginx-t Nginx-s Reload
Access to the https://server1.example.com can be viewed.
Web page rewrite:
1. How to modify the publishing page
View the source page of Baidu then write the code to the publishing home /usr/local/lnmp/nginx/html/index.html
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/87/43/wKioL1fZMTLhWR14AABdaiW9boE999.png-wh_500x0-wm_3 -wmp_4-s_3349768186.png "title=" image 10.png "alt=" Wkiol1fzmtlhwr14aabdaiw9boe999.png-wh_50 "/>
2. How to redirect Web pages
Add to the virtual host under Port
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/87/46/wKiom1fZUb2CvL9WAACYNze9LM0890.png-wh_500x0-wm_3 -wmp_4-s_716573486.png "title=" image 12.png "alt=" Wkiom1fzub2cvl9waacynze9lm0890.png-wh_50 "/>
Nginx-s Reload access server1.example.com can jump.
This article is from the "11682640" blog, please be sure to keep this source http://11692640.blog.51cto.com/11682640/1852855
Nginx load balancing and reverse proxy