How To Install OpenResty v1.21.4.1 on CentOS Stream 8

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

OpenResty is free, open-source and full-fledged web platform based on the NGINX web server. It integrates enhanced version of the NGINX core which can run using LuaJIT engine and 3rd-party Nginx modules. OpenResty is build specially for developers to easily create a scalable web applications, web services, and dynamic web gateways. The engineer team behind OpenResty develop various NGINX modules to support all web developers needs.

Please note that OpenResty is not forked version of the NGINX web server. However, it high-level apps and gateway platform which utilize a NGINX as its server components. OpenResty can run a server-side web app in the NGINX, which taking advantages of NGINX event-driven architecture. So, it can utilize non-blocking I/O for the HTTP clients side, and also remote backend server, including MySQL/MariaDB, PostgreSQL, Memcached, and Redis.

OpenResty change NGINX web server become a powerfull web application server, which can use Lua programming language to support various scipts on existing NGINX C and LUA modules. By using OpenResty you can deploy a high-performance web application to handle C10K problems which found on almost all Linux-based OS. Therefore, OpenResty web platform is capable to handle 10K ~ 1000K+ concurrent connection in the single time.

OpenResty is compatible with almost all type of web applications like dynamic web portals and web gateways, web application firewalls, and web service platforms for mobile apps, advertising, distributed storage, as well as, data analytics. In addition, it can support full-fledged dynamic web applications and websites.

OpenResty is a Scalable Web Platform by Extending NGINX with Lua
OpenResty is a Scalable Web Platform by Extending NGINX with Lua

Security patches or bug fixes which applied to NGINX Core in OpenResty mostly submited to the Official NGINX team, and almost all security patches have also been accepted. OpenResty team always import the latests features of the NGINX and its security patch from the official NGINX team, official LuaJIT repository, as well as other sources.

Currently OpenResty is available in the latest stable version 1.21.4.1 based on NGINX and LuaJIT. You can install OpenResty on almost all Linux distribution systems, including Debian/Ubuntu, Fedora, RHEL-based OS (CentOS, Amazon Linux, Rocky Linux, and Oracle Linux), Alpine, as well as OpenSUSE. On today’s guide we will teach you on how to install OpenResty v1.21.4.1 on CentOS Stream 8. So, make sure to meet the following pre-requisites before installing OpenResty web platform.

PRE-REQUISITES:

* VPS, Cloud or Bare-Metal Servers
* OS Distros with CentOS Stream 8
* Superuser Privileges (Root Access)
* Familiar with CLI-Based or Command-Line Only
* Gnome Terminal for Linux Desktop
* PuTTy SSH Client for Windows or Mac
* Powershell for Windows 10/11
* Familiar with DNF-Based Commands

1.) Login to the Server via SSH Terminal

In the step-one we need to login into the server via SSH terminal. Don’t forget to change the server IPv4 address and SSH port with your actual server IPv4 address and SSH port.

$ ssh [email protected] -p22
[email protected]'s password:
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue May 31 20:12:10 2022 from 125.164.235.221

2.) Install Package Dependencies

You need to install some package dependency like wget, nano and curl. Simply using the following command to install them.

$ dnf install wget nano curl -y
DigitalOcean Agent 61 kB/s | 3.3 kB 00:00
DigitalOcean Droplet Agent 39 kB/s | 3.3 kB 00:00
Package curl-7.61.1-18.el8.x86_64 is already installed.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
nano x86_64 2.9.8-1.el8 baseos 581 k
wget x86_64 1.19.5-10.el8 appstream 734 k
Upgrading:
curl x86_64 7.61.1-22.el8 baseos 351 k
libcurl x86_64 7.61.1-22.el8 baseos 301 k
openssl x86_64 1:1.1.1k-6.el8 baseos 709 k
openssl-libs x86_64 1:1.1.1k-6.el8 baseos 1.5 M

Transaction Summary
=====================================================================================================================================================
Install 2 Packages
Upgrade 4 Packages

Total download size: 4.1 M

3.) Add OpenResy Repository to CentOS System

