教你如何用openresty完美替换nginx

导读 本文教你如何用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的编译配置

八宿网站制作公司哪家好,找创新互联公司!从网页设计、网站建设、微信开发、APP开发、成都响应式网站建设公司等网站项目制作,到程序开发,运营维护。创新互联公司于2013年开始到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选创新互联公司

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

编辑:周晓雪,


文章题目:教你如何用openresty完美替换nginx
转载来于:http://lszwz.com/article/pgssho.html

其他资讯

售后响应及时

7×24小时客服热线

数据备份

更安全、更高效、更稳定

价格公道精准

项目经理精准报价不弄虚作假

合作无风险

重合同讲信誉,无效全额退款