The following is a tutorial for compiling and installing Nginx 1.22 on Ubuntu 18.04 system:
-
Update system packages:
sudo apt update sudo apt upgrade
-
Install dependencies required for compilation:
sudo apt install build-essential curl zlib1g-dev libpcre3-dev libssl-dev libffi-dev
-
Download the Nginx source code:
mkdir ~/nginx cd ~/nginx curl -O https://nginx.org/download/nginx-1.22.0.tar.gz tar -zxvf nginx-1.22.0.tar.gz cd nginx-1.22.0
-
Configure compilation parameters:
./configure --prefix=/usr/local/nginx --with-http_ssl_module
-
Compile and install Nginx:
make sudo make install
-
Start Nginx:
sudo /usr/local/nginx/sbin/nginx
You have now successfully compiled and installed Nginx 1.22 on Ubuntu 18.04. You can verify that Nginx is running properly by visiting your server's IP address in your browser. Please make sure to configure and adjust properly according to your needs in practice.
Please note that Nginx installed by compiling and installing will not be automatically updated, you need to manually update the version or perform maintenance.