Home  >  Article  >  Operation and Maintenance  >  How to replace nginx with openresty

How to replace nginx with openresty

WBOY
WBOYforward
2023-05-16 22:10:051175browse

OpenResty, also known as ngx_openresty, is a core web application server based on Nginx. OpenResty is a high-performance web platform based on Nginx and Lua. OpenResty uses aggregation Various well-designed Nginx modules effectively turn Nginx into a powerful universal web application platform.

How to replace nginx with openresty

Download 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

Install openresty

View the current nginx compilation configuration

nginx -V

as shown below,” configure arguments" is the configuration when compiling 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

Compile openresty, add the just configuration after the "configure" command, if you need to use lua you can also add "–with-luajit"

./configure --with-http_ssl_module --with-luajit
gmake && gmake install

gmake is GNU make. The reason for using it is that non-GNU platforms may occupy the make command. There is no need to consider this issue under Linux systems. GNU, after the invention of the Unix system, closed source paid software began to appear, so someone launched a free software plan, the GNU plan, to promote the open source spirit. The editor Emacs and the compiler GCC are projects under GNU, but there are few projects under GNU The system kernel later cooperated with Linux by chance and released GNU/Linux.

Change the configuration file

Move the original nginx configuration file to the openresty directory

mv /usr/local/nginx/conf/*.conf /usr/local/openresty/conf
mv /usr/local/nginx/conf/conf.d /usr/local/openresty/conf

Stop the original nginx

nginx -s stop

Start openresty

/usr/local/openresty/bin/openresty

If it prompts "nginx: [warn] the “ssl" directive is deprecated, use the “listen … ssl””, the reason is that nginx version 1.15 and later no longer need to use the ssl on command and can be removed.

Soft link to bin directory

If you find it inconvenient to use the command, you can directly soft link to the bin directory and change its name to nginx

ln -s /usr/local/openresty/bin/openresty /usr/local/bin/nginx

The above is the detailed content of How to replace nginx with openresty. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete