Ubuntu Server: Pointing Apache’s default /var/www Folder to a Different Folder CodeUnit 11 APR 2011

If you build a Zend Framework website then you will know that it is customary practice to move most of the work out of the publicly accessible web folder and then simple feed back the results to this folder so that the visitors can see a page off your site. So all projects always contain a /public folder which technically should be the root of your Apache webserver.

If you don’t in particular want to mess around with the various rights and permissions already linked to the default /var/www folder, it turns out that there is a elegantly simple solution to your problem – simply symlink the /var/www folder to your zendproject/public folder!

rm -r /var/www
ln -sv /home/user/zendproject/public /var/www

What we are doing above is simply removing the existing /var/www folder and then creating a symlink version of it that points to our project’s public folder. So now anyone browsing our web server will be served pages out of the /public folder, without them knowing any different, keeping the rest of our Zend project out of any potential snooper’s hands!


Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.

  • Ali M Alsaif

    I tried doing that but I keep getting the page:

    403 Forbidden
    You don’t have permission to access / on this server.

    How can I fix it ?

    • Does the folder you’re pointing to give www-data permissions to access it? Change the owner/group accordingly, should solve your problem.