centos7 tengine 安装

Posted fengjian1585

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7 tengine 安装相关的知识,希望对你有一定的参考价值。

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

 

 

 

 

1.安装tengine

1.1.准备安装

[[email protected] ~]# cd /usr/local/src/

下载 pcre-8.35.tar.gz到/usr/local/src

[[email protected] ~]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

下载zlib-1.2.8.tar.gz到/usr/local/src

[[email protected] ~]# wget http://zlib.net/zlib-1.2.8.tar.gz

下载 openssl-1.0.1h.tar.gz到/usr/local/src

[[email protected] ~]# wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz

下载jemalloc-3.6.0.tar.bz2到/usr/local/src

[[email protected] ~]#  wget http://www.canonware.com/download/jemalloc/jemalloc-3.6.0.tar.bz2

下载 tengine-2.0.3.tar.gz到/usr/local/src

[[email protected] ~]# wget http://tengine.taobao.org/download/tengine-2.2.0.tar.gz

  

2.2 更新包

[[email protected] ~]# yum install  zlib-devel  openssl-devel -y

 

2.3 安装Pcre

[[email protected] ~]# cd /usr/local/src/

[[email protected] ~]# tar zvxf pcre-8.35.tar.gz

[[email protected] ~]# cd pcre-8.35

[[email protected] ~]# ./configure

[[email protected] ~]# make && make install

 

2.4 安装openssl

[[email protected] ~]# cd /usr/local/src/

[[email protected] ~]# tar zvxf openssl-1.0.1h.tar.gz

[[email protected] ~]# cd openssl-1.0.1h

[[email protected] ~]# ./config

[[email protected] ~]# make && make install

 

2.5 安装zlib

[[email protected] ~]# cd /usr/local/src/

[[email protected] ~]# tar zlib-1.2.8.tar.gz

[[email protected] ~]# cd zlib-1.2.8

[[email protected] ~]# ./configure

[[email protected] ~]# make && make install

 

2.6 安装jemalloc

[[email protected] ~]# cd /usr/local/src/

[[email protected] ~]# tar zvxf jemalloc-3.6.0.tar.bz2

[[email protected] ~]# cd jemalloc-3.6.0

[[email protected] ~]# ./configure

[[email protected] ~]# make && make install

[[email protected] ~]# echo ‘/usr/local/lib‘ > /etc/ld.so.conf.d/local.conf

[[email protected] ~]# ldconfig

 

4.4 创建www用户和组,创建www虚拟主机使用的目录,以及nginx使用的日志目录,并且赋予他们适当的权限

[[email protected] ~]# groupadd www

[[email protected] ~]# useradd -g www www

[[email protected] ~]# mkdir -p /data/www

[[email protected] ~]# chmod +w /data/www

[[email protected] ~]# chown -R www:www /data/www

 

4.5 安装tengine

[[email protected] ~]# cd /usr/local/src/

[[email protected] ~]# tar zvxf /tengine-2.2.0.tar.gz

 

伪装服务器信息(可以不修改)

[[email protected] ~]# cd nginx-1.6.0/src/core

[[email protected] ~]# vim ./src/core/nginx.h

修改NGINX_VERSION为你希望显示的版号

修改NGINX_VER为你希望显示的名称

修改NGINX_VAR 为你希望显示的名称

 

开始安装tengine

./configure --prefix=/opt/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1h --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.35 --with-jemalloc

[[email protected] ~]# make && make install

 

 

 测试和运行

[[email protected] ~]# cd /opt/nginx

[[email protected] ~]# ldconfig

[[email protected] ~]# ./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服务

[[email protected] ~]# ./sbin/nginx 

[[email protected] ~]# ps au|grep nginx

如果显以类似下面的信息,即表示nginx已经启动

root 2013 0.0 0.0 103156 856 pts/0 S+ 03:22 0:00 grep nginx

  

输入代码检测是否支持加速

查看是否生效

[[email protected] ~]# 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

 

[[email protected] ~]# curl http://localhost

 

作为服务,开机后启动

[[email protected] ~]# 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 保存退出

 

 [[email protected] ~]# systemctl stop tengine

 [[email protected] ~]# systemctl start tengine

 [[email protected] ~]# systemctl reload tengine

 [[email protected] ~]# systemctl enable tengine

 [[email protected] ~]# shutdown -r now

以上是关于centos7 tengine 安装的主要内容,如果未能解决你的问题,请参考以下文章

centos7 tengine 安装

CentOS7 源码编译安装Tengine

centos7.x编译安装淘宝tengine-2.1.2

Tengine编译安装

ansible安装nginx (tengine)

CentOS 7.4 Tengine安装配置详解