Reduce Apache's Load With Nginx On RHEL 5.2
Reduce Apache's Load With Nginx On RHEL 5.2This how-to describes how to install and configure Nginx to accelerate an Apache server based on RHEL 5.2.
1. Update your installed packagesyum install update
2. Install new packagesyum install -y httpd-devel wget http://rpmfind.net/linux/EPEL/5Server/i386/nginx-0.6.31-3.el5.i386.rpm rpm nginx-0.6.31-3.el5.i386.rpm
3. Edit /etc/nginx/nginx.confSetting up nginx as a reverse proxy: nano /etc/nginx/nginx.conf Change worker_processes 1; To worker_processes 2; Replace http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
#
# The default server
#
server {
listen 80;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}with http {
include /etc/nginx/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 /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
#
# The default server
#
server {
listen 80;
server_name YOURSERVERNAME;
#charset koi8-r;
#access_log logs/host.access.log main;
#Main location
location / {
proxy_pass http://127.0.0.1:8080/;
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;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
root /usr/share/nginx/html;
index index.html index.htm index.php;
}This function allows nginx to work with these file types: Change #location ~ /\.ht {
#deny all;to location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$ {root /var/www;}
4. Check nginx confnginx -t The result must be like this: 2008/07/17 16:09:46 [info] 17197#0: the configuration file /etc/nginx/nginx.conf syntax is ok
5. Installing rpaf-2.0 moduleThis module gives active Nginx IPs to Apache. cd /usr/local/src wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz tar xzf mod_rpaf-0.6.tar.gz cd mod_rpaf-0.6
Compiling rpaf module:nano /usr/local/src/mod_rpaf-0.6/makefile Change APXS=$(shell which apxs) to APXS=/usr/sbin/apxs. Compile ways: I) make rpaf-2.0 && make install-2.0 II) apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
6. Edit httpd.confnano /etc/httpd/conf/httpd.conf Add ... LoadModule rpaf_module modules/mod_rpaf-2.0.so .... #Mod_rpaf settings RPAFenable On RPAFproxy_ips 127.0.0.1 REALIP1 REALIP2 RPAFsethostname On Change Listen 80 to Listen 8080, because nginx will use port 80.
7. Restart Apache & start Nginxservice httpd restart service nginx start
8. View resultsApache test page by Nginx:
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Learn benefits of Simpana software.
View the Gartner Video








Recent comments
21 hours 27 min ago
22 hours 22 min ago
1 day 1 hour ago
1 day 7 hours ago
1 day 7 hours ago
1 day 15 hours ago
1 day 15 hours ago
1 day 15 hours ago
1 day 17 hours ago
1 day 19 hours ago