导读 | 本文教你如何用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。
更换配置文件
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
编辑:周晓雪,
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。