Symlink /var/www directory

I think you have the ln -s 'source' and 'target' the wrong way round


WRONG:

sudo ln -s /var/www /home/USER/code


RIGHT:

sudo ln -s /home/USER/code /var/www


you will end up with a symlink in your /home/USER/code folder pointing to var/www which is wrong.

For example, I have a folder for sally's site in /home/webs/sallybydesign/

cd /var/www

There should be no folder or file called sallybydesign in /var/www because we are about to make one.

 sudo ln -s  /home/ndmaque/webs/sallybydesign /var/www/sallybydesign

to see the new file (a symbolic link)

ls -l

you will see a file called sallybydesign, it is a symlink to your home/webs/sallybydesign folder and if you run

ls sallybydesign/ 

you will see the files in your home/webs/sallybydesign folder.

If so you can point your vhost file at /var/www/sallybydesign and it will automagically inherit all the apache /var/www permissions and solve a shed load of issues.


Delete (or move, for safety) the www directory before you create the symlink.

So, you should have a /var, but there should be no /var/www. Then, and only then, will a symlink called www be created that points to your localhost/code/project folder.