openresty如何完美替換nginx


下載openresty

wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
tar zxvf openresty-1.15.8.1.tar.gz
cd 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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM