I've been searching for weeks on how to setup the localhost enviroment on ubuntu without any good solutions.

This is what I want to achieve:

I want to have My root folder as such /home/'username'/Sites/'projectname.pl' or /home/'username'/Sites/pl/'projectname'/public (or simular)

When accessing my localhost i don't wanna have to write localhost/'projectname'/public (or whatnot) I would like to be able to access the project just by typing http://'projectname'.pl

I know this is achievable on the apache server on OSX but I haven't been able to find any guides to achieve this on my Ubuntu-machine.

I would really be grateful of any help, and I really hope it's possible.



You can set up your vhosts in


For every vhost you like to have make a conf file in this directory. In the vhost configuration you can set your document root. The name of the file must end with .conf

So for example: /etc/apache2/sites-available/projectname.conf:

<VirtualHost *:80>
  ServerName projectname.pl

  DocumentRoot "/home/Sites/projectname/public"


Now enable your site with:

sudo a2ensite projectname

And restart apache:

sudo /etc/init.d/apache2 restart

Then edit your /etc/hosts file.

Just paste the line: projectname.pl

on the end.

Now you can access your site with http://projectname.pl

  • Thank you for your answer. I used som illegal chars in my question which resulted in som text falling out. I have updated my question now. Please refer to it again and see if there is something else I have to do to get it to work. Regards! – Pewter Dec 12 '13 at 18:27
  • Well basically it stays the same. I have edited the answer to mach your wishes :) – rechengehirn Dec 12 '13 at 21:39
  • The two key points here are naming the apache config with an extension of config and restarting apache afterwards. – JohnMerlino Oct 16 '14 at 6:15
  • Worked for me!! – arqam Sep 24 at 10:16

Just to add to the other answers here, the way I have configured such behaviour is with symlinks... Seems to work fine. It is very easy to do, and does not require any configuration files.

sudo ln -s ~/path/to/yoursite/ /var/www/html/yoursite

The last portion of the above may be different for you. The above is what I use in Linux Mint 17. The '/var/www/html/' directory is the default apache "site" folder.

So yeah, for anyone who is looking for a clean, easy method to map a site without actually placing their site's directory in the default apache folder, there ya go.

Note: I am not sure if the above is appropriate for production environments, but for local development, it seems to be okay. The reason I am unsure is because the symlink carries the permissions of the folder in the home directory, which is (most likely) "owned" by the user. If you need to, you can obviously change that to the more secure 'root' like the apache directory, but I leave mine alone as I am just using this in a development environment.


I solved this by following this guide. A really neat solution which enables you to create a folder in your specified "Sites"-folder and then access it without having to add a sites-available for every new site.

THE guide -> http://css.dzone.com/articles/drop-folder-directory-and-have

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.