Creating a VHOST on an Ubuntu Server

Ian Peter
3 min readFeb 7, 2022

--

This will be dealing with how to create a VHOST on an Ubuntu Server.

The following website will be used as an example

Prerequisites

- Installation of an Ubuntu Server or similar OS and Apache Webserver. Details for doing this can be found in my other article

  • Git installation on your server. You can check if git is present by running git version. If not install it by running sudo apt-get install git-all

What needs to be done:

  • Boot up you Ubuntu Server and on the Command Line Interface, navigate to /var/www/ folder using

cd /var/www

- Git clone into the website provided above using:

git clone https://github.com/sndeshmukh00/Random-Password-Generator

Picture showing how to git clone into website
  • If successful, rename the file to password as shown above by running

mv Random-Password-Generator/ password

  • Next, navigate to the /etc/apache2/sites-available using:

cd /etc/apache2/sites-available

  • Make a copy of the 000-default.conf file naming it as password.conf using:

cp 000-default.conf password.conf

Copying password file
  • Using your favorable editor, access password.conf and make the following changes

ServerAdmin admin@password.com

ServerName test.com

ServerAlias www.test.com

DocumentRoot /var/www/password

Changes made to password.conf file
  • Assign your preferred ServerAdmin value, ServerName and ServerAlias but ensure the DocumentRoot is still /var/www/password as that is where the website is stored
  • Finally run the following commands to activate the configuration file you just created in the previous step and deactivate the automatic Apache webpage that is served up when you access the server

a2ensite password.conf

a2dissite 000-default.conf

service apache2 restart

Enabling site and reloading Apache service
  • Note that you might have to disable any additional sites on already installed on your system by running the a2dissite command and restarting the apache2 service again. You can confirm the sites that are running by checking the sites-enabled directory. To do this, you can run this command from your current directory

ls ../sites-enabled

  • Finally, access your server from a webpage using either the IP address or a domain name if you have configured one. A successful installation should launch a page similar to the one below
Password Generator website
  • If you would like to learn how to configure an SSL Certificate in order to make your site accessible via HTTPS, please refer to the article below

Resources used

You can refer to these in case you need additional assistance in the configuration process

--

--

Ian Peter
Ian Peter

Written by Ian Peter

CTF player. Cybersecurity enthusiast and Computer science student

No responses yet