You are not logged in.

#1 2012-03-26 17:00:08

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

[SOLVED] PHP: developer's permissions

Hi,

I'm new to PHP, so the question may be dumb. On the other hand, I haven't been able to find much with Google. How am I supposed to debug/modify files in /srv/http as a user? Even on localhost? I've been thinking there should be a suitable group, but this doesn't seem to be the case.

Last edited by Llama (2012-03-28 19:30:27)

Offline

#2 2012-03-26 17:09:51

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: [SOLVED] PHP: developer's permissions

I use the http group, IIRC that's the normal way to do it. Basically, use whatever group the web server runs as.

Last edited by Barrucadu (2012-03-26 17:10:20)

Offline

#3 2012-03-27 17:15:41

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: [SOLVED] PHP: developer's permissions

Something is incorrect. Apache, presumably, runs as http, as I've configured it according to Wiki: https://wiki.archlinux.org/index.php/LAMP#Apache (how am I supposed to check it, BTW?).

My group list:

$ groups
sys tty wheel log http network video audio optical floppy storage users wireshark

I can't write:

$ pwd
/srv/http
$ touch writetest.php
touch: cannot touch `writetest.php': Permission denied

Offline

#4 2012-03-27 19:07:20

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: [SOLVED] PHP: developer's permissions

You need to be in the http group, and the directory needs to be group-writeable.

Offline

#5 2012-03-27 19:22:50

mustafa
Member
Registered: 2009-10-03
Posts: 6

Re: [SOLVED] PHP: developer's permissions

I usually  set up userdir and then do my development in my home folder.

Offline

#6 2012-03-28 07:07:27

robmaloy
Member
From: Germany
Registered: 2008-05-14
Posts: 263

Re: [SOLVED] PHP: developer's permissions

I know it's off topic but:
Please don't learn PHP, it's a horrible language


☃ Snowman ☃

Offline

#7 2012-03-28 07:57:44

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: [SOLVED] PHP: developer's permissions

Llama, I prefer using ACL's in such cases. Just mount the partition containing /srv/http with "acl" option and you'll be able to use setfacl/getfacl to edit/view ACL entries. In your case two additional entries would be required:

# setfacl -m user:your_username:rwx /srv/http/
# setfacl -m default:user:your_username:rwx /srv/http/

I'm not sure whether it's the "right way" but it works.

robmaloy, your argument is very convincing. I'd like to hear your opinion about other languages. smile

Offline

#8 2012-03-28 10:17:07

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: [SOLVED] PHP: developer's permissions

Thank you, Atragor! I'll try your solution. BTW, nobody seems to know what the "right way" is. Google fetches the question, but nothing worth the name of the definitive answer.

robmaloy: I don't care about PHP, too. Sometimes one just can't give it the slip.

Offline

#9 2012-03-28 12:12:12

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: [SOLVED] PHP: developer's permissions

A little something is still out of whack with ACL, Atragor:

[alexey@stovepipebox bimbo]$ getfacl /srv/http/
getfacl: Removing leading '/' from absolute path names
# file: srv/http/
# owner: root
# group: root
user::rwx
user:alexey:rwx
group::r-x
mask::rwx
other::r-x
default:user::rwx
default:user:alexey:rwx
default:group::r-x
default:mask::rwx
default:other::r-x

[alexey@stovepipebox bimbo]$ pwd
/srv/http/bimbo
[alexey@stovepipebox bimbo]$ ls -l
total 16
-rw-r--r-- 1 root root 886 Mar 12 17:44 mysql_up.php
-rw-r--r-- 1  501   80 175 Mar 28 07:29 test.php
-rw-r--r-- 1  501   80 171 Mar 28 07:22 test.php~
-rw-r--r-- 1 root root 851 Mar 25 18:31 testtype.php
-rw-r--r-- 1 root root   0 Mar 28 07:46 writetest.php
[alexey@stovepipebox bimbo]$ touch ww.php
touch: cannot touch `ww.php': Permission denied
[alexey@stovepipebox bimbo]$ groups
sys tty wheel log network video audio optical floppy storage users wireshark
[alexey@stovepipebox bimbo]$ cd ..
[alexey@stovepipebox http]$ ls -l
total 4
drwxrwxr-x 2 root root 4096 Mar 28 07:46 bimbo
[alexey@stovepipebox http]$

No '+' signs anywhere. I removed myself (alexey) from http group as it's not needed any more (?).

Last edited by Llama (2012-03-28 12:34:04)

Offline

#10 2012-03-28 18:39:29

Atragor
Member
Registered: 2009-02-28
Posts: 59

Re: [SOLVED] PHP: developer's permissions

I erroneously supposed that /srv/http was empty. Use setfacl with -R option to change ACL's of all nested folders and files (details are in the man page).

Offline

#11 2012-03-28 19:29:17

Llama
Banned
From: St.-Petersburg, Russia
Registered: 2008-03-03
Posts: 1,379

Re: [SOLVED] PHP: developer's permissions

Thank you very much, Atragor!

Offline

Board footer

Powered by FluxBB