Tengine是由淘寶網發起的Web服務器項目。它在Nginx的基礎上,針對大訪問量網站的需求,添加了不少高級功能和特性。Tengine的性能和穩定性已經在大型的網站如淘寶網,天貓商城等獲得了很好的檢驗。它的最終目標是打造一個高效、穩定、安全、易用的Web平臺。nginx
1.安裝tenginevim
1.1.準備安裝centos
[root@centos ~]# cd /usr/local/src/安全
下載 pcre-8.35.tar.gz到/usr/local/src服務器
[root@centos ~]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gzcurl
下載zlib-1.2.8.tar.gz到/usr/local/src性能
[root@centos ~]# wget http://zlib.net/zlib-1.2.8.tar.gz測試
下載 openssl-1.0.1h.tar.gz到/usr/local/src網站
[root@centos ~]# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gzurl
下載jemalloc-3.6.0.tar.bz2到/usr/local/src
[root@centos ~]# wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2
下載 tengine-2.0.3.tar.gz到/usr/local/src
[root@centos ~]# wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz
2.2 更新包
[root@centos ~]# yum install zlib-devel openssl-devel -y
2.3 安裝Pcre
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf pcre-8.35.tar.gz
[root@centos ~]# cd pcre-8.35
[root@centos ~]# ./configure
[root@centos ~]# make && make install
2.4 安裝openssl
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf openssl-1.0.1h.tar.gz
[root@centos ~]# cd openssl-1.0.1h
[root@centos ~]# ./config
[root@centos ~]# make && make install
2.5 安裝zlib
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zlib-1.2.8.tar.gz
[root@centos ~]# cd zlib-1.2.8
[root@centos ~]# ./configure
[root@centos ~]# make && make install
2.6 安裝jemalloc
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf jemalloc-3.6.0.tar.bz2
[root@centos ~]# cd jemalloc-3.6.0
[root@centos ~]# ./configure
[root@centos ~]# make && make install
[root@centos ~]# echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
[root@centos ~]# ldconfig
4.4 建立www用戶和組,建立www虛擬主機使用的目錄,以及Nginx使用的日誌目錄,而且賦予他們適當的權限
[root@centos ~]# groupadd www
[root@centos ~]# useradd -g www www
[root@centos ~]# mkdir -p /data/www
[root@centos ~]# chmod +w /data/www
[root@centos ~]# chown -R www:www /data/www
4.5 安裝tengine
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# tar zvxf /tengine-2.2.0.tar.gz
假裝服務器信息(能夠不修改)
[root@centos ~]# cd nginx-1.6.0/src/core
[root@centos ~]# vim ./src/core/nginx.h
修改NGINX_VERSION爲你但願顯示的版號
修改NGINX_VER爲你但願顯示的名稱
修改NGINX_VAR 爲你但願顯示的名稱
開始安裝tengine
./configure --prefix=/data/nginx --user=www --group=www --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_concat_module --with-pcre=/root/pcre-8.36 --with-zlib=/root/zlib-1.2.8 --with-http_ssl_module --with-jemalloc
[root@centos ~]# make && make install
測試和運行
[root@centos ~]# cd /opt/nginx
[root@centos ~]# ldconfig
[root@centos ~]# ./sbin/nginx -t
若是顯示下面信息,即表示配置沒問題
nginx: the configuration file /opt/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/nginx/conf/nginx.conf test is successful
輸入代碼運行nginx服務
[root@centos ~]# ./sbin/nginx
[root@centos ~]# ps au|grep nginx
若是顯以相似下面的信息,即表示nginx已經啓動
root 2013 0.0 0.0 103156 856 pts/0 S+ 03:22 0:00 grep nginx
輸入代碼檢測是否支持加速
查看是否生效
[root@centos ~]# lsof -n | grep jemalloc
ginx 2346 root mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1
nginx 2347 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1
nginx 2348 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1
nginx 2349 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1
nginx 2350 www mem REG 253,1 1824470 51571788 /usr/local/lib/libjemalloc.so.1
[root@centos ~]# curl http://localhost
做爲服務,開機後啓動
[root@centos ~]# vim /usr/lib/systemd/system/tengine.service
增長如下內容
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
:wq 保存退出
[root@centos ~]# systemctl stop tengine
[root@centos ~]# systemctl start tengine
[root@centos ~]# systemctl reload tengine
[root@centos ~]# systemctl enable tengine
[root@centos ~]# shutdown -r now