You can also download and compile opensslwww. openssl. orgsourcepcrewww. pcre. orgngw.rewrite website page address rewriting function requires the regular expression module PCRE. In addition, the page compression transmission requires zlib to use the regular expression in the configuration file, which needs to be installed
For related support programs, you can also download and compile from here install openssl http://www.openssl.org/source/ pcre http://www.pcre.org nginx rewrite website page address rewrite function requires regular expression module PCRE, in addition, for page compression and transmission, zlib must use regular expressions in the configuration file and install
You can also download and compile and install related support programs from here.
Openssl
Http://www.openssl.org/source/
Pcre
Http://www.pcre.org
The rewrite function of nginx requires the regular expression module PCRE, and zlib is required for page compression and transmission.
To use regular expressions in the configuration file, install pcre and pcre-devel,
Note: The nginx-0.6.32 has no rpm package installed with pcre and pcre-deve but cannot find the pcre problem.
Note: According to the October 2006 message, md5 is used in an http cache module that is no longer in use, while sha1 is used in an unfinished mysql database module, so they are not required currently.
Read the module description on the wiki carefully.
Http://wiki.codemongers.com/Main
./Configure -- prefix =/usr/local/nginx \
-- With-openssl =/usr/include \
With-http_stub_status_module \
Without-poll_module \
Without-select_module
Make
Make install
# Running user
User nobody;
# Start a process
Worker_processes 2;
# Global error logs and PID files
Error_log logs/error. log notice;
Pid logs/nginx. pid;
# Working mode and maximum number of connections
Events {
Use epoll;
Worker_connections 1024;
}
# Set the http server and use its reverse proxy function to provide Load Balancing support
Http {
# Set the mime type
Include mime. types;
Default_type application/octet-stream;
# Set the log format
Log_format main '$ remote_addr-$ remote_user [$ time_local]'
'"$ Request" $ status $ bytes_sent'
'"$ Http_referer" "$ http_user_agent "'
'"$ Gzip_ratio "';
Log_format download '$ remote_addr-$ remote_user [$ time_local]'
'"$ Request" $ status $ bytes_sent'
'"$ Http_referer" "$ http_user_agent "'
'"$ Http_range" "$ sent_http_content_range "';
# Set Request Buffer
Client_header_buffer_size 1 k;
Large_client_header_buffers 4 4 k;
# Enable the gzip Module
Gzip on;
Gzip_min_length 1100;
Gzip_buffers 4 8 k;
Gzip_types text/plain;
Output_buffers 1 32 k;
Post pone_output 1460;
# Setting access log
Access_log logs/access. log main;
Client_header_timeout 3 m;
Client_body_timeout 3 m;
Send_timeout 3 m;
Sendfile on;
Tcp_nopush on;
Tcp_nodelay on;
Keepalive_timeout 65;
# Set the Server list of Server Load balancer
Upstream backend {
# The weigth parameter indicates the weight. A higher weight indicates a higher probability of being assigned.
# Enable port 3128 for Squid on the local machine
# Server 192.168.8.1: 3128 weight = 5;
Server 192.168.8.2: 80 weight = 6;
Server 192.168.8.3: 80 weight = 6;
}
# Set Virtual Hosts
Server {
Listen 80;
Server_name 192.168.7.192 www.test.com;
Charset gb2312;
# Set access logs for the current virtual host
Access_log logs/www. test. access. log main;
# If you access/img/*,/js/*,/css/* resources, you can directly retrieve the local file without passing squid
# This method is not recommended if there are many files, because the squid cache works better.
# Location ~ ^/(Img | js | css )/{
# Root/data3/Html;
# Expires 24 h;
#}
# Enable Server Load balancer "/"
Location /{
Proxy_pass http: // backend;
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 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4 k;
Proxy_buffers 4 32 k;
Proxy_busy_buffers_size 64 k;
Proxy_temp_file_write_size 64 k;
}
# Set the address for viewing Nginx status
Location/NginxStatus {
Stub_status on;
Access_log on;
# Auth_basic "NginxStatus ";
# Auth_basic_user_file conf/htpasswd;
}
}
}
Curl-I http: // 127.0.0.1 view http Header
Nginx STARTUP script, stored in/etc/init. d/nginxd
#! /Bin/bash
# Nginx Startup script for the Nginx HTTP Server
# This script create it by jackbillow at 2007.10.15.
# It is v.0.0.2 version.
# If you find any errors on this scripts, please contact jackbillow.
# And send mail to jackbillow at gmail dot com.
#
# Chkconfig:-85 15
# Description: Nginx is a high-performance web and proxy server.
# It has a lot of features, but it's not for everyone.
# Processname: nginx
# Pidfile:/usr/local/nginx/logs/nginx. pid
# Config:/usr/local/nginx/conf/nginx. conf
Nginxd =/usr/local/nginx/sbin/nginx
Nginx_config =/usr/local/nginx/conf/nginx. conf
Nginx_pid =/var/run/nginx. pid
RETVAL = 0
Prog = "nginx"
# Source function library.
./Etc/rc. d/init. d/functions
# Source networking configuration.
./Etc/sysconfig/network
# Check that networking is up.
[$ {NETWORKING} = "no"] & exit 0
[-X $ nginxd] | exit 0
# Start nginx daemons functions.
Start (){
If [-e $ nginx_pid]; then
Echo "nginx already running ...."
Exit 1
Fi
Echo-n $ "Starting $ prog :"
Daemon $ nginxd-c $ {nginx_config}
RETVAL =$?
Echo
[$ RETVAL = 0] & touch/var/lock/subsys/nginx
Return $ RETVAL
}
# Stop nginx daemons functions.
Stop (){
Echo-n $ "Stopping $ prog :"
Killproc $ nginxd
RETVAL =$?
Echo
[$ RETVAL = 0] & rm-f/var/lock/subsys/nginx/var/run/nginx. pid
}
# Reload nginx service functions.
Reload (){
Echo-n $ "Reloading $ prog :"
# Kill-HUP 'cat $ {nginx_pid }'
Killproc $ nginxd-HUP
RETVAL =$?
Echo
}
# See how we were called.
Case "$1" in
Start)
Start
;;
Stop)
Stop
;;
Reload)
Reload
;;
Restart)
Stop
Start
;;
Status)
Status $ prog
RETVAL =$?
;;
*)
Echo $ "Usage: $ prog {start | stop | restart | reload | status | help }"
Exit 1
Esac
Exit $ RETVAL