Nambah Virtual Host Apache

Create a new directory in /var/www/ for your domain. Just replace with your own.

sudo mkdir -p /var/www/

8.2. Create Virtual Host
Create a virtual host configuration file replacing with your own.

sudo nano /etc/apache2/sites-available/

Enter the following replacing with your own.

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

Save and exit (press CTRL + X, press Y and then press ENTER)

Test for errors.

apachectl configtest

You can ignore any error that mentions “Could not reliably determine the server’s fully qualified domain name”.

Enable your virtual host replacing with your own.

sudo a2ensite

Disable the default Apache website, otherwise it will override your virtual host.

sudo a2dissite 000-default

Restart Apache.

sudo systemctl reload apache2


Leave a Comment