cd /usr/local/src/添加启动脚本
wget http://nginx.org/download/nginx-0.7.65.tar.gz
tar -zxf nginx-0.7.65.tar.gz
cd nginx-0.7.65
./configure --user=apache --group=apache --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/conf/nginx.conf --pid-path=/var/log/nginx/nginx.pid --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx_client --http-proxy-temp-path=/tmp/nginx_proxy --http-fastcgi-temp-path=/tmp/nginx_fastcgi --with-http_stub_status_module
make
make install
#! /bin/sh嗯嗯.这个脚本很熟悉吧,呵呵.记得赋予执行权限,chmod 755 /etc/init.d/nginx 接着设置nginx.conf.
ulimit -n 65535
# Description: Startup script for nginx
# chkconfig: 2345 55 25
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/sbin/$NAME
CONFIGFILE=/etc/nginx/conf/nginx.conf
PIDFILE=/var/log/nginx/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
set -e
[ -x "$DAEMON" ] || exit 0
do_start() {
$DAEMON -c $CONFIGFILE || echo -n "nginx already running"
}
do_stop() {
kill -INT `cat $PIDFILE` || echo -n "nginx not running"
}
do_reload() {
kill -HUP `cat $PIDFILE` || echo -n "nginx can't reload"
}
case "$1" in
start)
echo -n "Starting $DESC: $NAME"
do_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
do_stop
echo "."
;;
reload)
echo -n "Reloading $DESC configuration..."
do_reload
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
do_stop
sleep 1
do_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
mv /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.bak输入以下内容
mkdir /etc/nginx/conf/ips
vim /etc/nginx/conf/nginx.conf
在/etc/nginx/conf/ips路径下.添加监听的IP地址的虚拟主机配置,有多个IP.就添加多几个主机配置,以192.168.2.1为例:
worker_processes 4;
worker_rlimit_nofile 51200;
events {
worker_connections 51200;
use epoll;
}
error_log /var/log/nginx/error.log info;
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 120;
gzip on;
gzip_http_version 1.0;
gzip_min_length 1100;
gzip_comp_level 3;
gzip_buffers 4 32k;
gzip_types text/plain text/xml text/css application/x-javascript application/xml application/xml+rss text/javascript application/atom+xml;
ignore_invalid_headers on;
connection_pool_size 256;
request_pool_size 32k;
server_names_hash_max_size 2048;
server_names_hash_bucket_size 256;
output_buffers 4 64k;
postpone_output 1460;
#open_file_cache max=1000 inactive=300s;
#open_file_cache_valid 600s;
#open_file_cache_min_uses 2;
#open_file_cache_errors off;
client_max_body_size 100m;
client_body_buffer_size 256k;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
include "/etc/nginx/conf/ips/*.conf";
}
server {上例中的error_page都转发到后端.
listen 192.168.2.1:80;
server_name _;
access_log off;
error_page 400 401 402 403 404 405 406 407 408 409 500 501 502 503 504 @backend;
location @backend {
internal;
proxy_connect_timeout 30s;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 46k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_path /dev/shm/proxy_temp;
proxy_redirect http://$host:81 http://$host;
proxy_redirect http://www.$host:81 http://$host;
proxy_pass http://192.168.2.1:81;
proxy_pass_header User-Agent;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
proxy_connect_timeout 30s;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_path /dev/shm/proxy_temp;
proxy_redirect http://$host:81 http://$host;
proxy_redirect http://www.$host:81 http://$host;
proxy_pass http://192.168.2.1:81;
proxy_pass_header User-Agent;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
cd /usr/local/src/安装完了之后.编辑/etc/httpd/conf/httpd.conf文件.添加以下内容:
wget http://stderr.net/apache/rpaf/download/mod_rpaf-0.6.tar.gz
tar -zxf mod_rpaf-0.6.tar.gz
cd mod_rpaf-0.6
/usr/sbin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
LoadModule rpaf_module /usr/lib/apache/mod_rpaf-2.0.so[your_ips]改成你自己的监听IP
#Mod_rpaf settings
RPAFenable On
RPAFproxy_ips 127.0.0.1 [your_ips]
RPAFsethostname On
RPAFheader X-Forwarded-For
Port 81ips_virtual_host.conf virtual_host2_sub.conf virtual_host.conf virtual_host_sub.conf httpd.conf redirect_virtual_host.conf virtual_host2.conf
Listen 81
Listen 443
<VirtualHost |IP|:81>此外还要修改已绑定域名的配置文件.位于/etc/httpd/conf /usr/local/directadmin/data/users/ 两处目录.进入以上路径后可以使用以下命令查找端口.
grep 80 . -r端口还是改成"81".然后还是细心一点.接着重启一下nginx和httpd.
cd /etc/httpd/conf/注释掉Include /etc/httpd/conf/ips.conf,再在下面把你所监听的IP都添加上去:
vim httpd.conf
NameVirtualHost ip:81tip:1.建议关闭apache的Deflate模块.直接在/etc/httpd/conf/httpd.conf中注释掉Deflate模块那一段.在第165行.
NameVirtualHost ip:443


没这么强吧...我的巴斯500个并发丢过去.nginx都挂了.
| 欢迎光临 全球主机交流论坛 (https://loc.010206.xyz/) | Powered by Discuz! X3.4 |