Gaming industry under DDoS attack. Get DDoS protection now. Start onboarding

Products

  1. Home
  2. Developers
  3. How to Uninstall Nginx on Ubuntu

How to Uninstall Nginx on Ubuntu

  • By Gcore
  • May 28, 2023
  • 2 min read
How to Uninstall Nginx on Ubuntu

If you’ve been using the nginx web server and decide to switch to Apache, OpenLiteSpeed, or Lighttpd, you may encounter an “Address already in use” error. This indicates that ports 80 and 443 are currently occupied by nginx. To enable the new web server to use these ports, nginx needs to be removed. This guide will show you how to delete nginx from Ubuntu.

Note: Before proceeding with the uninstallation, make sure to back up any data or configurations you don’t want to lose.

To remove nginx from Ubuntu, follow these steps:

1. Connect to your server where nginx is installed. 

2. Stop the web server by entering the following command:

sudo systemctl stop nginx

3. Uninstall the nginx package with the “purge” command. This command is preferable as it not only removes the package but also deletes its configuration files, unlike the “remove” command.

sudo apt-get purge nginx

After executing the above commands, the system will prompt you to remove any dependencies.

4. Remove any dependencies that were installed alongside nginx but are no longer required:

sudo apt-get autoremove

The terminal will display a list of all the removed dependencies.

5. (Optional) You may want to check if there are any remaining nginx-related files in the system. Common directories include “/etc/nginx/” and “/var/log/nginx/”. If these directories still exist, you can remove them manually:

sudo rm -rf /etc/nginx /var/log/nginx

6. (Optional) To verify if the web server has been completely removed, check the status of the nginx service:

sudo systemctl status nginx

If the web server has been successfully removed, you’ll see the service status set to “inactive (dead)”:

That’s it! These steps help you to uninstall nginx on your server.


Want to run Ubuntu in a virtual environment? With Gcore Cloud, you can choose from Basic VM, Virtual Instances, or VPS/VDS suitable for Ubuntu:

Choose an instance

Related articles

What Is a High Availability Server?

Every minute your servers are down, your business is bleeding. For e-commerce sites, healthcare platforms, and revenue-critical applications, an outage isn't just an inconvenience. It's a direct hit to your bottom line, your reputation, and

Cloud vs Dedicated Server: Which Is Right for You?

Your server choice could be quietly costing you, or quietly holding you back. Pick the wrong infrastructure for your workload and you're either overpaying for idle hardware every month or watching your site buckle under traffic spikes you c

VPS vs Dedicated Server
VPS vs Dedicated Server: Which One Do You Need?

Your site is humming along fine, until it isn't. Traffic spikes, page loads crawl, and your hosting plan buckles under pressure right when it matters most. Choosing between a VPS and a dedicated server isn't just a technical checkbox. It's

Multi-Cloud Plan: What It Is and How It Works

Your cloud provider goes down. Applications fail. Customers can't access your services. And because you've built everything around a single vendor, there's nothing you can do but wait. For organizations locked into one cloud platform, this

Vendor Lock-In in Cloud Computing: What It Is and How to Avoid It

Imagine discovering that migrating your company's data to a new cloud provider will cost hundreds of thousands of dollars in egress fees alone, before you've even touched the re-engineering work. Or worse, picture being in Synapse Financial

What Is Sovereign Cloud and Why Does It Matter?

Picture this: a foreign government issues a legal order forcing your cloud provider to hand over sensitive patient records, classified research data, or critical national infrastructure details. You can't stop it. This isn't hypothetical. G

Subscribe to our newsletter

Get the latest industry trends, exclusive insights, and Gcore updates delivered straight to your inbox.