After that you must add OpenResty repository into your CentOS Stream 8. It will make your work more easily whre you can install OpenResty packages, receive software updates and security patches or bug fixes in the future, both using “yum update” or “dnf update” commands. Simply run the following command to add OpenResty repository into your CentOS 8 machine.

READ:  How To Create Nginx Server Block on Debian/Ubuntu Linux

* Move to the directory of yum.repos.d.

$ cd /etc/yum.repos.d/

* Download openresty.repo file.

$ wget https://openresty.org/package/centos/openresty.repo
--2022-05-31 21:19:09-- https://openresty.org/package/centos/openresty.repo
Resolving openresty.org (openresty.org)... 2600:1f1c:9b2:8000:f183:c67e:2c64:855f, 3.131.85.84
Connecting to openresty.org (openresty.org)|2600:1f1c:9b2:8000:f183:c67e:2c64:855f|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 267 [text/plain]
Saving to: ‘openresty.repo’

openresty.repo 100%[======================================================================>] 267 --.-KB/s in 0s

2022-05-31 21:19:10 (142 MB/s) - ‘openresty.repo’ saved [267/267]

* Update the yum or dnf index

$ dnf check-update
Last metadata expiration check: 0:00:19 ago on Tue 31 May 2022 09:21:54 PM UTC.

NetworkManager.x86_64 1:1.39.5-1.el8 baseos
NetworkManager-libnm.x86_64 1:1.39.5-1.el8 baseos
NetworkManager-team.x86_64 1:1.39.5-1.el8 baseos
NetworkManager-tui.x86_64 1:1.39.5-1.el8 baseos
audit.x86_64 3.0.7-4.el8 baseos
audit-libs.x86_64 3.0.7-4.el8 baseos
authselect.x86_64 1.2.2-3.el8 baseos
authselect-compat.x86_64 1.2.2-3.el8 appstream
authselect-libs.x86_64 .............
.............

4.) Install OpenResty v1.21.4.1 Web Platform

In the step four you can execute using the following command to install OpenResty Web Platform on CentOS Stream 8.

$ dnf install openresty
Last metadata expiration check: 0:02:55 ago on Tue 31 May 2022 09:21:54 PM UTC.
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
openresty x86_64 1.21.4.1-1.el8 openresty 1.1 M
Installing dependencies:
openresty-openssl111 x86_64 1.1.1n-1.el8 openresty 1.6 M
openresty-pcre x86_64 8.45-1.el8 openresty 167 k
openresty-zlib x86_64 1.2.12-1.el8 openresty 59 k

Transaction Summary
=====================================================================================================================================================
Install 4 Packages

Total download size: 2.9 M
Installed size: 8.2 M
Is this ok [y/N]: y

You can check on the following screenshots for more detailed information on OpenResty installation.

OpenResty Web Platform Installation Process
OpenResty Web Platform Installation Process

5.) Install Resty Command-Line Utility

Then let’s install openresty-resty package to bring the resty command-line utility into your CentOS 8 machine.

$ dnf install openresty-resty
DigitalOcean Agent 67 kB/s | 3.3 kB 00:00
DigitalOcean Droplet Agent 44 kB/s | 3.3 kB 00:00
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Installing:
openresty-resty noarch 1.21.4.1-1.el8 openresty 18 k
Installing dependencies:
dwz x86_64 0.12-10.el8 appstream 109 k
efi-srpm-macros noarch 3-3.el8 appstream 22 k
ghc-srpm-macros noarch 1.4.2-7.el8 appstream 9.3 k
go-srpm-macros noarch 2-17.el8 appstream 13 k
make x86_64 1:4.2.1-11.el8 baseos 498 k
ocaml-srpm-macros noarch 5-4.el8 appstream 9.4 k

6.) List All OpenResty Packages

OpenResty provide “restydoc” command-line utility in the openresty-doc package, while the openresty-opm package provide opm command-line utility. You can list all available OpenResty package on CentOS 8 using the following command.

