从Nginx切换到Tengine的步骤分享
更新时间:2016年1月27日 20:15 点击:1524
从Nginx切换到Tengine主要是因为 concat 模块(合并js、css),以及动态加载模块功能(DSO)。
如果已经用apt-get方式安装了Nginx,可以尝试以下步骤以切换到Tengine(不需要卸载Nginx):
1. 到官方下载你喜欢的Tengine版本,这里以最新版(1.4.0)为例,
wget http://tengine.taobao.org/download/tengine-1.4.0.tar.gz
2. 解压缩:
tar -xvzf tengine-1.4.0.tar.gz
3. 进入解压出来的文件夹:
cd tengine-1.4.0/
4. 查看当前Nginx的编译参数:
nginx -V
得到结果如下:
nginx: nginx version: nginx/1.0.5
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-upstream-fair
5. 根据上面第三行的配置编译Tengine,具体做法:从--prefix=/etc/nginx开始复制第三行的代码,然后在--with-debug后面加上--with-http_concat_module(意前后需要有空格),并删掉从--add-module开始的代码(否则会编译不过),完整的编译脚本如下:
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_concat_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module
如果编译中出现类似下面的错误,说明编译依赖模块不存在,你可以选择安装或者如果你不需要这个模块的话,从上面的编译脚本中删除后再一次执行编译脚本,直到编译完成:
这里提示XSLT模块不存在,在上面的编译脚本中搜索xslt,找到了--with-http_xslt_module,删除就可以了,同样注意前后的空格。
成功后提示如下(其中的路径是跟编译脚本有关的,所以可能会略有不同):
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/etc/nginx"
nginx binary file: "/etc/nginx/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx dso module path: "/etc/nginx/modules"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/scgi"
6. 继续编译(make就可以了,不需要make install):
make
7. 到objs目录下编译好的nginx文件:
8. 停止nginx:
9. 复制objs目录下的nginx文件到/usr/sbin/nginx目录,覆盖前记得备份原来文件:
9. 测试nginx是否正常(/user/sbin目录):
如果出现syntax is ok,test is successful表示成功:
10. 重新启动nginx
service nginx start
访问服务器上一个不存在的页面,查看服务器是否是Tengine
403 Forbidden
You don't have permission to access the URL on this server. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
URL: http://10.20.131.181/doc
Server: ubuntu-bak
Date: 2012/10/06 17:54:53
Powered by Tengine/1.4.0
注意看最后一行:Powered by Tengine/1.4.0 表示我们已经成功从Nginx切换到了Tengine
如果已经用apt-get方式安装了Nginx,可以尝试以下步骤以切换到Tengine(不需要卸载Nginx):
1. 到官方下载你喜欢的Tengine版本,这里以最新版(1.4.0)为例,
复制代码 代码如下:
wget http://tengine.taobao.org/download/tengine-1.4.0.tar.gz
2. 解压缩:
复制代码 代码如下:
tar -xvzf tengine-1.4.0.tar.gz
3. 进入解压出来的文件夹:
复制代码 代码如下:
cd tengine-1.4.0/
4. 查看当前Nginx的编译参数:
复制代码 代码如下:
nginx -V
得到结果如下:
复制代码 代码如下:
nginx: nginx version: nginx/1.0.5
nginx: TLS SNI support enabled
nginx: configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-echo --add-module=/build/buildd/nginx-1.0.5/debian/modules/nginx-upstream-fair
5. 根据上面第三行的配置编译Tengine,具体做法:从--prefix=/etc/nginx开始复制第三行的代码,然后在--with-debug后面加上--with-http_concat_module(意前后需要有空格),并删掉从--add-module开始的代码(否则会编译不过),完整的编译脚本如下:
复制代码 代码如下:
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_concat_module --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module
如果编译中出现类似下面的错误,说明编译依赖模块不存在,你可以选择安装或者如果你不需要这个模块的话,从上面的编译脚本中删除后再一次执行编译脚本,直到编译完成:
复制代码 代码如下:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
libraries. You can either do not enable the module or install the libraries.
libraries. You can either do not enable the module or install the libraries.
这里提示XSLT模块不存在,在上面的编译脚本中搜索xslt,找到了--with-http_xslt_module,删除就可以了,同样注意前后的空格。
成功后提示如下(其中的路径是跟编译脚本有关的,所以可能会略有不同):
复制代码 代码如下:
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using system zlib library
nginx path prefix: "/etc/nginx"
nginx binary file: "/etc/nginx/sbin/nginx"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/var/log/nginx/error.log"
nginx http access log file: "/var/log/nginx/access.log"
nginx http client request body temporary files: "/var/lib/nginx/body"
nginx dso module path: "/etc/nginx/modules"
nginx http proxy temporary files: "/var/lib/nginx/proxy"
nginx http fastcgi temporary files: "/var/lib/nginx/fastcgi"
nginx http uwsgi temporary files: "/var/lib/nginx/uwsgi"
nginx http scgi temporary files: "/var/lib/nginx/scgi"
6. 继续编译(make就可以了,不需要make install):
复制代码 代码如下:
make
7. 到objs目录下编译好的nginx文件:
复制代码 代码如下:
cd objs/
8. 停止nginx:
复制代码 代码如下:
service nginx stop
9. 复制objs目录下的nginx文件到/usr/sbin/nginx目录,覆盖前记得备份原来文件:
复制代码 代码如下:
cp /usr/sbin/nginx /usr/sbin/nginx.bak
cp nginx /usr/sbin/
cp nginx /usr/sbin/
9. 测试nginx是否正常(/user/sbin目录):
复制代码 代码如下:
nginx -t
如果出现syntax is ok,test is successful表示成功:
复制代码 代码如下:
the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful
configuration file /etc/nginx/nginx.conf test is successful
10. 重新启动nginx
复制代码 代码如下:
service nginx start
访问服务器上一个不存在的页面,查看服务器是否是Tengine
复制代码 代码如下:
403 Forbidden
You don't have permission to access the URL on this server. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
URL: http://10.20.131.181/doc
Server: ubuntu-bak
Date: 2012/10/06 17:54:53
Powered by Tengine/1.4.0
注意看最后一行:Powered by Tengine/1.4.0 表示我们已经成功从Nginx切换到了Tengine
相关文章
详解nginx同一端口监听多个域名和同时监听http与https
这篇文章主要介绍了详解nginx同一端口监听多个域名和同时监听http与https的相关资料,需要的朋友可以参考下...2017-07-06- 这篇文章主要介绍了Nginx根据不同浏览器语言配置页面跳转的方法,包括一个简体繁体的基本判断方法及实际根据中英文跳转的例子,需要的朋友可以参考下...2016-05-22
- 周一今天给大家分享shell脚本多实例部署nginx的详细教程,文章通过实例代码脚本给大家详细介绍,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧...2021-10-26
- 这篇文章主要介绍了Nginx中配置过滤爬虫的User-Agent的简单方法,文中罗列了一些常用搜索引擎的爬虫名称以免造成不必要的过滤,需要的朋友可以参考下...2016-01-27
- 这篇文章主要介绍了nginx配置引发的403问题解决办法的相关资料,需要的朋友可以参考下...2017-07-06
- 这篇文章主要介绍了Linux环境下nginx搭建简易图片服务器,需要的朋友可以参考下...2016-01-27
- 这篇文章主要介绍了Nginx访问日志及错误日志参数说明,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下...2020-11-14
- 这篇文章主要介绍了使用nginx方式实现http转换为https的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2020-09-06
Nginx反向代理proxy_cache_path directive is not allowed错误解决方法
这篇文章主要介绍了Nginx反向代理proxy_cache_path directive is not allowed错误解决方法,需要的朋友可以参考下...2016-01-27nginx+apache+mysql+php+memcached+squid搭建集群web环境
当前,LAMP开发模式是WEB开发的首选,如何搭建一个高效、可靠、稳定的WEB服务器一直是个热门主题,本文就是这个主题的一次尝试。...2016-01-27- Nginx日志主要分为两种:访问日志和错误日志。访问日志主要记录客户端访问Nginx的每一个请求,格式可以自定义。下面这篇文章主要给大家介绍了Nginx自定义访问日志的配置方式,需要的朋友可以参考学习,下面来一起看看吧。...2017-07-06
- 这篇文章主要介绍了nginx使用IPV6的相关配置项介绍,首先查看编译参数是否编译了IPV6模块,然后介绍了监听IPV6的配置语法,需要的朋友可以参考下...2016-01-27
解决使用了nginx获取IP地址都是127.0.0.1 的问题
这篇文章主要介绍了解决使用了nginx获取IP地址都是127.0.0.1 的问题,获取i工具的完整代码文中给大家提到,具体实例代码跟随小编一起看看吧...2021-09-18- 本篇文章主要介绍了nginx修改上传文件大小限制的方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧。 ...2017-01-22
- 这篇文章主要介绍了Debian7编译安装nginx简明教程,本文直接给出操作命令和步骤,需要的朋友可以参考下...2016-01-27
- 这篇文章主要介绍了隐藏Nginx或Apache以及PHP的版本号的方法,主要用来防止针对性的漏洞攻击,需要的朋友可以参考下...2016-01-05
- 这篇文章主要介绍了Nginx DNS resolver配置实例,本文讲解在proxy_pass 和 upstream server 通信的时候需要手动指定 resolver,本文就给出了配置实例,需要的朋友可以参考下...2016-01-27
- 这篇文章主要介绍了关于Nginx中if语句的判断条件与多条件判断的相关资料,文中给出了详细的示例代码,对大家具有一定的参考价值,需要的朋友们下面来一起看看吧。...2017-07-06
详解Nginx服务器中配置Sysguard模块预防高负载的方案
这篇文章主要介绍了详解Nginx服务器中配置Sysguard模块预防高负载的方案,该模块由阿里巴巴的团队开发,能够设置负载阀值,比较强大,需要的朋友可以参考下...2016-02-02- 本篇文章主要介绍了nginx实现ssl反向代理实战,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧 ...2017-01-22