受欢迎的博客标签

How to Install Tengine on Ubuntu 18.04 Step by Step?(aliyun)

Published

Tengine,nginx come from taobao.

To install Tengine, just follow these  steps:

#dowanload  tengine-2.3.2.tar.gz
#unzip  tengine-2.3.2.tar.gz  to ./tengine-2.3.2
#cd tengine-2.3.2
(安装过程会报错提示你安装一些依赖包)

#./configure
#make
# make install

 

1、下载淘宝版nginx

sudo wget http://tengine.taobao.org/download/tengine-2.3.2.tar.gz

Offical web site download url:https://tengine.taobao.org/download.html

2、解压

sudo tar -zxvf tengine-2.3.2.tar.gz

 

3、更新升级apt-get

sudo apt-get update
sudo apt-get upgrade

 

4、安装依赖库

1)PCRE 库

PCRE(Perl Compatible Regular Expressions)是一个 Perl 库,包括 perl 兼容的正则表达式库。nginx rewrite 依赖于 PCRE 库,所以在安装 Tengine 前一定要先安装 PCRE。

sudo apt-get install libpcre3 libpcre3-dev

2)Zlib 库

Zlib 是提供资料压缩用的函数库,当 Tengine 想启用 gzip 压缩的时候就需要使用到 Zlib。

sudo apt-get install zlib1g-dev

3)OpenSSL 库

OpenSSL 是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。安装 OpenSSL 主要是为了让 Tengine 支持 HTTPS 的访问请求。

sudo apt-get install openssl libssl-dev

 

5、生成makefile

cd tengine-2.3.2
sudo ./configure --with-http_v2_module --add-module=modules/ngx_http_upstream_check_module

这里选择了编译 HTTP/2 需要的 ngx_http_v2_module 模块。Tengine 默认将安装在 /usr/local/nginx 目录。你可以用 --prefix 来指定你想要的安装目录。

 

6、编译安装

sudo make
sudo make install

 

7、开机自启动

sudo vim /lib/systemd/system/nginx.service

 nginx.service内添加以下内容:

Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target
 

使配置生效

sudo systemctl daemon-reload

设置开机启动

sudo systemctl enable nginx.service

 

8、运行tengine

1)启动

sudo /usr/local/nginx/sbin/nginx
或者
sudo systemctl start nginx.service
 
# sudo systemctl status nginx.service
● nginx.service
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2021-08-30 00:43:00 CST; 27s ago
  Process: 379 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 528 (nginx)
    Tasks: 2 (limit: 474)
   CGroup: /system.slice/nginx.service
           ├─528 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           └─529 nginx: worker process

Aug 30 00:42:59 iZj6c10zjner0nfuo9rb5vZ systemd[1]: Starting nginx.service...
Aug 30 00:43:00 iZj6c10zjner0nfuo9rb5vZ systemd[1]: Started nginx.service.

 2)重启

sudo /usr/local/nginx/sbin/nginx -s reload
或者
sudo systemctl restart  nginx.service

3)停止

sudo /usr/local/nginx/sbin/nginx -s stop
或者
sudo systemctl stop nginx.service

9、是否启动成功,默认80端口,访问地址:http://ip:port/

 

Welcome to tengine!
If you see this page, the tengine web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to tengine.taobao.org.

Thank you for using tengine.