3. install nginx dependent package # yum-yinstallpcrepcre-developensslopenssl-devel...
1. install Nginx
1. download nginx( official network download, and nginx-1.0.5.tar.gz)
2. decompress
# Tar zxvf nginx-1.0.5.tar.gz
3. install nginx dependent packages
# Yum-y install pcre-devel openssl-devel
4. install nginx
#./Configure -- prefix =/usr/local/nginx
# Make & make install
5. check whether the installation is complete.
# Cd/usr/local/nginx/sbin
# Nginx
(Enter the server address http: // localhost/to check whether the installation is successful. Generally, there is no problem)
2. integrate objective
Modify nginx configuration file
# Vi/usr/local/nginx/conf/nginx. conf
Edit content
# User nobody;
Worker_processes 1;
# Error_log logs/error. log;
# Error_log logs/error. log notice;
# Error_log logs/error. log info;
# User add
Error_log logs/error. log info;
# Pid logs/nginx. pid;
Pid logs/nginx. pid;
Events {
# User add
Use epoll;
Worker_connections 1024;
}
Http {
Include mime. types;
Default_type application/octet-stream;
# Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
# '$ Status $ body_bytes_sent "$ http_referer "'
# '"$ Http_user_agent" "$ http_x_forwarded_for "';
# Access_log logs/access. log main;
Access_log logs/access. log;
# User add
Client_header_timeout 3 m;
Client_body_timeout 3 m;
Send_timeout 3 m;
Client_header_buffer_size 1 k;
Large_client_header_buffers 4 4 k;
Sendfile on;
# Tcp_nopush on;
Tcp_nopush on;
Tcp_nodelay on;
# Keepalive_timeout 0;
Keepalive_timeout 65;
# Proxy
Include proxy. conf;
# Gzip on;
# User add
Include gzip. conf;
Server {
Listen 80;
Server_name localhost;
# Charset KOI8-R;
# Access_log logs/host. access. log main;
Location /{
Root html;
Index index.html index.htm index. jsp;
Proxy_pass http: // localhost: 8080;
Proxy_connect_timeout 3;
Proxy_send_timeout 30;
Proxy_read_timeout 30;
}
# Error_page 404/404 .html;
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 127.0.0.1;
#}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Location ~ \. Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# Fastcgi_index index. php;
# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;
# Include fastcgi_params;
#}
# Deny access to. htaccess files, if Apache's document root
# Concurs with nginx's one
#
# Location ~ /\. Ht {
# Deny all;
#}
}
# Another virtual host using mix of IP-, name-, and port-based configuration
#
# Server {
# Listen 8000;
# Listen somename: 8080;
# Server_name somename alias another. alias;
# Location /{
# Root html;
# Index index.html index.htm;
#}
#}
# HTTPS server
#
# Server {
# Listen 443;
# Server_name localhost;
# Ssl on;
# Ssl_certificate cert. pem;
# Ssl_certificate_key cert. key;
# Ssl_session_timeout 5 m;
# Ssl_protocols SSLv2 SSLv3 TLSv1;
# Ssl_ciphers HIGH :! ANULL :! MD5;
# Ssl_prefer_server_ciphers on;
# Location /{
# Root html;
# Index index.html index.htm;
#}
#}
} T
Add proxy. conf to configure www.2cto.com
# Vi/usr/local/nginx/conf/proxy. conf
Content
#! Nginx
# Proxy. conf
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;
Client_max_body_size 10 m;
Client_body_buffer_size 128 k;
Proxy_connect_timeout 300;
Proxy_send_timeouts 300;
Proxy_read_timeout 300;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
Edit gzip. conf
# Vi/usr/local/nginx/conf/gzip. conf
Content
# Nginx
# Gzip. conf
Gzip on;
Gzip_min_length 1000;
Gzip_types text/plain text/css application/x-javascript;
Run the test
Start tomcat
/Usr/local/tomcat/bin/startup. sh restart
Start nginx
/Usr/local/nginx/sbin/nginx
The operation is complete!
From zhaoweitco's column