当前位置: 首页 > 新闻动态 > 技术教程

openresty怎么替换nginx

作者:WBOY 浏览: 发布日期:2023-05-16
[导读]:OpenResty又被称为ngx_openresty,是基于Nginx的核心Web应用程序服务器,OpenResty是基于Nginx和Lua的高性能Web平台,OpenResty通过汇聚各种设计精良的Nginx模块,从而将Nginx有效地变成一个强大的通用Web应用平台。下载openrestywgethttps://openresty.org/download/openresty-1.15.8.1.tar.gztarzxvfopenresty-1.15.8.1.tar.gzcdopenresty

openresty又被称为ngx_openresty,是基于nginx的核心web应用程序服务器,openresty是基于nginx和lua的高性能web平台,openresty通过汇聚各种设计精良的nginx模块,从而将nginx有效地变成一个强大的通用web应用平台。

下载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.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS 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
免责声明:转载请注明出处:http://sczxchw.cn/news/169327.html

扫一扫高效沟通

多一份参考总有益处

免费领取网站策划SEO优化策划方案

请填写下方表单,我们会尽快与您联系
感谢您的咨询,我们会尽快给您回复!