Remove Nginx And Install Apche Ubuntu 18.04


Remove Nginx And Install Apche Ubuntu 18.04

Introduction

The world of web servers is quite vast and different web servers have different applications and preferences. If you are new to the world of web servers it can be quite daunting to know which one you should use for your particular website or application. One of the most popular web servers used today is Nginx (Engine X), which is well known for its speed, reliability and scalability. On the other hand, another popular web server is Apache, which has been around for a much longer time and is quite versatile.

Apache is generally considered to be more feature-rich compared to Nginx. It can be used for web hosting, as a proxy server, for file serving, as an application server and for many other purposes. This can be quite handy for websites or applications with varying needs. In this article, we will show you how to uninstall Nginx and install Apache on Ubuntu 18.04.

Prerequisites

In order to complete this tutorial, you need:

  • A server running Ubuntu 18.04 with at least 1GB of RAM.
  • A non-root user with sudo privileges.
  • Access to the root account or a user with sudo privileges.

You can check whether your server meets the requirements by running the following command:

  • cat /proc/meminfo

You should see your RAM size listed in the output:

Output
MemTotal: 8195240 kB

[...]

Once you have checked that your server meets the requirements, you can proceed with the installation.

Step 1 — Uninstalling Nginx

Let’s start by uninstalling the previous version of Nginx. To do this, run the following command:

  • sudo apt-get remove nginx -y

The output should look something like this:

Output
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter libnginx-mod-mail
libnginx-mod-stream
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
nginx*
[...]

Now that Nginx has been uninstalled, we can proceed with the installation of Apache.

Step 2 — Installing Apache

To install Apache, we need to first install the Apache2 package from the Ubuntu repository. To do this, run the following command:

  • sudo apt-get install apache2 -y

The output should look something like this:

Output
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
apache2-bin apache2-data libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap ssl-cert
Suggested packages:
apache2-doc apache2-suexec-pristine apache2-suexec-custom
apache2-utils ssl-cert libnet-ssleay-perl libauthen-pam-perl
libio-pty-perl libcrypt-ssleay-perl
The following NEW packages will be installed:
apache2 apache2-bin apache2-data libapr1 libaprutil1
libaprutil1-dbd-sqlite3 libaprutil1-ldap ssl-cert
[...]

Once Apache is installed, we need to configure it for our application. To do this, open the Apache configuration file in your text editor:

  • sudo nano /etc/apache2/apache2.conf

In the configuration file, add the following line to your VirtualHost definition:

ServerName your_domain_name

In the above line, replace your_domain_name with the actual domain name of your application. You should also add the following line to the same file:

ServerAlias *.your_domain_name

Save and close the file when you are finished. Now, we need to enable the Apache modules we need for our application. To do this, run the following command:

  • sudo a2enmod module_name

Replace module_name with the Apache module you need for your application. For example, to enable the rewrite module you would use the following command:

  • sudo a2enmod rewrite

Once you have enabled all the modules you need for your application, you can restart Apache to apply the changes:

  • sudo systemctl restart apache2

You can now check if the installation was successful by running the following command:

  • systemctl status apache2

The output should look something like this:

Output
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Tue 2018-07-31 11:07:05 EDT; 41s ago [...]

At this point, Apache should be installed and running on your server.

Conclusion

In this article, we have shown you how to uninstall Nginx and install Apache on Ubuntu 18.04. If you have any questions or comments, please feel free to

Leave a Reply

Your email address will not be published. Required fields are marked *