Apache2 - Configure multiple websites (virtual hosts)
1. Login to your Ubuntu Server, navigate to and list »sites-available« directory
cd /etc/apache2/sites-available
ll
2. You should see the files:
000-default.conf
default-ssl.conf
3. Disable the default site configuration
sudo a2dissite 000-default.conf
4. Create a copy of the default configuration file and open it for edit
sudo cp 000-default.conf yourdomain-com.conf
sudo nano yourdomain-com.conf
5. Enter the configuration (you can delete the comments) in this manner
<VirtualHost *:80>
ServerName yourdomain.com
ServerAdmin info@yourdomain.com
DocumentRoot /var/www/yourdomain.com
ErrorLog ${APACHE_LOG_DIR}/yourdomain.com-error.log
CustomLog ${APACHE_LOG_DIR}/yourdomain.com-access.log combined
</VirtualHost>
6. Save and exit the file edit mode
7. Enable the yourdomain.com site configuration
sudo a2ensite yourdomain-com.conf
8. Be sure to create appropriate directory and set permissions
cd /var/www/
sudo mkdir yourdomain.com
sudo chown username:username yourdomain.com -R
(use your own Ubuntu Server username)
9. Reload Apache2 server
sudo service apache2 reload