Ubuntu 18.04 in Azure – Pt. 3: Virtual Hosts

Create a new directory.
sudo mkdir /var/www/<yourdomain>
sudo chown -R $USER:$USER /var/www/<yourdomain>

Make a placeholder webpage in HTML.
sudo nano /var/www/<yourdomain>/index.html
<html>
<head>
<title>Welcome to Your_Domain!</title>
</head>
<body>
<h1> Success! The your_domain server block is working!</h1>
</body>
</html>

Make a new Apache configuration file.
sudo nano /etc/apache2/sites-available/<yourdomain>.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName <yourdomain>
ServerAlias www.<yourdomain>
DocumentRoot /var/www/<yourdomain>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

sudo a2ensite <yourdomain>.conf
sudo a2dissite 000-default.conf
sudo systemctl restart apache2

Leave a Reply

Your email address will not be published. Required fields are marked *