下載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
查看當(dāng)前Nginx的編譯配置
nginx -V
如下所示,"configure arguments"就是編譯nginx時(shí)的配置
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平臺(tái)可能占用了make命令,在linux系統(tǒng)下不用考慮這個(gè)問題。GNU,在Unix系統(tǒng)發(fā)明后,開始出現(xiàn)閉源收費(fèi)軟件,于是有人發(fā)起了自由軟件的計(jì)劃,即GNU計(jì)劃,宣揚(yáng)開源精神,編輯器Emacs和編譯器GCC就屬于GNU下的項(xiàng)目,但是GNU下缺少系統(tǒng)內(nèi)核,后來(lái)機(jī)緣巧合地與Linux進(jìn)行了合作,發(fā)布了GNU/Linux。
更換配置文件
把原有nginx配置文件移動(dòng)到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
啟動(dòng)openresty
/usr/local/openresty/bin/openresty
如果提示"nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl"",原因是nginx1.15版本及以后已經(jīng)不需要使用ssl on命令了,可以去掉。
軟鏈接到bin目錄
如果覺得命令使用不方便可以直接軟鏈接到bin目錄,并改名為nginx
ln -s /usr/local/openresty/bin/openresty /usr/local/bin/nginx
轉(zhuǎn)自:https://www.linuxprobe.com/openresty-nginx.html