Prerequisites:
  • A Ubuntu Server
  • Apache2
  • MySQL server
  • PHP

 

First create a directory for your hosting website’s files. By default, in Ubuntu it is in /var/www/ You can create a folder inside it with the name of website or create in other directory. Both will work.

To create a directory

$sudo mkdir /var/www/mywebsite/

 

This folder requires permission to read by anyone,

$sudo chmod -R 755 /var/www/mywebsite

 

Now, create a new virtual host file for your new website. You can copy the default file to your website and edit to make change according to your requirement.

$sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mywebsite

 

Opne the website virtual host file and edit the following,

<VirtualHost *:80> ServerAdmin webmaster@mywebsite.com ServerName mywebsite.com ServerAlias http://www.mywebsite.com

 DocumentRoot /var/www/mywebsite/

[…]

 

Then You need to activate the host,

 sudo a2ensite mywebsite.com

Finally, restart or reload the apache server.

$sudo service apache2 restart

or

$sudo server apache2 reload

 

Now, domain update must be done to map the domain to the ip address of the server. And then you can browse your website

 

 

Advertisements