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
CentOS6.5安装nginx及负载均衡配置的更多相关文章
- 傻瓜式安装nginx以及负载均衡配置
概述 需求 做了一个对内的http api应用.由于只有一台服务器,考虑到升级问题(即升级时会造成几秒钟用户访问不了),决定搭一个nginx,公共端口:9999,部署2套应用,端口:9981,9982 ...
- nginx四层负载均衡配置
nginx四层负载均衡配置代理Mysql集群 环境如下: ip 192.168.6.203 Nginx ip 192.168.6.*(多台) Mysql 步骤一 查看Nginx是否安装stream模块 ...
- Nginx + Tomcat 负载均衡配置详解
Nginx常用操作指南一.Nginx 与 Tomcat 安装.配置及优化1. 检查和安装依赖项 yum -y install gcc pcre pcre-devel zlib zlib-devel o ...
- Docker安装nginx以及负载均衡
首先在linux系统中新建一个data文件夹进行nginx容器的创建--即为:mkdir data. 一:第一次 1 第一步: 使用 docker pull nginx将nginx的镜像从仓库下载下来 ...
- [转]CENTOS 6.5 配置YUM安装NGINX+服务器负载均衡
原文连接: CENTOS 6.5 配置YUM安装NGINX http://blog.sina.com.cn/s/blog_69f467b70102uyux.html 参考博文: Centos下安装. ...
- centos6 Nginx+Tomcat负载均衡配置
一.Nginx简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡,具体简介我就不介绍了百度一下有很多,下面直接进入安装步骤 二.Nginx安装 1.下载N ...
- Nginx+tomcat负载均衡配置
Nginx+tomcat是目前主流的java web架构,如何让nginx+tomcat同时工作呢,也可以说如何使用nginx来反向代理tomcat后端均衡呢?直接安装配置如下: 1.JAVA JDK ...
- Linux上安装nginx+tomcat负载均衡
1.Ngnix Nginx (发音同 engine x)是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行. 其特点是占有内 ...
- Linux记录-Nginx+Tomcat负载均衡配置
Nginx负载均衡配置及策略: 轮询(默认) 优点:实现简单缺点:不考虑每台服务器的处理能力配置示例如下:upstream www.xxx.com {# 需要负载的server列表server www ...
随机推荐
- VLAN是什么
VLAN是什么?VLAN,是英文Virtual Local Area Network的缩写,中文名为"虚拟局域网", VLAN是一种将局域网(LAN)设备从逻辑上划分(注意,不是从 ...
- windows命令行编码与nodejs编码格式冲突的解决方式
今天写一个工具,由于大部分人使用的机器都是windows,在和nodejs结合的时候出问题了. win命令行的编码格式是gbk,而nodejs支持的编码只有:utf8 ascii和base64,必须让 ...
- TCP/IP的三次握手和四次分手以及超时机制
使用INADDR_ANY的时候,往往针对多网卡情况,采用tcp连接方式,需要选择使用哪一个网卡发送,自己猜想应该是使用三次握手机制,如何判断目标地址不可达,应该使用的是超时机制,即握手超时则不可到达. ...
- R语言学习笔记:矩阵与数组(array)
元素可以保存在多个维度的对象中,数组存储的是多维数据元素,矩阵的是数组的特殊情况,它具有两维. 创建数组的几种方法. 1. > m<-c(45,23,66,77,33,44,56,12,7 ...
- C#.Net 如何动态加载与卸载程序集(.dll或者.exe)6-----在不卸载程序域的前提下替换程序集文件。
当某个程序集文件被载入AppDomain,该文件在AppDomain.Unload之前是不能被替换和删除的.使用AppDomainSetup的影像复制功能可以实现在不卸载程序的情况下替换或者删除程序集 ...
- ORA-14452: 试图创建, 更改或删除正在使用的临时表中的索引
ORA-14452: 试图创建, 更改或删除正在使用的临时表中的索引 因为表KOL_XX_FIN050_TEMP 为临时表,而且有其他session正在使用. 处理步骤: 1.先从 dba ...
- Red hat Linux(Centos 5/6)安装R语言
Red hat Linux(Centos 5/6)安装R语言1 wget http://cran.rstudio.com/src/base/R-3/R-3.0.2.tar.gz2 tar xzvf R ...
- POI 中Cell的backgroundcolor和foregroundcolor
刚开始以为要获得cell的背景色是使用 getFillBackgroundColor()这个函数(这里返回的是调色板的索引,要获得RGB需要先获得系统的Pallete,然后在获得 RGB).结果出来 ...
- WVGA-维基百科
WVGA是一种屏幕分辨率的规格,其中的W意味宽(wide),长宽比为800×480.与之相关的还有VGA(640×480)和FWVGA(854×480). WVGA并不是16:9比例,而是5:3的显示 ...
- 记录遇到的IE8兼容性问题汇总
1,伪元素:first-child不起作用,需要单独指定样式名称 2,透明度表示方法,尤其在函数中表示 @mixin opacity($value) { -webkit-opacity: $value ...