CentOS6.5安装nginx及负载均衡配置
1、下载PCRE, 是一个用C语言编写的正则表达式函数库
[root@localhost download]# wget http://ncu.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
[root@localhost download]# wget http://www.openssl.org/source/openssl-1.0.1p.tar.gz
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# 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: /var/run/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
nginx (pid 2417 2416) is running...
[root@localhost logs]# /etc/init.d/nginx stop
Stopping nginx: [ OK ]
[root@localhost logs]# /etc/init.d/nginx start
Starting nginx: [ OK ]
[root@localhost logs]# /etc/init.d/nginx status
nginx (pid 2454 2452) is running...
pid /usr/local/nginx/nginx.pid;
worker_rlimit_nofile 102400;
events
{
use epoll;
worker_connections 102400;
}
http
{
include mime.types;
default_type application/octet-stream;
fastcgi_intercept_errors on;
charset utf-8;
server_names_hash_bucket_size 128;
client_header_buffer_size 4k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
client_body_buffer_size 512k;
proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
###2012-12-19 change nginx logs
log_format main '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $request_time $remote_addr';
upstream web_app {
server 192.168.137.197:8080 weight=1 max_fails=2 fail_timeout=30s;
server 192.168.137.33:8080 weight=1 max_fails=2 fail_timeout=30s;
server 10.10.33.59:8080 weight=1 max_fails=2 fail_timeout=30s;
}
####chinaapp.sinaapp.com
server {
listen 80;
server_name chinaapp.sinaapp.com;
index index.jsp index.html index.htm;
#发布目录/data/www
root /data/www;
location /
{
proxy_next_upstream http_502 http_504 error timeout invalid_header;
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_pass http://web_app;
expires 3d;
}
}
}
/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
libpcre.so.0
libpcre.so.0.0.1
[root@localhost local]# ls /lib/ |grep pcre
[root@localhost local]# cd nginx
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
最新文章
- oncopy=";document.selection.empty()";跟oncopy=";return false";什么区别?
- VBA中如何动态定义数组
- 单机搭建Android开发环境(二)
- div文字超出
- 第一章 开始编写第一个jsp
- Android源码分析之Looper
- 基于@AspectJ和schema的aop(三)---切点函数详解
- poj 3250 Bad Hair Day 单调栈入门
- POJ 3308 Paratroopers(最小割EK)
- 2.2.4 转换 Path
- hdu 1262寻找素数对
- 基于linux c的mysql操作——幼儿园数据管理系统
- gcc/g++ 如何支持c11 / c++11标准编译
- 201421123042 《Java程序设计》第4周学习总结
- Python多版本管理-pyenv
- [再寄小读者之数学篇](2014-06-22 求极限 [中国科学技术大学2011年高等数学B考研试题])
- Spring源码阅读(五)
- sudo 命令报错的解决方法
- UVa 1660 电视网络(点连通度+最小割最大流+Dinic)
- 配置Tomcat的server.xml以适应web-content文件系统的位置改变