简介
Tengine是由淘宝网发起的Web服务器项目。它在Nginx的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。官网
准备
- 下载:http://tengine.taobao.org/download_cn.html 下载 Tengine-2.x.x.tar.gz 的文件
- 系统环境 根据需要的功能模块,需要准备以下软件
yum -y install autoconf automake libtool gcc gcc-c++ openssl openssl-devel
rewrite 需要pcre库 pcre-8.32.tar.gz 官网
gzip 需要zlib库 zlib-1.2.8.tar.gz 官网
ssl 需要openssl 尽量用系统的openssl-devel
lua 需要LuaJIT LuaJIT-2.0.4.tar.gz 官网
lua 需要ngx_devel_kit ngx_devel_kit-0.2.19.tar.gz 官网
lua 需要lua-nginx-module lua-nginx-module-0.9.20.tar.gz 官网
cache 需要 ngx_cache_purge ngx_cache_purge-2.3.tar.gz 官网
echo 需要 echo-nginx-module echo-nginx-module-0.58.tar.gz 官网
geoip 需要 ngx_http_geoip_module ngx_http_geoip2_module-1.0.tar.gz 官网
naxsi 需要 naxsi-core naxsi-0.51-1.tar.gz 官网
jemalloc 需要 jemalloc jemalloc-4.0.4.tar.gz 官网
安装
- pcre
tar xzf pcre-8.32.tar.gz
cd pcre-8.3.2
./configure
make && make install
- zlib
tar xzf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make && make install
- jemalloc
tar xzf jemalloc-4.0.4.tar.gz
cd jemalloc-4.0.4
./autogen.sh
./configure
make && make install
- Tengine
tar xzf tengine-2.1.2.tar.gz
cd tengine-2.1.2
./configure --with-select_module --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_ssl_module --with-http_spdy_module --with-syslog --with-pcre=/usr/local/src/pcre-8.32 --with-jemalloc=/usr/local/src/jemalloc-4.0.4
make && make install
使用
1.设置为服务 保存以下代码到/etc/init.d/nginx
#!/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=/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
2.设置为自启动
chmod 775 /etc/rc.d/init.d/nginx #赋予文件执行权限
chkconfig nginx on #设置开机启动
service nginx restart #启动服务
以上是基本功能,下期介绍常用模块的功能和用法