How To Uninstall NGINX on RHEL-Based OS, CentOS Stream 9

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

Today we will teach you on how to completely uninstall NGINX web server from the RHEL-based OS, CentOS Stream 9. In this cases you have some problems where it force you to uninstall NGINX from your CentOS 9 machine. E.g. there maybe some issues on your website applications which cannot run properly under Nginx web server. Instead, your web apps need other web servers that can run with rewrite rule, e.g. Apache .htaccess.

Therefore, it force you to switch to other web servers like Apache, OpenLiteSpeed (OLS), or maybe a LiteSpeed Enterprise Web Server (LSWS). It very simply, you can completely removed the Nginx web server in just a few step. Before doing this on your end, make sure to meet the following pre-requisites.

PREREQUISITES:

* Virtual / Physical Servers, VPS or Cloud
* OS Distros with CentOS Stream 9
* Superuser Privileges (Root Access)
* Familiar with CLI-Based or Command-Line Only
* Gnome Terminal for Linux Desktop
* PuTTy SSH Client for Windows or Mac
* Powershell for Windows 10/11

1.) Login to Machine via SSH Console

In the first step you need to login to your machine via SSH console. Make sure to replace with your actual server IPv4 address and active SSH port.

$ ssh [email protected] -p4322
[email protected]'s password:
Web console: https://open-source.project:9090/ or https://104.131.86.105:9090/

Last login: Tue May 31 04:52:09 2022 from 125.166.8.37

2.) Verify NGINX Version

Verify installed NGINX version on your CentOS 9 machine using the following command.

$ nginx -V
nginx version: nginx/1.22.0
built by gcc 11.2.1 20220127 (Red Hat 11.2.1-9) (GCC)
built with OpenSSL 3.0.1 14 Dec 2021
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie'

3.) Uninstall NGINX

Then simply run the following commands to completely uninstall or remove NGINX web server from your CentOS Stream 9. You can using either it “yum” command or “dnf” command if you running “DNF-Based” system.

$ yum remove nginx nginx-common -y
No match for argument: nginx-common
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Removing:
nginx x86_64 1:1.22.0-1.el9.ngx @nginx-stable 2.9 M

Transaction Summary
=====================================================================================================================================================
Remove 1 Package

Freed space: 2.9 M
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: nginx-1:1.22.0-1.el9.ngx.x86_64 1/1
Erasing : nginx-1:1.22.0-1.el9.ngx.x86_64 1/1
Running scriptlet: nginx-1:1.22.0-1.el9.ngx.x86_64 1/1
Verifying : nginx-1:1.22.0-1.el9.ngx.x86_64 1/1

Removed:
nginx-1:1.22.0-1.el9.ngx.x86_64

Complete!
$ yum remove nginx* -y
No such command: purge. Please use /usr/bin/yum --help
It could be a YUM plugin command, try: "yum install 'dnf-command(purge)'"
[root@open-source ~]# yum remove nginx* -y
Dependencies resolved.
=====================================================================================================================================================
Package Architecture Version Repository Size
=====================================================================================================================================================
Removing:
nginx-filesystem noarch 1:1.20.1-10.el9 @appstream 0

Transaction Summary
=====================================================================================================================================================
Remove 1 Package

Freed space: 0
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Erasing : nginx-filesystem-1:1.20.1-10.el9.noarch 1/1
Running scriptlet: nginx-filesystem-1:1.20.1-10.el9.noarch 1/1
Verifying : nginx-filesystem-1:1.20.1-10.el9.noarch 1/1

Removed:
nginx-filesystem-1:1.20.1-10.el9.noarch

Complete!
$ yum autoremove autoclean -y
Last metadata expiration check: 0:51:08 ago on Tue 31 May 2022 01:27:45 PM EDT.
Dependencies resolved.
Nothing to do.
Complete!

CONCLUSION:

You have successfully uninstall or remove NGINX web server completely from your CentOS Stream 9 machine. Then you can switch to another web server like Apache, or LiteSpeed to continue run your website or blog applications.

Leave a Comment