How to set up Apache Virtual host on Ubuntu

How to set up Apache Virtual host on Ubuntu

Apache is Most popular and reliable web server to
serving  web content on the internet. In this guide we will help you to host your website easy and fast within five minute.

First, What is your Ubuntu Version ?

Is that a latest version ?

Never mind about your Ubuntu version. You can easily go with this tutorial.

STEP 1 : Create the directory / Folder

   sudo mkdir -p /var/www/tipscraft.com/

STEP 2 : Give the permission to the directory

  sudo chown -R $USER:$USER /var/www/tipscraft.com/

STEP 3 : Create a dummy index file in the directory

In here we create a simple index file. That helps to check whether website is working.This is my sample index.html

<html>
<head>
<title>Welcome to tips craft.com</title>
</head>
<body>
<h1>Success ! Now you can host your real website.</h1>
</body>
</html>

STEP 4 : Create a new virtual host file

  sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/tipscraft.com.conf

Open your new conf. file with root permission

sudo nano /etc/apache2/sites-available/tipscraft.com.conf

STEP 5 : Edit the tipscraft.com.conf file with new configurations

<VirtualHost *:80>  
   ServerAdmin [email protected]  
   ServerName tipscraft.com   
   ServerAlias www.tipscraft.com   
   DocumentRoot /var/www/tipscraft.com     
   ErrorLog ${APACHE_LOG_DIR}/error.log   
   CustomLog ${APACHE_LOG_DIR}/access.log combined
 </VirtualHost> 

STEP 5 : Enable the new virtual host

  sudo a2ensite tipscraft.com.conf

STEP 6 : Restart your Apache

  sudo service apache2 restart

If you are using a DNS manager, configure your domain point to your server alias.Example : Cloudflare , Rackspace .

Comments are closed.