Name and version of the required software:
Pcre-8.02.tar.gz
Nginx-0.7.58.tar.gz
Nginx_upstream_hash-0.3.1.tar.gz
1. Installation Pcre
TAR-ZXVF pcre-8.02.tar.gz
CD pcre-8.02/
./configure
Make && make install
2. Install Url_hash patch for Nginx
TAR-ZXVF nginx-0.7.58.tar.gz
TAR-ZXVF nginx_upstream_hash-0.3.1.tar.gz
CD nginx-0.7.58/
Patch-p0 </var/tmp/loojoy/nginx_upstream_hash-0.3.1/nginx.patch
3. Installation Nginx
Groupadd www
Useradd www-g www
./configure--prefix=/usr/local/webserver/nginx
--user=www
--group=www
--add-module=/var/tmp/loojoy/nginx_upstream_hash-0.3.1
--with-http_ssl_module
--with-http_stub_status_module
4, check the nginx generated configuration file is correct
/usr/local/webserver/nginx/sbin/nginx-t
5, start Nginx
If the Nginx.conf check passes, start the nginx.
/usr/local/webserver/nginx/sbin/nginx
6. View Port 80
Netstat-ant
7, through the browser access:
http://your_nginx_server_ip/
If normal access is available, the Nginx installation succeeds.
8, modify the Nginx configuration file as follows:
-------------------Url_hash Forwarding Method nginx.conf--------------------
User www www
Worker_processes 10
Error_log Logs/error.log
#error_log Logs/error.log Notice
#error_log Logs/error.log Info
#pid Logs/nginx.pid
Worker_rlimit_nofile 51200
Events
{
Use Epoll
Worker_connections 51200
}
http
{
Include Mime.types
Default_type Application/octet-stream
Keepalive_timeout 120
Tcp_nodelay on
Upstream your.website.name{
Server your.tomcat.server.ip1:8080
Server your.tomcat.server.ip1:8080
Hash $request _uri
}
Server
{
Listen 80
server_name Your.website.name
Location/{
Proxy_pass Http://your.website.name
Proxy_set_header Host $host
Proxy_set_header X-real-ip $remote _addr
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for
}
Log_format www_gjw_com ' $remote _addr-$remote _user [$time _local] $request '
"$status" $body _bytes_sent "$http _referer"
"$http _user_agent" "$http _x_forwarded_for"
#access_log/data1/logs/www.log www_gjw_com
Location/nginx_status {
Stub_status on
Access_log off
}
}
}
-------------------[E]url_hash forwarding way nginx.conf[e]--------------------
9, add Nginx startup, shutdown, restart script
-------------------[S]url_hash forwarding nginx start, close script [S]--------------------
#!/bin/sh
cwd= ' pwd '
Case is in
Start
/usr/local/webserver/nginx/sbin/nginx
;
Stop
Kill-2 ' ps-ef|grep '/usr/local/webserver/nginx/sbin/nginx ' |grep-v ' grep ' |awk ' {print $} '
;
Restart)
CD "$CMD"
$ stop
$ start
;
*)
echo $ "Usage: $ {Start|stop|restart}"
Exit 1
Esac
Exit 0
-------------------[E]url_hash forwarding nginx start, close script [E]--------------------
Change the file permissions
chmod u+x nginx.sh
Launch Nginx./nginx.sh start
Reboot Nginx./nginx.sh restart
Close Nginx./nginx.sh stop