$ dnf --disablerepo="*" --enablerepo="openresty" list available
Last metadata expiration check: 0:09:45 ago on Tue 31 May 2022 09:21:54 PM UTC.
Available Packages
openresty-asan.x86_64 1.21.4.1-1.el8 openresty
openresty-asan-debuginfo.x86_64 1.21.4.1-1.el8 openresty
openresty-debug.x86_64 1.21.4.1-1.el8 openresty
openresty-debug-debuginfo.x86_64 1.21.4.1-1.el8 openresty
openresty-debuginfo.x86_64 1.21.4.1-1.el8 openresty
openresty-doc.noarch 1.21.4.1-1.el8 openresty
openresty-openssl.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-asan.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-asan-debuginfo.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-asan-devel.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-debug.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-debug-debuginfo.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-debug-devel.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-debuginfo.x86_64 1.1.0l-2.el8 openresty
openresty-openssl-devel.x86_64 1.1.0l-2.el8 openresty
openresty-openssl111-asan.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-asan-debuginfo.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-asan-devel.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-debug.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-debug-debuginfo.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-debug-devel.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-debuginfo.x86_64 1.1.1n-1.el8 openresty
openresty-openssl111-devel.x86_64 1.1.1n-1.el8 openresty
openresty-opm.noarch 1.21.4.1-1.el8 openresty
openresty-pcre-asan.x86_64 8.45-1.el8 openresty
openresty-pcre-asan-debuginfo.x86_64 8.45-1.el8 openresty
openresty-pcre-asan-debugsource.x86_64 8.44-1.el8 openresty
openresty-pcre-asan-devel.x86_64 8.45-1.el8 openresty
openresty-pcre-debuginfo.x86_64 8.45-1.el8 openresty
openresty-pcre-debugsource.x86_64 8.44-1.el8 openresty
openresty-pcre-devel.x86_64 8.45-1.el8 openresty
openresty-valgrind.x86_64 1.21.4.1-1.el8 openresty
openresty-valgrind-debuginfo.x86_64 1.21.4.1-1.el8 openresty
openresty-zlib-asan.x86_64 1.2.12-2.el8 openresty
openresty-zlib-asan-debuginfo.x86_64 1.2.12-2.el8 openresty
openresty-zlib-asan-debugsource.x86_64 1.2.11-13.el8 openresty
openresty-zlib-asan-devel.x86_64 1.2.12-2.el8 openresty
openresty-zlib-debuginfo.x86_64 1.2.12-1.el8 openresty
openresty-zlib-debugsource.x86_64 1.2.11-3.el8 openresty
openresty-zlib-devel.x86_64 1.2.12-1.el8 openresty
perl-Spiffy.noarch 0.46-3.el8 openresty
perl-Test-Base.noarch 0.89-1.el8 openresty
perl-Test-Nginx.noarch 0.29-2.el8 openresty

7.) Verify OpenResty Version

Later, you can verify your OpenResty version using the following command-line in the SSH terminal.

READ:  Red Hat Enterprise Linux (RHEL) 9 Release Date

* Check OpenResty version at a glance

$ openresty -v
nginx version: openresty/1.21.4.1

* For more detailed version of OpenResty run this command.

$ openresty -V
nginx version: openresty/1.21.4.1
built by gcc 8.5.0 20210514 (Red Hat 8.5.0-4) (GCC)
built with OpenSSL 1.1.1n 15 Mar 2022
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC -I/usr/local/openresty/zlib/include -I/usr/local/openresty/pcre/include -I/usr/local/openresty/openssl111/include' --add-module=../ngx_devel_kit-0.3.1 --add-module=../echo-nginx-module-0.62 --add-module=../xss-nginx-module-0.06 --add-module=../ngx_coolkit-0.2 --add-module=../set-misc-nginx-module-0.33 --add-module=../form-input-nginx-module-0.12 --add-module=../encrypted-session-nginx-module-0.09 --add-module=../srcache-nginx-module-0.32 --add-module=../ngx_lua-0.10.21 --add-module=../ngx_lua_upstream-0.07 --add-module=../headers-more-nginx-module-0.33 --add-module=../array-var-nginx-module-0.05 --add-module=../memc-nginx-module-0.19 --add-module=../redis2-nginx-module-0.15 --add-module=../redis-nginx-module-0.3.9 --add-module=../ngx_stream_lua-0.0.11 --with-ld-opt='-Wl,-rpath,/usr/local/openresty/luajit/lib -L/usr/local/openresty/zlib/lib -L/usr/local/openresty/pcre/lib -L/usr/local/openresty/openssl111/lib -Wl,-rpath,/usr/local/openresty/zlib/lib:/usr/local/openresty/pcre/lib:/usr/local/openresty/openssl111/lib' --with-cc='ccache gcc -fdiagnostics-color=always' --with-pcre-jit --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-http_v2_module --without-mail_pop3_module --without-mail_imap_module --without-mail_smtp_module --with-http_stub_status_module --with-http_realip_module --with-http_addition_module --with-http_auth_request_module --with-http_secure_link_module --with-http_random_index_module --with-http_gzip_static_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-threads --with-compat --with-stream --with-http_ssl_module

