Newbie question about permissions on Apache document root
I'm working though the guides to get a LAMP stack installed (using the Arch Linux 2012.07 distro - I'm most familiar with Arch from the desktop, so it seemed the best choice). I've got all the components working, with two virtual hosts (domain1.com and domain2.com) in respective document roots as follows:
/srv/http/domain1.com/public_html
/srv/http/domain2.com/public_html
Test HTML or PHP files in those directories work fine.
What I'm wondering about is the correct permissions, group and ownership of the files within the respective publichtml directories. I have added a normal user ('myuser') and would like to create and edit files in these directories when logged in as that user. What's the best way to go about this? Currently the directories are owned by root, in the http group, and the permissions are 755. Is it OK to change ownership recursively of the publichtml directory to be owned by myuser? Also, which groups should my_user be in?
Thanks in advance for any help. This process is a bit scary for someone not used to being a sysadmin, but it's exciting too!
4 Replies
You should then be able to access the files in /home/youruser/pubic_html:
Since the files are in the own home directory, they showed be owned by you.
[Edit since you are using Arch]
See https://wiki.archlinux.org/index.php/Apache#User_dirs
Since I'm using VirtualHosts in Apache, and will want to have 2 or more domains under one of the users' home directories, should I do something like this:
~/publichtml/domain1.com/publichtml
~/publichtml/domain2.com/publichtml
and then point the DocumentRoot for each VirtualHost entry to the correct directory? Providing that I make ~ and ~/public_html executable, I'm assuming that should allow access to the subdirectories within each domain.
Thanks very much for your help.
Another possibility is to chown the vhost directory to the user.group who will be using it. I am not sure what the security implications of this are, so maybe someone else will advise.
<virtualhost 109.74.196.44:80="">ServerAdmin webmaster@wilkesley.org
ServerName http://www.wilkesley.org
ServerAlias wilkesley.org
DocumentRoot /srv/http/vhosts/wilkesley.org/
<directory srv="" http="" vhosts="" wilkesley.org="">Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny</directory></virtualhost>