Hello, this time I’ll guide you through the process of how to compile modules in OpenResty. If you don’t know what is OpenResty, I’ll say you that is a tuned Nginx with a lot of pre-compiled modules. This will help you to configure your server without much hard work.
The problem comes when some modules are not in that pre-compiled modules list, so we will need to compile those modules by hand. Modules like GeoIP2, Brotli… are in that list.
To avoid that Google will detect my posts as duplicate content and avoid to repeat the steps in every module (I’m a bit vague :P), I have created this basic guide to prepare the system to compile the modules. Later I’ll post guides about every module in their corresponding post.
Modules guides list
I’ve not posted any guide yet, so I’ll add it here as I created them.
Install requirements to compile modules in OpenResty
This steps can be also found in the official webpage:
The first you have to do to compile modules in OpenResty, is to install the required packages. Without those packages the compilation will fail, so are very important. In my case I have used Debian 10, so I will guide you through the necessary steps for this Linux version.
First, you have to add the official OpenResty repository, that will have much necessary packages (including the OpenResty itself):
# install some prerequisites needed by adding GPG public keys (could be removed later) sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates # import our GPG key: wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add - # add the our official APT repository: codename=`grep -Po 'VERSION="[0-9]+ (K[^)]+' /etc/os-release` echo "deb http://openresty.org/package/debian $codename openresty" | sudo tee /etc/apt/sources.list.d/openresty.list # to update the APT index: sudo apt-get update
once is installed and configure, we need to disable the Nginx (if installed), to avoid problems during the OpenResty installation:
# Disable Nginx Daemon sudo systemctl disable nginx # Stop Nginx Daemon sudo systemctl stop nginx
Those steps will stop the Nginx daemon y will also disable it:
# Installing OpenResty apt-get install -y openresty
If we need to compile the module for a concrete OpenResty version, we need to install the same version on the server to avoid compatibility problems (is very improtant). If we use another version, we will get an error saying that module was compiled for that version and will not work on our installed version. To get the version, will use the openresty -v command on the server where we are planning to install the module. This will will tell us the installed version. We can ignore this step if the server where we are compiling the module is the same where will be installed.
$ openresty -v nginx version: openresty/22.214.171.124
The we will proceed to install the required version, indicating the version which version in the command:
# Installing custom OpenResty Version apt-get install openresty=126.96.36.199*
The final wildcard is very important, because the version name always contains the debian version for which is the package, and can change. In Debian 10 for example, the version is 188.8.131.52-1~buster1.
Once installed, we can proceed to install the required packages for the compilation:
# Installing compilation requirements apt-get install libpcre3-dev libssl-dev perl make build-essential curl git openresty-zlib-dev
And here ends the guide about how to prepare your system for modules compilation. I hope that will help you, and don’t forget to share to help me also.