憧憬博客Nginx到Tengine的迁移

时间:2022-07-22
本文章向大家介绍憧憬博客Nginx到Tengine的迁移,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

憧憬博客Nginx到Tengine的迁移

Tengine 是由淘宝网发起的 Web 服务器项目。它在 Nginx 的基础上,针对大访问量网站的需求,添加了很多高级功能和特性。据说 TengineIO 性能比 Nginx 提升了几十倍、淘宝流量高峰全靠 Tengine 应对。 一直在网上听说 Tengine 优秀的性能,淘宝自家都使用的 web server,其稳定性和性能已经在淘宝网,天猫商城等得到了很好的检验。这个时候博主好奇心就来了,非得把博客的 Nginx 迁移到 Tengine 不可,小小体验一下 Tengine

这里就记录一下迁移记录,其实迁移很简单,Tengine基本上继承 Nginx 的所有特性,兼容 Nginx 的配置,所以在迁移上并没花多少时间。

  • 文档资料

http://tengine.taobao.org/document/install.html https://github.com/alibaba/tengine

安装

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

./configure
  • 出错了呀
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

apt-get install libpcre3 libpcre3-dev

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

apt-get install openssl libssl-dev

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

apt-get install zlib1g-dev

找这个 zlib 库的时候比较有意思, zlib 这个包直接安装但是不清楚包名,编译安装下载资源 Not Found,然后看到一个解决问题的思路觉得挺好, 分享给大家: zlib 的官网打不开, apt-get insatll zlib 也找不到软件包,貌似不在软件源里?解决方法是打开 ubuntu software center ,搜索 zlib ,找到 zlib1g-dev 这个包,安装成功。 有些软件包的名字无法确定,可以借助 ubuntu software center 来确定其有效名字,

# 成功弄好配置项 这里的话如果有需要其他模块的 和 nginx是一样的,Tengine 特有的就直接上官网翻资料就可以

./configure

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + using system zlib library
  + jemalloc library is disabled

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"


make

迁移

配置脚本选项大多数选项与Nginx兼容。文档有些Tengine的特定选项,可以查看

默认安装路径 /usr/local/nginx/

因为他直接兼容 nginx,所以我直接把原来的站点引入过来 放入到配置文件

  • vi /usr/local/nginx/conf/nginx.conf
include /etc/nginx/sites-enabled/*;
  • sbin/nginx -t
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/sites-enabled/default:67
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
  • 这里在检测配置的时候有个警告,看了一下 ssl 指令废弃了,如果使用 listen 443 ssl,删除 ssl on 就行了。
listen 443 ssl;
server_name aoppp.com;
#ssl on;