Nginx nginx linux installation and configuration of IIS distribution

Installation and configuration of IIS nginx linux distribution

A. Installation

  Operating System: centos 7, nginx version 1.12.2, windows server 2008 iis 

  1.1 validation tool nginx depends

    Zlib: nginx provide gzip module requires zlib library support, Openssl: nginx provide ssl function, Pcre: support for address rewriting rewrite function. If not, use yum to install under the root.

- Detection Kit is installed dependence 
[root @ xuegod64 HSR] # yum List | grep zlib 
[root @ xuegod64 HSR] # yum List | grep OpenSSL 
[root @ xuegod64 HSR] # yum List | grep PCRE

  1.2 install nginx

    After downloading the package nginx-1.12.2.tar.gz, in the system directory linux / home / hsr / lower.

- unzip 
[root @ xuegod64 HSR] # tar -xzvf nginx- 1.12 . 2 . Tar .gz 
[root @ xuegod64 HSR] # cd nginx - 1.12 . 2 
- compiler 
[root @ xuegod64 nginx - 1.12 . 2 ] #. / Configure
 - mounting 
[the root xuegod64 Nginx @ - 1.12 . 2 ] # the make    
[Nginx xuegod64 the root @ - 1.12 . 2 ] # the make  the install

  1.3 nginx user generated operating system

/ * 
Use -u 8000 to generate a user ID, 
-s specified user login shell after used, 
Nginx user refers to the system 
* / 
 [the root xuegod64 @ ~] # the useradd -u 8000 -s / usr / sbin / nologin Nginx
- View nginx user information 
[root @ xuegod64 sbin] # CAT / etc / passwd 
nginx: the X-: 8000 : 8000 :: / Home / nginx: / sbin / nologin

   1.4 Starting nginx

[root@xuegod64 sbin]# pwd
/usr/local/nginx/sbin
[root@xuegod64 sbin]# ./nginx -c  /usr/local/nginx/conf/nginx.conf

  Above nginx service has started successfully, the back can add / usr / local / nginx / sbin directory to the path in a global, not just positioning to / usr / local / nginx / down sbin. The default port is 80 (Verification of the firewall has opened 80 ports).

- View nginx process 
[root @ xuegod64 sbin] # PS -ef | grep nginx

  

  Finally, check the running status of nginx

[root@xuegod64 sbin]# curl http://192.168.2.101:80

  If welcome to nginx does not appear, you need to see nginx logs (/ usr / local / nginx / logs), to be distributed in the client (iis service) to fight through telnet 192.168.2.101 80. You can also enter the address in the browser to view the state as follows:

    

 II. Configuring IIS distribution

  2.1 nginx.conf edit files (you can back it)

    (1) First nobdy user commented, adding nginx users in the group, the following script

2 #user  nobody;
3 user nginx nginx;
4 worker_processes  1;

    (2)  add a distribution policy
    found at http server node module, the inside of the location node, Location is the root directory of the site, the location node, the added distribution strategy, as shown below (note that if you want to be free interval between the braces { )

 44         location / {
 45             root   html;
 46             index  index.html index.htm;
 47         if ($request_uri ~* \.html$) {
 48                 proxy_pass http://htmlservers;
 49            }
 50          if ($request_uri ~* \.aspx$){
 51                proxy_pass http://aspxservers;
 52            }
 53            proxy_pass http://picservers;
 54         }

    Note that the above url uri with the same Uniform Resource placeholder for example, if the end has come a .html, all go to http: // server on htmlservers, there aspxservers server, and finally picservers server. (Start their own name, rather a pool of servers). Finally picservers equivalent else.

    (3) the definition of the load equipment ip (50,51 ip here on the IIS server), add the position in the last row in the http module, the latter according to their actual ip, make changes, save the file and exit nginx.conf

126        upstream  htmlservers{
127           server 192.168.2.50:80;
128           server 192.168.2.51:80;
129       }
130       upstream  aspxservers{
131           server 192.168.2.50:80;
132           server 192.168.2.51:80;
133       }
134       upstream   picservers{
135           server 192.168.2.50:80;
136           server 192.168.2.51:80;
137       }
138 
139 }

     (4) Check the configuration is correct, reload configuration

[root@xuegod64 sbin]# pwd
/usr/local/nginx/sbin
[root@xuegod64 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@xuegod64 sbin]# ./nginx -s reload

 

 
 
 

