A-A+

Tengine/Nginx安装

2017年01月13日 Tengine 暂无评论 阅读 644 次浏览 次

一.Tengine是什么

简介

Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。Tengine的性能和稳定性已经在大型的网站如淘宝网天猫商城等得到了很好的检验。它的最终目标是打造一个高效、稳定、安全、易用的Web平台。



从2011年12月开始,Tengine成为一个开源项目,Tengine团队在积极地开发和维护着它。Tengine团队的核心成员来自于淘宝搜狗等互联网企业。Tengine是社区合作的成果,我们欢迎大家参与其中,贡献自己的力量。

特性

 

二. 安装 Tengine

2.1 编译环境准备

 yum -y install gcc gcc-c++ autoconf automake wget
 yum -y install zlib zlib-devel openssl openssl-devel pcre-devel pcre gd-devel 
 groupadd nginx
 useradd -g nginx  -s/sbin/nologin -M nginx

zlib:nginx提供gzip模块,需要zlib库支持

openssl:nginx提供ssl功能

pcre:支持地址重写rewrite功能

concat:支持js,CSS的样式文件合并,减少nginx服务器请求链接数

 

 

 

安装jemalloc,优化nginx内存管理

wget http://www.canonware.com/download/jemalloc/jemalloc-4.0.4.tar.bz2
tar xjf jemalloc-4.0.4.tar.bz2
cd jemalloc-4.0.4
./configure
make && make install
echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
ldconfig

2.2编译安装

cd /opt/
wget http://tengine.taobao.org/download/tengine-2.1.2.tar.gz
tar zxvf tengine-2.1.2.tar.gz
cd tengine-2.1.2
./configure  \
--user=nginx \
--group=nginx \
--with-jemalloc \
--prefix=/usr/local/nginx \
--with-http_ssl_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_concat_module \
--with-pcre \
--with-http_sysguard_module \
--with-http_realip_module \
--with-http_image_filter_module
make
make install

2.3启动Tengine

/usr/local/nginx/sbin/nginx

2.4设置Tengine开机启动

cat >> /etc/init.d/nginx <<EOF
#!/bin/bash
# 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=/usr/local/nginx/logs/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 /usr/local/nginx/logs/nginx.pid
}
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
EOF

 

授予执行权限

chmod +x /etc/init.d/nginx
chkconfig nginx --level 345 on

三.测试

3.1 用浏览器访问主机80端口

 

出现如图所示界面即表示Tengine安装完成!

 

标签:

评论已关闭!

Copyright © 香港虚拟主机_美国虚拟主机_香港服务器_美国服务器租用托管 保留所有权利.   Theme  Ality 蜀ICP备14006632号-1

用户登录