REDIRECT DOMAIN TO YOUR SERVER – Virtual Hosts Apache Ubuntu 16.04

0. Purchase domain on Joker.com and redirect to your server

1.  Install Apache

sudo apt-get update

sudo apt-get install apache2

2. Create websIte directory

/var/www/websitenamefolder

3. Check folder permissions

/var/www  must be 755 

4. Put an index.html / php inside the websitefolder to check if working

<html>
  <head>
    <title>¡Bienvenido a Test.com!</title>
  </head>
  <body>
    <h1>¡Lo lograste! El virtual host test.com está funcionando</h1>
  </body>
</html>

5. Copy the default example of this route and modify with your needs.

/etc/apache2/sites-available/000-default.conf

6. Change the example.com below for your new website.

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com/public_html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

7. Enable your site and restart apache with console.

a2ensite example.com.conf
service apache2 restart