How to Install Openresty on Debian 10

Openresty is a web server built on Nginx with some additional built-in features like Lua programming language. If you want to use Lua with Nginx you will need to compile Nginx from source with Lua support but with openresty, you can get all the features of Nginx and additional few without going through the hassle of compiling it from source code.

For installing Openresty on Debian 10 follow these simple steps

YouTube player

Step 1: (Optional) Stop Nginx 

This step is only required if you are already running Nginx on your system. Without stopping Nginx installation of openresty might fail.

Run these commands to stop and disable Nginx

sudo systemctl disable nginx
sudo systemctl stop nginx

Step 2: Import GPG key

Run these commands to import the GPG key

sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates

Above command will install some dependencies to import the key

wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -

This command will import the GPG key into your system

Step 3: Add Openresty repository

First, get the version of the Debian OS of your system. This command will get the version codename and save it to variable “codename”. We will use this variable in next command to add the appropriate repository for your system.

codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release`

Now add the openresty repository for your version

echo "deb http://openresty.org/package/debian $codename openresty" \ | sudo tee /etc/apt/sources.list.d/openresty.list

Step 4: Update apt index

Use this command to update the apt index so we can download the latest package from the repository

sudo apt-get update

Step 5: Install Openresty

Now download and install the Openresty package from the repository by using this command

sudo apt-get -y install openresty

If everything goes well you will have openresty installed on your system.

You can visit the IP Address of your server to verify openresty is running. You will be greeted with a screen like this

openresty_welcome_page

That’s it

If you face any problem let me know in the comments below so we can solve the problem together.