# Create a VHOST for a website in Apache

Last updated:

This is what you should do if you want a certain url to point to a specific folder on your system:

create a new file under /etc/apache2/sites-available (for example's sake we will name that file foobar.yourhost.com so you can know what it points to.)

on that file, you must write the configuration. Here is an example:

<VirtualHost *:80>
ServerName foobar.yourhost.com
DocumentRoot /var/www/foobar
<Directory />
AllowOverride None
</Directory>
<Directory /var/www/foobar/>
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>


activate the VirtualHost you've just created:

sudo a2ensite foobar.yourhost.com


Restart apache

### DNS Issues

If you're just testing out on localhost, you just need to open /etc/hosts and add another line, like this:
127.0.0.1   localhost