Quick preface - i'm a new to managing my own servers. I'm on Ubuntu 14.04 running Apache. I ran into some problems setting up Craft which i was hoping someone might be able to shed a bit of light on what i got wrong. I have a user with sudo privileges, lets say 'user1'.
I used a simple PHP script to find out what user PHP is running as:
<?php echo exec('whoami'); ?>
Which came out as 'www-data'. In terminal as 'user1' i created a new group 'craftpermissions' and added 'user1' and 'www-data' to this group. I then set the group 'craftpermissions' as the owner of the following directories:
/craft/app/
/craft/config/
/craft/storage/
I then set permissions on those three folders to 775 using:
sudo chmod -R 775 /var/www/myvirtualhostaddress/craft/app/
However when i visited mydomainname.com/index.php/admin/
i still got the error saying php could not write to the /config folder.
In the end i set permissions on the folder to 777 so i could crack on with installation and it worked fine, but i'd like to do it properly as i think 777 is a bit of a no-no? Or does it not matter too much if craft folder is one directory above my web root?
Any guidance much appreciated.
EDIT
for /craft/app
everything is owned by craftpermissions except ..
which is owned by the group created when i made user1:
drwxr-xr-x 7 user1 user1 4096 Aug 25 06:44 ..
does this refer to the directory above it? When i run on /craft/storage/ it appears as:
drwxrwxrwx 3 user1 craftpermissions 4096 Aug 25 09:18 .
drwxr-xr-x 7 user1 user1 4096 Aug 25 06:44 ..
drwxr-xr-x 6 www-data www-data 4096 Aug 25 09:19 runtime.
/craft/config
appears as
drwxrwxrwx 3 user1 craftpermissions 4096 Aug 25 09:19 .
drwxr-xr-x 7 user1 user1 4096 Aug 25 06:44 ..
-rwxrwxrwx 1 user1 craftpermissions 671 Aug 25 06:44 db.php
-rwxrwxrwx 1 user1 craftpermissions 220 Aug 25 06:44 general.php
-rw-r--r-- 1 www-data www-data 255 Aug 25 09:19 license.key
drwxrwxrwx 2 user1 craftpermissions 4096 Aug 25 06:45 redactor
-rwxrwxrwx 1 user1 craftpermissions 844 Aug 25 06:44 routes.php
ls -al
, what user:group currently ownscraft/app
,craft/storage
andcraft/config
?service apache2 restart
after addingwww-data
to the group. If that doesn't work - anything interesting in the Apache logs? Also - any reason why you're not justchown -R www-data:www-data /var/www/myvirtualhostaddress
?chown
those files towww-data:www-data
, do the 755 permissions work then?/app
,/storage
and/config
folders to www-data:www-data, and set permissions to 755 and it worked fine - thanks for the suggestion. is it ok to do it this way (having directories owned by www-data), or are there any drawbacks? is the best way to figure out how to do it with groups? i think i've probably just not fully understood how the relationships between groups / users works. am i understanding right that if group X is assigned through chown to a directory, any user in the group X should be able to read/write/execute with 775 (regardless of assigned user through chown)?