I believe most of us have tried to update the nginx version to mainline using default RockyLinux documentation. If you are reading this webpage its possible the documentation didn’t really help!

So, when I tried to upgrade my nginx using the documentation, I got the following error message:

[root@webserver ~]# dnf module enable nginx:mainline
Last metadata expiration check: 0:02:26 ago on Fri 12 Jan 2024 07:01:10 PM IST.
Error: Problems in request:
missing groups or modules: nginx:mainline

To resolve this, I took some try and error to help me fix this without manually touching the repository.

Here are the steps:

1. Check and install all pending updates (a little bit of housekeeping 😊)

[root@webserver ~]# dnf update -y

2. Run the following command to check the available nginx versions:

root@webserver ~]# dnf module list nginx
Last metadata expiration check: 0:04:38 ago on Fri 12 Jan 2024 07:01:10 PM IST.
Rocky Linux 8 - AppStream
Name            Stream               Profiles            Summary                 
nginx           1.14 [d][e]          common [d]          nginx webserver         
nginx           1.16                 common [d]          nginx webserver         
nginx           1.18                 common [d]          nginx webserver         
nginx           1.20                 common [d]          nginx webserver         
nginx           1.22                 common [d]          nginx webserver         

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

3. Select the nginx stream version you want to activate:

[root@webserver ~]# dnf module enable nginx:1.22
Last metadata expiration check: 0:04:23 ago on Fri 12 Jan 2024 07:08:44 PM IST.
Dependencies resolved.
The operation would result in switching of module 'nginx' stream '1.14' to stream '1.22'
Error: It is not possible to switch enabled streams of a module unless explicitly enabled via configuration option module_stream_switch.
It is recommended to rather remove all installed content from the module, and reset the module using 'dnf module reset <module_name>' command. After you reset the module, you can install the other stream.

4. Now, you will see the warning above stating the implications of switching between nginx AppStream versions. As per the error, to proceed further, we need to reset the nginx package, to do that we need to run the following command:

[root@webserver ~]# dnf module reset nginx
Dependencies resolved.
=================================================================================
 Package           Architecture     Version              Repository         Size
=================================================================================
Resetting modules:
 nginx                                                                          

Transaction Summary
=================================================================================

Is this ok [y/N]: y
Complete!

5. Now, we can re-run the command to change the nginx AppStream version:

[root@webserver ~]# dnf module enable nginx:1.22
Last metadata expiration check: 0:00:07 ago on Fri 12 Jan 2024 07:13:50 PM IST.
Dependencies resolved.
=================================================================================
 Package           Architecture     Version              Repository         Size
=================================================================================
Enabling module streams:
 nginx                              1.22                                        

Transaction Summary
=================================================================================

Is this ok [y/N]: y
Complete!

Congratulations, you have now successfully changed the nginx AppStream version. To make sure it has changed, we can run the following command again to check and confirm:

[root@webserver ~]# dnf module list nginx
Last metadata expiration check: 0:01:32 ago on Fri 12 Jan 2024 08:12:55 PM IST.
Rocky Linux 8 - AppStream
Name            Stream             Profiles             Summary                  
nginx           1.14 [d]           common [d]           nginx webserver          
nginx           1.16               common [d]           nginx webserver          
nginx           1.18               common [d]           nginx webserver          
nginx           1.20               common [d]           nginx webserver          
nginx           1.22 [e]           common [d]           nginx webserver          

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

Make sure you see [e] in front of the nginx version you chose, in my case that is 1.22 [e]

6. Now we will run command to install nginx normally

[root@webserver ~]# dnf install nginx -y

I believe this wraps up the tutorial, for changing the nginx AppStream version.

Thank you for taking time to read my tutorial, happy computing….

Categorized in:

Linux,

Last Update: April 3, 2024