How to Install Nginx Mainline on openSUSE Leap


NGINX is a widely-used open-source web server and reverse proxy known for its high performance and efficient use of resources. The Mainline version is the current, actively developed version of NGINX, maintained by the official NGINX team. This guide will cover installing the Mainline version of NGINX on openSUSE Leap and instructions for those who prefer using the latest stable version as an alternative.

Step 1: Update openSUSE Leap

Before installing the NGINX mainline, it is essential to ensure that your system is fully updated to prevent any conflicts during installation. You can use the following terminal commands to update your system.

sudo zypper ref
sudo zypper up

After updating your system, it’s recommended to reboot it, mainly if the updates include a new kernel or a significant amount of updates. This will ensure that all the changes are implemented correctly, and your system runs optimally.

reboot

Step 2: Import nginx.org Repository

Install Dependecies

The next step is to install the necessary dependencies by running the following command.

sudo zypper install curl ca-certificates gpg2

Option 1. Import NGINX Mainline Repository

To set up and add the NGINX Mainline repository, execute the following command in your terminal.

sudo zypper addrepo --gpgcheck --type yum --refresh --check \
    'http://nginx.org/packages/mainline/sles/$releasever_major' nginx-mainline

Example output:

Adding repository 'nginx-mainline' ..........................................................................................................[done]
Repository 'nginx-mainline' successfully added

URI         : http://nginx.org/packages/mainline/sles/15
Enabled     : Yes
GPG Check   : Yes
Autorefresh : Yes
Priority    : 99 (default priority)

Repository priorities are without effect. All enabled repositories share the same priority.

Option 2. Import Nginx Stable Repository

Similar to the NGINX Mainline setup, to add the Nginx Stable repository, use the following command in your terminal.

sudo zypper addrepo --gpgcheck --type yum --refresh --check \
    'http://nginx.org/packages/sles/$releasever_major' nginx-stable

Example output:

Adding repository 'nginx-stable' ............................................................................................................[done]
Repository 'nginx-stable' successfully added

URI         : http://nginx.org/packages/sles/15
Enabled     : Yes
GPG Check   : Yes
Autorefresh : Yes
Priority    : 99 (default priority)

Repository priorities are without effect. All enabled repositories share the same priority.

Import GPG Key

To verify the authenticity of the Nginx.org packages, import the GPG key using the curl command to download the “nginx_signing.key” file.

curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key

Testing and confirming that the downloaded file has the correct key is advisable. To do this, run the following command in your terminal.

gpg --with-fingerprint /tmp/nginx_signing.key

The example output should appear:

pub  2048R/7BD9BF62 2011-08-19 [expires: 2024-06-14]
      Key fingerprint = 573B FD6B 3D8F BC64 1079  A6AB ABF5 BD82 7BD9 BF62
uid nginx signing key <signing-key@nginx.com>

After completing the above step, finalize the GPG key import by executing the following command.

sudo rpmkeys --import /tmp/nginx_signing.key

After importing, ensure that the metadata cache is updated.

sudo zypper ref -f

Step 3: Install Nginx

Proceed to install NGINX mainline or stable on openSUSE using the imported repository. By default, you have imported one of the two options available.

sudo zypper install nginx

Please note that during the installation process, you may be prompted to keep or replace your current /etc/nginx/nginx.conf configuration file. It is recommended to keep your existing configuration file by choosing (n). A copy will be made regardless of the maintainer’s version, allowing you to refer to it in the future.

To confirm that Nginx was installed correctly and to the latest version, use the following command:

sudo nginx -v

Example output from my machine:

nginx version: nginx/1.23.3

As mentioned earlier, the version installed should be the latest NGINX mainline or stable version available at the time of writing. Nginx is set to be enabled by default. If it is not activated, use the following command to enable it.

sudo systemctl enable nginx --now

Example output if successful:

Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.

Check the status of Nginx by running the following command.

systemctl status nginx

Example output:

And that’s it, you have installed the latest Nginx version.

See also
How to Install EPEL on CentOS Stream EL9 or EL8

Conclusion

To summarize, this tutorial has outlined the steps to add the Nginx repository on openSUSE Leap, enabling you to install the latest stable or mainline version of Nginx easily. By using the official repository, you will receive updates as soon as they are released by the Nginx team, rather than waiting for a third-party maintainer to push the updates, making sure that you always have the most recent version of Nginx running on your system.

Leave a Comment

Share to...