Apache Virtual Hosts on Ubuntu
Apache can be installed on your server through apt-get:
apt-get update
apt-get install apache2
Create the folders
The first step that we are going to take is to make a directory structure that will hold the site data that we will be serving to visitors.
mkdir /var/www/html/example.com
mkdir /var/www/html/example2.com
Create the Apache Virtual Host Files
Edit the file,
nano /etc/apache2/sites-available/example.com.conf
The update the config accordingly and to look like this,
<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>
Save and close the file, do the same for example2.com,
Edit the file,
nano /etc/apache2/sites-available/example2.com.conf
The update the config accordingly and to look like this,
<VirtualHost *:80>
ServerAdmin admin@example2.com
ServerName example2.com
ServerAlias www.example2.com
DocumentRoot /var/www/example2.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Save and close the file.
Enable the Apache Virtual Host Files
a2ensite example.com.conf
a2ensite example2.com.conf
Restart Apache to make these changes take effect:
service apache2 restart
Done!
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS