Centos 64-bit mounting nginx-1.6.2
Centos 64-bit for linux
Step 1: Download the corresponding version from http://nginx.org/download/( or wget http://nginx.org/download/nginx-1.5.9.tar.gzdirectly on linux)
Step 2: unzip tar-zxvf nginx-1.5.9.tar.gz
Step 3: Set the configuration information./configure -- prefix =/usr/local/nginx, or do not execute this step.
Step 4:
Make compilation (The make process is to convert source code files written in various languages into executable files and various library files)
Make install (make install copies the compiled executable files and library files to appropriate places)
When configuring information, that is, in step 3, an error occurs:
Error:./configure: error: the HTTP rewrite module requires the PCRE library.
Install pcre-devel to solve the problem
Yum-y install pcre-devel
It is also possible that:
Install zlib-devel to solve the problem
Yum-y install zlib-devel
It is also possible that:
Error message:./configure: error: the HTTP cache module requires md5 functions
From OpenSSL library. You can either disable the module by using
-- Without-http-cache option, or install the OpenSSL library into the system,
Or build the OpenSSL library statically from the source with nginx by using
-- With-http_ssl_module -- with-openssl = <path> options.
Solution:
Yum-y install openssl-devel
After installation, start and disable nginx in linux:
Start Operation
/Usr/nginx/sbin/nginx (/usr/nginx/sbin/nginx-t to check whether the configuration information is correct)
Web Interface: http: // 192.168.189.136: 80/
Stop operation
The stop operation is performed by sending a signal to the nginx process (for more information about the signal, see the linux document ).
Step 1: query the nginx master process number
Ps-ef | grepnginx
Find the master process in the process list. Its number is the master process number.
Step 2: send signals
Stop Nginx with ease:
Kill-QUIT master process number
Stop Nginx quickly:
Kill-TERM master process number
Force stop Nginx:
Pkill-9nginx
In addition, if the pid file storage path is configured in nginx. conf, the file stores the Nginx main process number. If no pid file is specified, the file is placed in the nginx logs directory. With the pid file, we do not need to query the main process Number of Nginx first, but directly send a signal to Nginx. The command is as follows:
Kill-signal type '/usr/nginx/logs/nginx. pid'
Smooth restart
If you change the configuration, restart Nginx. Do you need to disable Nginx before enabling Nginx? No. You can send a signal to Nginx to restart Nginx smoothly.
Smooth restart command:
Kill-HUP enters the title or process number file path
Or use
/Usr/nginx/sbin/nginx-sreload
To use nginx to configure Server Load balancer for Web servers, you need to modify the following:
A) configure the upstream attribute under the http tag, for example:
Upstream mysvr {
# The weigth parameter indicates the weight. A higher weight indicates a higher probability of being assigned.
Server 192.168.189.136: 8080 weight = 5;
Server 192.168.189.20.: 8080 weight = 1;
Server 192.168.189.138: 8080 weight = 6;
}
Weight is optional. If weight is not configured, all Web servers have the same weight by default.
B) modify the server label under the http label, for example:
Server {
Listen 83;
Server_name localhost;
Location /{
Root/root;
Index. jsp;
Proxy_pass http: // mysvr;
Proxy_set_header Host $ host: 83;
Proxy_set_header X-Real-IP $ remote_addr;
Proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;
}
......
}
It should be noted that server_name and listen respectively set the user access address and port; proxy_pass specifies the list of servers to be switched (defined in upstream ); proxy_set_header Host sets the address in the http packet to be redirected to the address specified in proxy_pass. You can also specify the port number here. If this parameter is not specified, port 80 is redirected by default.
In this example, the server uses tomcat
Enter the following URL for testing:
Http: // 192.168.189.136: 80/examples/
Http: // 192.168.189.136: 8080/examples/
Http: // 192.168.189.20.: 8080/examples/
Http: // 192.168.189.138: 8080/examples/