im having a few problems symlinking my /var/www/
to a new Webroot
directory inside my home folder. I think these stem from my lack of understanding of linux permissions.
As far as im aware, symlinks should take the form of the directory you want to linked and the directory you want to be linked to, so in my case, i ran:
sudo ln -s ~/Webroot/* /var/www/
this has sort of worked, if i run ls
on /var/www/
i can see all of the files in my Webroot
directory.
Whenever i try to run a file that is in my Webroot
folder, i get a 403 permission error, is this because the files in my Webroot directory are created by me, and the apache instance is being run as www-data?
if this is the case, would this mean i need to change the permissions on every file i create in order to run it?
I have previously run a local apache instance my pointing the directory root of my default vhost to the Webroot
folder, in this instance i did not need to alter any permissions. Any help would be appreciated.
Best Answer
This is not a good practice, I agree with Weboide. But there is a simple way to achieve this goal.
1). enable the apache userdir module.
this will enable apache userdir module. Now you can put the contents of website in
~/Webroot/
or whatever inside your home directory.Note: The default folder is
~/public_html
2). Make necessary changes to
/etc/apache2/mods-enabled/userdir.conf
.3). Restart the apache
Now you can access the site by navigating your browser to http://ip-address/~username. You can also set a virtual host for this site.
If you are looking to run php files you need to do one more step
edit the
/etc/apache2/mods-enabled/php5.conf
and comment the following lines:Then restart the apache.
Thats it. You are done.
Ref:https://wiki.ubuntu.com/UserDirectoryPHP
Hope this helps. If you face any difficulties feel free to post it here.