教你如何用 openresty 完美替换 nginx

发布时间:2020-08-08 14:09:16 作者:大雄45
来源:ITPUB博客 阅读:259
导读 本文教你如何用openresty完美替换nginx。
下载openresty
wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
tar zxvf openresty-1.15.8.1.tar.gzcd openresty-1.15.8.1
安装openresty

查看当前nginx的编译配置

nginx -V

如下所示,"configure arguments"就是编译nginx时的配置

nginx version: nginx/1.14.0built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017TLS SNI support enabled
configure arguments: --with-http_ssl_module

编译openresty,把刚才的配置加到"configure" 命令后方,如果需要使用lua也可以加上"--with-luajit"

./configure --with-http_ssl_module --with-luajit
gmake && gmake install

gmake即GNU make,使用它的原因是非GNU平台可能占用了make 命令,在 linux系统下不用考虑这个问题。GNU,在Unix系统发明后,开始出现闭源收费软件,于是有人发起了自由软件的计划,即GNU计划,宣扬开源精神,编辑器Emacs和编译器GCC就属于GNU下的项目,但是GNU下缺少系统内核,后来机缘巧合地与 Linux进行了合作,发布了GNU/Linux。

更换配置文件

把原有nginx配置文件移动到openresty目录

mv /usr/local/nginx/conf/*.conf /usr/local/openresty/conf
mv /usr/local/nginx/conf/conf.d /usr/local/openresty/conf
停止原nginx
nginx -s stop
启动openresty
/usr/local/openresty/bin/openresty

如果提示"nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl"",原因是nginx1.15版本及以后已经不需要使用ssl on命令了,可以去掉。

软链接到bin目录

如果觉得命令使用不方便可以直接软链接到bin目录,并改名为nginx

ln -s /usr/local/openresty/bin/openresty /usr/local/bin/nginx

原文来自:  https://www.linuxprobe.com/openresty-nginx.html

编辑:周晓雪,

推荐阅读:
  1. 如何用nginx进行反向代理?
  2. 手把手教你写一个通用的helm chart

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

nginx openresty 何用

上一篇:CentOS 7系统设置vsFTPd简单方法介绍

下一篇:oracle数据库逻辑备份

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》