Tengine安装配置
为了加快网站的大流量访问速度,公司要求把Nginx更换为Tengine,下面记录下整个安装配置过程:
#安装必要依赖
yum install -y pcre pcre-devel zlib zlib-devel openssl openssl-devel glibc-headers gcc-c++
#安装google-perftools支持依赖
wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.98.tar.gz
tar xf libunwind-0.98.tar.gz
cd libunwind-0.98
./configure && make && make install
#安装google-perftools
wget https://github.com/gperftools/gperftools/releases/download/gperftools-2.4/gperftools-2.4.tar.gz
tar xf gperftools-2.4.tar.gz
cd gperftools-2.4
./configure --enable-frame-pointers
make && make install
#为google-perftools添加线程目录
mkdir /tmp/tcmalloc
chmod 0777 /tmp/tcmalloc
#下载Tengine最新稳定版本
wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
#解压
tar xf tengine-2.1.2.tar.gz
cd tengine-2.1.2
#修改nginx.h,以隐藏版本信息
sed -i "12 s/1006002/1000001/g" src/core/nginx.h
sed -i "13 s/1.6.2/1.0.0/g" src/core/nginx.h
sed -i "14 s/nginx/webserver/g" src/core/nginx.h
sed -i "16 s/\"Tengine\"/\"X\"/g" src/core/nginx.h
sed -i "17 s/2001002/2000000/g" src/core/nginx.h
sed -i "18 s/2.1.2/2.0.0/g" src/core/nginx.h
sed -i "21 s/\"NGINX\"/\"X\"/g" src/core/nginx.h
sed -i "s/\/usr\/local/\/usr\/local\/gacp\/gperftools/g" auto/lib/google-perftools/conf
#添加运行用户
useradd -s /sbin/nologin apache
#创建相应目录
mkdir -p /usr/local/gacp/nginx
mkdir -p /data/logs/nginx/{access,error}
#编译安装
./configure \
--user=apache \
--group=users \
--prefix=/usr/local/gacp/nginx \
--error-log-path=/data/logs/nginx/error/error.log \
--http-log-path=/data/logs/nginx/access/access.log \
--pid-path=/usr/local/gacp/nginx/conf/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-http_realip_module \
--with-http_gzip_static_module \
--with-google_perftools_module \
--with-file-aio
make
make install
#配置文件nginx.conf
user apache;
worker_processes 12;
worker_rlimit_nofile 65535;
pid conf/nginx.pid;
google_perftools_profiles /tmp/tcmalloc;
error_log /data/logs/nginx/error/error.log crit;
events {
use epoll;
worker_connections 20960;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$upstream_addr $upstream_response_time $upstream_status';
access_log off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
keepalive_timeout 60;
include gzip.types;
include server.types;
include upstream.conf;
include vhosts.d/*.conf;
}
#配置文件gzip.types
zip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 5;
gzip_types text/plain application/x-javascript text/css text/xml image/jpeg image/gif image/png;
gzip_vary on;
#配置文件server.types
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
server_names_hash_bucket_size 128;
client_max_body_size 8m;
open_file_cache max=10240 inactive=60s;
open_file_cache_valid 30s;
open_file_cache_min_uses 1;
proxy_headers_hash_max_size 512;
proxy_headers_hash_bucket_size 64;
#配置文件flb_params
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;
proxy_next_upstream error timeout invalid_header http_502 http_504;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#配置文件upstream.conf
#负载均衡
#1、轮询(默认)
#每个请求按时间顺序逐一分配到不同的后端服务器,如果后端服务器down掉,能自动剔除。
#2、weight
#指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。
#例如:
#upstream bakend {
#server 192.168.0.1 weight=10;
#server 192.168.0.2 weight=10;
#}
#3、ip_hash
#每个请求按访问ip的hash结果分配,这样每个访客固定访问一个后端服务器。
#例如:
#upstream bakend {
#ip_hash;
#server 192.168.0.1:88;
#server 192.168.0.2:80;
#}
#每个设备的状态设置为:
#1.down 表示单前的server暂时不参与负载
#2.weight 默认为1.weight越大,负载的权重就越大。
#3.max_fails :允许请求失败的次数默认为1.当超过最大次数时,返回proxy_next_upstream 模块定义的错误
#4.fail_timeout:max_fails次失败后,暂停的时间。
#5.backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。所以这台机器压力会最轻。
#6.check interval=3000 rise=2 fall=2 timeout=1000 type=http;用于自动判断后端是否可用。
#####
upstream web_server
{
check interval=3000 rise=2 fall=2 timeout=1000 type=http;
server 1.1.1.1 max_fails=2 fail_timeout=30s;
server 2.2.2.2 max_fails=2 fail_timeout=30s;
ip_hash;
}
#配置文件proxy.vipbet.com.conf
server {
listen 58080;
server_name proxy.vipbet.com;
access_log /data/logs/nginx/access/proxy.vipbet.com.access.log main;
error_log /data/logs/nginx/error/proxy.vipbet.com.error.log;
location /
{
proxy_pass http://web_server;
include flb_params;
}
}
#更改目录用户组
chown -R apache.apache /usr/local/gacp/nginx
#启动脚本:cat /etc/init.d/nginx
#!/bin/bash
#
# nginx - this script starts and stops the nginx daemon #
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
TENGINE_HOME="/usr/local/gacp/nginx/"
#这里修改nginx的路径 nginx=$TENGINE_HOME"sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE=$TENGINE_HOME"conf/nginx.conf"
[ -f /etc/sysconfig/nginx ] && /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
killall -9 nginx
}
restart() {
test || return $?
stop
sleep 1
start
}
reload() {
test || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
test() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|test)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|test}"
exit 2
esac
#chmod +x /etc/init.d/nginx
#service nginx start
#报错/lib/lsb/init-functions: No such file or directory
yum install redhat-lsb
#报错error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory
查看libprofiler.so.0是否存在:whereis libprofiler.so.0
libprofiler.so: /usr/local/lib/libprofiler.so /usr/local/lib/libprofiler.so.0
添加动态库路径: vi /etc/ld.so.conf.d/extend.conf
/usr/local/lib
装载动态库:ldconfig
#service nginx start
#####查看nginx进程
ps aux|grep nginx
#####查看google_perftools_profiles
lsof -n | grep tcmalloc
Tengine安装配置的更多相关文章
- Tengine 安装配置全过程
Tengine官网上有个非常简单的教程,中间并未涉及到一些常用的设置,所以仅供参考.一下午为本人的安装步骤及过程. 1.安装必要的编译环境好 由于Tengine安装需要使用源代码自行编译,所以在安装前 ...
- Tengine 安装配置全过程(nginx 同理)
1.安装必要的编译环境好 yum update yum install gcc gcc-c++ autoconf automake 2.安装需要的组件 A.PCRE PCRE(Perl Compati ...
- Tengine 2.1.2 (nginx/1.6.2)安装配置,淘宝 Web 服务器
简介 Tengine是由淘宝网发起的Web服务器项目.它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性.Tengine的性能和稳定性已经在大型的网站如淘宝网,天猫商城等得到了很 ...
- 分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)——第一篇
分布式文件系统 FastDFS 5.0.5 & Linux CentOS 7 安装配置(单点安装)--第一篇 简介 首先简单了解一下基础概念,FastDFS是一个开源的轻量级分布式文件系统,由 ...
- Nginx 安装 配置 使用
Nginx 安装 配置 使用 基本的HTTP服务器特性 处理静态文件,索引文件以及自动索引:打开文件描述符缓存(缓存元数据和文件描述符,下一次可以直接从内存找到数据或者文件的位置): 使用缓存加速反向 ...
- Tengine安装(阿里baba的)-Nginx
在先前的文章中介绍过Tengine,先前只是使用了运维人员配置好的内容,未自己进行过安装配置.周末闲来无事,对于Tengine进行了尝试性的安装.记录下面方便以后再做改进. Tengine官网上有个非 ...
- linux下tengine安装
1.什么是tengine? 说到tengine,首先还是得说下nginx了,大家对于nginx并不陌生,对于基本的需求都能满足,如果是涉及高级性能,那么就必须使用商用版nginx plus了,一谈到商 ...
- 记录:CentOS 7 安装配置分布式文件系统 FastDFS 5.1.1
CentOS 7 安装配置分布式文件系统 FastDFS 5.1.1 软件下载:http://download.csdn.net/download/qingchunwuxian1993/9897458 ...
- CentOS 7 安装配置分布式文件系统 FastDFS 5.0.5
前言 项目中用到文件服务器,有朋友推荐用FastDFS,所以就了解学习了一番,感觉确实颇为强大,在此再次感谢淘宝资深架构师余庆大神开源了如此优秀的轻量级分布式文件系统,本篇文章就记录一下FastDFS ...
随机推荐
- 【转】APP的缓存文件到底应该存在哪?看完这篇文章你应该就自己清楚了
只要是需要进行联网获取数据的APP,那么不管是版本更新,还是图片缓存,都会在本地产生缓存文件.那么,这些缓存文件到底放在什地方合适呢?系统有没有给我们提供建议的缓存位置呢?不同的缓存位置有什么不同呢? ...
- rsa加密--选择padding模式需要注意的问题。。。
最近在做一个项目中需要,在android对一个密码字段首先进行 一次md5加密后再进行一次rsa加密,然后把加密的结果通过 json协议传输给nginx服务器进行解密.在android中,可以直接 使 ...
- easyui中对于dialog页面传值的接收
dialog的功能是将B页面嵌入至A页面,这样,A页面作为B页面的父容器,所有的元素均可以被B页面访问 那么问题来了:我怎么获取B页面的链接参数呢? 其实很简单,只要找到B页面的存放容器即可: 代码如 ...
- js字符串函数之substring() substr()
substring 方法用于提取字符串中介于两个指定下标之间的字符 substring(start,end) 开始和结束的位置,从零开始的索引 参数 描述start 必需.一个非负的整 ...
- [redis] Jedis 与 ShardedJedis 设计
Jedis设计 Jedis作为推荐的java语言redis客户端,其抽象封装为三部分: 对象池设计:Pool,JedisPool,GenericObjectPool,BasePoolableObjec ...
- Flask+mongodb 实现简易个人博客
最近学习完了<flask-web开发>,实现了一个简易的个人博客网站,由flask+mongodb+bootstrap做成, 这个软件是在阅读<Flask-Web开发>后写的一 ...
- springmvc:BeanNameViewResolver访问内部资源视图对象和访问外部资源视图对象
<!-- 处理器映射器 --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerM ...
- 如何查看,关闭和开启selinux
以下介绍一下SELinux相关的工具/usr/bin/setenforce 修改SELinux的实时运行模式setenforce 1 设置SELinux 成为enforcing模式setenforce ...
- python 将数据随机分为训练集和测试集
# -*- coding: utf-8 -*- """ Created on Tue Jun 23 15:24:19 2015 @author: hd "&qu ...
- C语言指针(一)
一.指针 定义指针变量 指针指向的数据类型 *指针变量名称; 例: int *p; *作用: 1.在定义变量的时候 * 是一个类型说明符,说明定义的这个变量是一个指针变量 2.在不是定义变量的时候 * ...