How to replace nginx with openresty

WBOY
Release: 2023-05-16 22:10:05
forward
1215 people have browsed it

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
Copy after login

Install openresty

View the current nginx compilation configuration

nginx -V
Copy after login

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
Copy after login

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
Copy after login

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
Copy after login

Stop the original nginx

nginx -s stop
Copy after login

Start openresty

/usr/local/openresty/bin/openresty
Copy after login

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
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template