How To Configure Apache on Ubuntu 18.04 in just few steps

Installing Apache:

Before installing first of all you’ll need update your source list by running the following command.

$ sudo apt-get update

Now run the following command in order to install Apache server

 $ sudo apt-get install apache2

Creating Project
By default we place all our projects into “/var/www/” directory. Its a default directory where apache will look for the deployed projects. So lets create a new project here in this directory. First create a folder of your project and then create an “index.html” file.

$ cd /var/www/
$ sudo mkdir my_website
$ cd my_website
$ sudo nano index.html

Now place the following sample html code into this file and save it.

     <title>My Website</title> 
    <h3>Hi This is my new website via Apache2 on Ubuntu Server 14.04</h3>

Create new virtual host

Now that we have created our project, Its time for creating new virtual host and configuring that project. So that apache will know in which folder/directory i have placed my project. Now cd to “/etc/apache2/sites-available/” directory. Here we will create our configuration file. You can give any name to your configuration file with extension “*.conf”. Now run the following commands in order to do that,

$ cd /etc/apache2/sites-available/
$ sudo nano website.conf

Now place the following text in to the file website.conf and save it.

<VirtualHost *:80>
    DocumentRoot /var/www/my_website
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Till now we have created our project and configuration file but its not yet enabled. So we have to enable our conf file via following command. And also restart your server.

 $ sudo a2enmod rewrite
 $ sudo a2enmod wsgi 
 $ sudo a2ensite website.conf
 $ sudo service apache2 restart

That’s it! :)
Your website will probably be live now, Enjoy!
If you still face any problem, don’t worry, just drop me a message and I will help you out.

high performance ssd vps