8.) Manage OpenResty v1.21.4.1 Web Platform

You can manage OpenResty web platform on CentOS Stream 8 using the following commands.

* Enable OpenResty to automatically start from boot

$ systemctl enable openresty
Created symlink /etc/systemd/system/multi-user.target.wants/openresty.service → /usr/lib/systemd/system/openresty.service.

* To Start OpenResty

$ systemctl start openresty

* To Stop OpenResty

$ systemctl stop openresty

* To Restart OpenResty

$ systemctl restart openresty

* To check OpenResty Service State

* systemctl status openresty
● openresty.service - The OpenResty Application Platform
Loaded: loaded (/usr/lib/systemd/system/openresty.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-05-31 21:42:46 UTC; 37s ago
Process: 18978 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=0/SUCCESS)
Process: 18984 ExecStart=/usr/local/openresty/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 18983 ExecStartPre=/usr/local/openresty/nginx/sbin/nginx -t (code=exited, status=0/SUCCESS)
Main PID: 18987 (nginx)
Tasks: 2 (limit: 4744)
Memory: 2.4M
CGroup: /system.slice/openresty.service
├─18987 nginx: master process /usr/local/openresty/nginx/sbin/nginx
└─18988 nginx: worker process

May 31 21:42:46 open-source.project systemd[1]: openresty.service: Succeeded.
May 31 21:42:46 open-source.project systemd[1]: Stopped The OpenResty Application Platform.
May 31 21:42:46 open-source.project systemd[1]: Starting The OpenResty Application Platform...
May 31 21:42:46 open-source.project nginx[18983]: nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
May 31 21:42:46 open-source.project nginx[18983]: nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
May 31 21:42:46 open-source.project systemd[1]: openresty.service: Failed to parse PID from file /usr/local/openresty/nginx/logs/nginx.pid: Invalid >
May 31 21:42:46 open-source.project systemd[1]: Started The OpenResty Application Platform.
lines 1-20/20 (END)

9.) Verify via Web Browsers

Lasty, you can verify that OpenResty is successfully installed via accessing web browsers like Google Chrome or Mozilla Firefox. As you can see on the following screenshots that we have successfully installing OpenResty version 1.21.4.1 on CentOS 8 machine, where there is Default/Welcome Page which mark OpenResty is working properly.

---------------------------------------------------
HTTP Header Spy
GET http://104.131.86.105/
HTTP/1.1 200 OK
496 ms
104.131.86.105

Request
Response

Server openresty/1.21.4.1
Date Tue, 31 May 2022 21:45:38 GMT
Content-Type text/html
Content-Length 1097
Last-Modified Tue, 17 May 2022 19:11:58 GMT
Connection keep-alive
ETag "6283f37e-449"
Accept-Ranges bytes
---------------------------------------------------

CONCLUSION:

You have successfully setting up, install and manage OpenResty v1.21.4.1 web platform on CentOS 8 machine. Later you can utilize OpenResty to host your web -based applications or blogs with PHP-FPM, MySQL or MariaDB database server, and Memcached or Redis as database caching modules.

Leave a Comment