阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

205次阅读
没有评论

共计 5008 个字符,预计需要花费 13 分钟才能阅读完成。

据说淘宝的 Tengine 很牛 X,所以我们今天也来玩玩,我们这里是某开放云的 vps,现在已经安装好了 Nginx,现在我们要在 CentOS 下平滑切换到安装 Tengine。

  • 下载 Tengine,解压进入文件夹:

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

tar xvfz tengine-2.1.0.tar.gz

cd tengine-2.1.0

  • 查看一下当前的 nginx 版本:

nginx -V

运行结果如下:

nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
TLS SNI support enabled
configure arguments: –prefix=/etc/nginx –sbin-path=/usr/sbin/nginx –conf-path=/etc/nginx/nginx.conf –error-log-path=/var/log/nginx/error.log –http-log-path=/var/log/nginx/access.log –pid-path=/var/run/nginx.pid –lock-path=/var/run/nginx.lock –http-client-body-temp-path=/var/cache/nginx/client_temp –http-proxy-temp-path=/var/cache/nginx/proxy_temp –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp –http-scgi-temp-path=/var/cache/nginx/scgi_temp –user=nginx –group=nginx –with-http_ssl_module –with-http_realip_module –with-http_addition_module –with-http_sub_module –with-http_dav_module –with-http_flv_module –with-http_mp4_module –with-http_gunzip_module –with-http_gzip_static_module –with-http_random_index_module –with-http_secure_link_module –with-http_stub_status_module –with-http_auth_request_module –with-mail –with-mail_ssl_module –with-file-aio –with-ipv6 –with-http_spdy_module –with-cc-opt=’-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables’

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

然后我们复制一下下面的编译参数 configure arguments: 开始一直到最后。

  • 开始编译 Tengine,运行代码:

./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'

结果错误,如下图所示:

./configure: error: C compiler cc is not found

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

主要是我们系统里面没有 C 语言,现在补上 gcc 编译环境:

yum install gcc

重新运行编译命令,依然报错:

./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.

缺少 pcre,安装 pcre:

yum install pcre-devel

再次编译,结果如下图,缺少 openssl:

./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.

 

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

安装 openssl:

yum -y install openssl openssl-devel

再次编译成功,返回:

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

nginx path prefix:“/etc/nginx”
nginx binary file:“/usr/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/cache/nginx/client_temp”
nginx dso module path:“/etc/nginx/modules/”
nginx http proxy temporary files:“/var/cache/nginx/proxy_temp”
nginx http fastcgi temporary files:“/var/cache/nginx/fastcgi_temp”
nginx http uwsgi temporary files:“/var/cache/nginx/uwsgi_temp”
nginx http scgi temporary files:“/var/cache/nginx/scgi_temp”

MAKE,命令行里直接打 make 就行了,如下图:

make

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

make 成功,则如下图所示:

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

  • nginx 停止运行:

/etc/init.d/nginx stop

  • 迁移文件:

复制 objs 目录下的 nginx 文件到 /usr/sbin/nginx 目录,覆盖前记得备份原来文件:

cp /usr/sbin/nginx /usr/sbin/nginx.bak
cp objs/nginx /usr/sbin/

  • 测试一下 nginx:

 nginx -t

the configuration file /etc/nginx/nginx.conf syntax is ok
configuration file /etc/nginx/nginx.conf test is successful

  • 启动 nginx 服务:

service nginx start

Starting nginx:                                            [OK]

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

测试 Tengine 是否成功:

我们这里输入一个不存在的页面看看报错就知道了,如下图所示:

CentOS 下 yum 安装 Nginx 平滑切换安装到 Tengine

Tegine 是兼容 nginx 配置文件的,所以我们原先配置好的东西就不用再麻烦去修改啦。

相关阅读

CentOS 6.4 制作 Tengine 的 rpm 包 http://www.linuxidc.com/Linux/2013-12/93786.htm

CentOS 6.5 安装配置 Tengine  http://www.linuxidc.com/Linux/2015-09/123075.htm

Tengine 动态开启模块试用 http://www.linuxidc.com/Linux/2012-12/75849.htm

CentOS 6.3 用 ICC 编译 PHP5.4.8+Percona5.5.27+Tengine1.4.1 http://www.linuxidc.com/Linux/2012-12/76636.htm

基于淘宝 Tengine 和 Scribe 的 WEB 日志收集方案 http://www.linuxidc.com/Linux/2012-02/52997.htm

基于 Tengine 部署 LNMP 环境 http://www.linuxidc.com/Linux/2014-01/95148.htm

Tengine 的详细介绍 :请点这里
Tengine 的下载地址 :请点这里

本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-01/127908.htm

正文完
星哥玩云-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计5008字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中