A. Installation

  Operating System: centos 7, nginx version 1.12.2, windows server 2008 iis 

  1.1 validation tool nginx depends

    Zlib: nginx provide gzip module requires zlib library support, Openssl: nginx provide ssl function, Pcre: support for address rewriting rewrite function. If not, use yum to install under the root.

- Detection Kit is installed dependence 
[root @ xuegod64 HSR] # yum List | grep zlib 
[root @ xuegod64 HSR] # yum List | grep OpenSSL 
[root @ xuegod64 HSR] # yum List | grep PCRE

  1.2 install nginx

    After downloading the package nginx-1.12.2.tar.gz, in the system directory linux / home / hsr / lower.

- unzip 
[root @ xuegod64 HSR] # tar -xzvf nginx- 1.12 . 2 . Tar .gz 
[root @ xuegod64 HSR] # cd nginx - 1.12 . 2 
- compiler 
[root @ xuegod64 nginx - 1.12 . 2 ] #. / Configure
 - mounting 
[the root xuegod64 Nginx @ - 1.12 . 2 ] # the make    
[Nginx xuegod64 the root @ - 1.12 . 2 ] # the make  the install

  1.3 nginx user generated operating system

/ * 
Use -u 8000 to generate a user ID, 
-s specified user login shell after used, 
Nginx user refers to the system 
* / 
 [the root xuegod64 @ ~] # the useradd -u 8000 -s / usr / sbin / nologin Nginx
- View nginx user information 
[root @ xuegod64 sbin] # CAT / etc / passwd 
nginx: the X-: 8000 : 8000 :: / Home / nginx: / sbin / nologin

   1.4 Starting nginx

[root@xuegod64 sbin]# pwd
/usr/local/nginx/sbin
[root@xuegod64 sbin]# ./nginx -c  /usr/local/nginx/conf/nginx.conf

  Above nginx service has started successfully, the back can add / usr / local / nginx / sbin directory to the path in a global, not just positioning to / usr / local / nginx / down sbin. The default port is 80 (Verification of the firewall has opened 80 ports).

- View nginx process 
[root @ xuegod64 sbin] # PS -ef | grep nginx

  

  Finally, check the running status of nginx

[root@xuegod64 sbin]# curl http://192.168.2.101:80

  If welcome to nginx does not appear, you need to see nginx logs (/ usr / local / nginx / logs), to be distributed in the client (iis service) to fight through telnet 192.168.2.101 80. You can also enter the address in the browser to view the state as follows:

    

 II. Configuring IIS distribution

  2.1 nginx.conf edit files (you can back it)

    (1) First nobdy user commented, adding nginx users in the group, the following script

2 #user  nobody;
3 user nginx nginx;
4 worker_processes  1;

    (2)  add a distribution policy
    found at http server node module, the inside of the location node, Location is the root directory of the site, the location node, the added distribution strategy, as shown below (note that if you want to be free interval between the braces { )

 44         location / {
 45             root   html;
 46             index  index.html index.htm;
 47         if ($request_uri ~* \.html$) {
 48                 proxy_pass http://htmlservers;
 49            }
 50          if ($request_uri ~* \.aspx$){
 51                proxy_pass http://aspxservers;
 52            }
 53            proxy_pass http://picservers;
 54         }

    Note that the above url uri with the same Uniform Resource placeholder for example, if the end has come a .html, all go to http: // server on htmlservers, there aspxservers server, and finally picservers server. (Start their own name, rather a pool of servers). Finally picservers equivalent else.

    (3) the definition of the load equipment ip (50,51 ip here on the IIS server), add the position in the last row in the http module, the latter according to their actual ip, make changes, save the file and exit nginx.conf

126        upstream  htmlservers{
127           server 192.168.2.50:80;
128           server 192.168.2.51:80;
129       }
130       upstream  aspxservers{
131           server 192.168.2.50:80;
132           server 192.168.2.51:80;
133       }
134       upstream   picservers{
135           server 192.168.2.50:80;
136           server 192.168.2.51:80;
137       }
138 
139 }

     (4) Check the configuration is correct, reload configuration

[root@xuegod64 sbin]# pwd
/usr/local/nginx/sbin
[root@xuegod64 sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@xuegod64 sbin]# ./nginx -s reload

 

Guess you like

Origin www.cnblogs.com/linpei/p/10980205.html