|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!Nginx完成负载平衡(2013-5-2113:43)
1.挂载光盘,删除当地yum库文件,构建新的yum堆栈文件
[root@tdoalnmp_oa]#mount/dev/cdrom/mnt/
mount:blockdevice/dev/cdromiswrite-protected,mountingread-only
[root@tdoa~]#rm-f/etc/yum.repos.d/*
[root@tdoa~]#touch/etc/yum.repos.d/local.repo
[root@tdoa~]#cat>/etc/yum.repos.d/local.repo<<EOF
>[base]
>name=base
>baseurl=file:///mnt/
>gpgcheck=0
>enabled=1
>EOF
[root@tdoa~]#yumcleanall
Loadedplugins:fastestmirror,security
CleaningupEverything
Cleaninguplistoffastestmirrors
2.yum装置体系基础组成所需依附文件
[root@tdoa~]#yum-yinstallgccgcc-c++gcc-g77openssl-devellibtoolreadline-devellibxml2libxml2-develautoconfautomakegdlibjpeglibjpeg-devellibpnglibpng-devellibmcrypt*libtool-ltdl-devel*freetypefreetype-develfiex*zlibzlib-develglibcglibc-develglib2glib2-developenldapopenldap-develnss_ldapncurses-developenldap-clientsopenldap-serversinstallsamba-*system-config-samba-*
3.创建log目次、数据文件目次、附件目次
[root@tdoa~]#/usr/sbin/groupaddtdoa
[root@tdoa~]#/usr/sbin/useradd-gtdoatdoa
[root@tdoa~]#mkdir-p/usr/local/tdoa/data5
[root@tdoa~]#mkdir-p/usr/local/tdoa/logs/nginx
[root@tdoa~]#mkdir-p/usr/local/tdoa/logs/mysql
[root@tdoa~]#mkdir-p/usr/local/tdoa/logs/php
[root@tdoa~]#mkdir-p/usr/local/tdoa/attach/bak
[root@tdoa~]#mkdir-p/usr/local/tdoa/bak
[root@tdoa~]#chown-Rtdoa:tdoa/usr/local/tdoa/attach
[root@tdoa~]#chown-Rtdoa:tdoa/usr/local/tdoa/bak
4.编译装置pcre(装置pcre库是为了使nginx撑持HTTPRewrite模块)
[root@tdoalnmp_oa]#cddown/
[root@tdoadown]#tarzxvfpcre-8.32.tar.gz
[root@tdoadown]#cdpcre-8.32
[root@tdoapcre-8.32]#./configure;make;makeinstall
5编译装置nginx
[root@tdoadown]#tarzxfnginx-1.2.6.tar.gz
[root@tdoadown]#cdnginx-1.2.6
[root@tdoanginx-1.2.6]#./configure--user=tdoa--group=tdoa--prefix=/usr/local/tdoa/nginx--with-http_stub_status_module--with-http_gzip_static_module--with-http_ssl_module--with-http_realip_module;make;makeinstall
[root@tdoaconf]#ln-s/usr/local/lib/libpcre.so.1/lib64/
[root@tdoaconf]#/usr/local/tdoa/nginx/sbin/nginx
[root@tdoaconf]#echo"/usr/local/tdoa/nginx/sbin/nginx">>/etc/rc.d/rc.sysinit
[root@tdoanginx-1.2.6]#vi/usr/local/tdoa/nginx/conf/nginx.conf
usertdoatdoa;
worker_processes2;
error_log/usr/local/tdoa/logs/nginx/error.logerror;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
pid/usr/local/tdoa/logs/nginx/nginx.pid;
worker_rlimit_nofile65535;
events{
useepoll;
worker_connections65535;
}
http{
includemime.types;
default_typeapplication/octet-stream;
log_formatmain$remote_addr-$remote_user[$time_local]"$request"
$status$body_bytes_sent"$http_referer"
"$http_user_agent""$http_x_forwarded_for";
#access_log/usr/local/tdoa/logs/nginx/access.logmain;
keepalive_timeout120;
tcp_nodelayon;
upstream192.168.0.44{
ip_hash;
server192.168.0.40:80;
server192.168.0.41:80;
}
server{
listen80;
server_nametdoa;
location/{
proxy_passhttp://192.168.0.44;
proxy_set_headerHost$host;
proxy_set_headerX-Real-IP$remote_addr;
proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for;
}
}
}
欢迎大家来到仓酷云论坛! |
|