Tengine/Nginx 安裝

一.Tengine是什麼html

簡介

Tengine是由淘寶網發起的Web服務器項目。它在Nginx的基礎上,針對大訪問量網站的需求,添加了不少高級功能和特性。Tengine的性能和穩定性已經在大型的網站如淘寶網天貓商城等獲得了很好的檢驗。它的最終目標是打造一個高效、穩定、安全、易用的Web平臺。

從2011年12月開始,Tengine成爲一個開源項目,Tengine團隊在積極地開發和維護着它。Tengine團隊的核心成員來自於淘寶搜狗等互聯網企業。Tengine是社區合做的成果,咱們歡迎你們參與其中,貢獻本身的力量。nginx

特性


二. 安裝 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安裝完成!

相關文章
相關標籤/搜索