LNMP下Nginx升级至Tengine

发布于 分类 Nginx

更新于 2015-11-09

今天博客seonoco.com的服务器环境从lnmp下的nginx切换为tengine,以下为主要步骤,如果全新安装也可参考本文。

下载Tengine

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

安装必要的软件,避免出错,也许你安装过这些库或者你想跳过这一步,没关系。出错来再回来安装就是了。

yum install gcc gcc-c++ ncurses-devel perl
yum -y install pcre-devel openssl openssl-devel 

大概是哪些错误呢?

./configure: error: C compiler cc is not found
./configure: error: the HTTP rewrite module requires the PCRE library.
./configure: error: SSL modules require the OpenSSL library.

配置与安装

Tengine默认安装是没有http_concat_module模块的,因此需要在configure后面增加该模块。其他以此类推。

由于Nginx在新版本中,使用了标准的 MIME-Type:application/javascript。而在nginx_concat_module模块目前版本的代码中,写的是 application/x-javascript 的类型。

因此,我们在升级之前最好,修改nginx_concat_module的源代码文件tengine-2.1.1/src/http/modules/ngx_http_concat_module.c,将application/x-javascript更改为application/javascript,然后再编译安装即可!不然多个文件的JS会报400错误

./configure --with-http_concat_module
make && make install 

将nginx以前的编译文件备份,使用tengine新编译的nginx

mv /usr/sbin/nginx /usr/sbin/nginx.old-before-tengine
cp -r objs/nginx /usr/sbin/nginx 

重启即可生效。可通过nginx -V查看安装情况

service nginx restart
nginx -V 

备注:ngx_http_concat_module

configure [--with-http_concat_module | --with-http_concat_module=shared]
--with-http_concat_module选项,concat模块将被静态编译到tengine中
--with-http_concat_module=shared,concat模块将被编译成动态文件,采用动态模块的方式添加到tengine中

参考与扩展阅读

http://tengine.taobao.org/

-- The End --

本文标题: LNMP下Nginx升级至Tengine

本文地址: https://seonoco.com/blog/lnmp-nginx-upgrade-to-tengine

本页面显示内容已针对移动端进行优化,点击查看完整版本