Nginx relies on three packages
Gzip module requires zlib library (download: http://www.zlib.net/) zlib-1.2.8.tar.gz
wget http://zlib.net/zlib-1.2.8.tar.gz
TAR-ZXVF zlib-1.2.8.tar.gz CD zlib-1.2.8
./configure
Make&make Install
2. Rewrite module requires pcre library (download: http://www.pcre.org/) pcre-8.21.tar.gz
Installing the Pcre Library
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
TAR-ZXVF pcre-8.21.tar.gz
CD pcre-8.21
./configure
Make&make Install
3. The SSL function requires the OpenSSL library (download: http://www.openssl.org/) openssl-1.0.1.tar.gz
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
TAR-ZXVF openssl-1.0.1c.tar.gz
./config
Make&make Install
Note: You can install dependent packages with one click yum-y groupinstall "Development Tools" "Development Libraries"
4. Installing Nginx
wget http://nginx.org/download/nginx-1.2.8.tar.gz
TAR-ZXVF nginx-1.2.8.tar.gz
CD nginx-1.2.8
./configure--prefix=/usr/local/nginx \
--conf-path=/etc/nginx/nginx.conf \
--sbin-path=/usr/sbin/nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_image_filter_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_concat_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_sysguard_module \
--with-backtrace_module \
--with-http_stub_status_module \
--with-http_upstream_check_module
#定义编译参数 #
Make&make Install
5. Edit the nginx.conf file #需要根据具体情况编写 #
User www p2progs;
Worker_processes 8;
Worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;
Pid/var/run/nginx.pid;
Worker_rlimit_nofile 65536;
Events
{
Use Epoll;
Worker_connections 65536;
}
http
{
Include Mime.types;
Default_type Application/octet-stream;
CharSet Utf-8;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 4k;
Large_client_header_buffers 4 32k;
Client_max_body_size 8m;
Open_file_cache max=65536 inactive=20s;
Open_file_cache_valid 30s;
Open_file_cache_min_uses 1;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 60;
Tcp_nodelay on;
Server_tokens off;
Port_in_redirect off;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64k;
Fastcgi_buffers 4 64k;
Fastcgi_busy_buffers_size 128k;
Fastcgi_temp_file_write_size 128k;
gzip on;
Gzip_vary on;
Gzip_min_length 1k;
Gzip_buffers 4 16k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_disable "MSIE [1-6]\. (?!. *SV1) ";
Proxy_connect_timeout 600;
Proxy_read_timeout 600;
Proxy_send_timeout 600;
Proxy_buffer_size 16k;
Proxy_buffers 4 32k;
Proxy_busy_buffers_size 64k;
Proxy_temp_file_write_size 64k;
Log_format access ' $remote _addr-$remote _user [$time _local] "$request"
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" $http _x_forwarded_for ';
Server
{
Listen 80;
server_name#只需更改 server_name for the corresponding website domain name can be #
Index index.html index.htm;
Error_log
Access_log
if ($host ~* ^ (p2puser.com) $) {
Rewrite ^/(. *) $
Break
}
Rewrite ^ (. *) \;(. *) $ $ last;
Location ~ \. (Jsp|do|html|action|tpl|eot|svg|page|woff|ttf) $ {
Proxy_pass http://127.0.0.1:8564;
Proxy_redirect off;
Proxy_set_header HOST $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
}
}
}
6.nginx installation is complete, start nginx. Service Nginx Start (if the command cannot be found, there may be an issue with the Nginx installation version that does not have a startup script.) Copy a script and you can use the command. Of course, there are other commands to reboot, turn on, turn off).
7.chkconfig nginx on (add Nginx to boot,
Note: The Proxy_pass http://127.0.0.1:8564 to be consistent with the Tomcat port.
8.nginx Related commands:
/usr/local/nginx/nginx-t Checking nginx configuration file
/usr/local/nginx/nginx-s Reload Reload configuration file (do not stop service)
/usr/local/nginx/sbin/nginx–s Reload Restart
Parameters for 9.Nginx Compilation
–prefix #nginx安装目录, default in/usr/local/nginx
–pid-path #pid文件位置, default in Logs directory
–lock-path #lock文件位置, default in Logs directory
–with-http_ssl_module #开启HTTP the SSL module to support HTTPS requests.
–with-http_dav_module #开启WebDAV扩展动作模块, you can specify permissions for files and directories
–with-http_flv_module #支持对FLV文件的拖动播放
–with-http_realip_module #支持显示真实来源IP地址
–with-http_gzip_static_module #预压缩文件传前检查 to prevent files from being repeatedly compressed
–with-http_stub_status_module #取得一些nginx的运行状态
–with-mail #允许POP3/IMAP4/SMTP Agent Module
–with-mail_ssl_module #允许POP3/IMAP/SMTP can use SSL/TLS
–with-pcre=. /pcre-8.21 #注意是未安装的pcre路径
–with-zlib=. /zlib-1.2.8 #注意是未安装的zlib路径
–with-debug #允许调试日志
–http-client-body-temp-path #客户端请求临时文件路径
–http-proxy-temp-path #设置http Proxy Temp file path
–http-fastcgi-temp-path #设置http fastcgi Temporary file path
–http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi Temporary file path
–http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi Temporary file path
This article from "10998982" blog, declined reprint!
Nginx Installation Deployment