0

On a Debian system I installed Apache, MySQL, PHP. In the /var/www I dropped Joomla 3. The PHP script is executed but there is a problem with permissions. The php script is not able to write to files in /var/www. The script is triggered through a browser, which is started by a non-privileged user (simpleuser). I tried two different file setups for the directory:

set directory Owner Group Permissions


1) /var/www root simpleuser 775

2) /var/www root simpleuser 777

Only option 2) works. Because of this I think the script runs not with the permissions of simpleuser which is in the same-named group.

How can I determine who tries to modify files in /var/www/ ?

EDIT: The user in my specific case is actually www-data. Although I would like to know how to determine who (user) wants to get access to a certain file.

lojoe
  • 521
  • 1
  • 3
  • 13

2 Answers2

1

Most probably it would be the user apache/www-data

You can run:

sudo chown -R www-data:www-data /var/www 
Kanishk Dudeja
  • 1,201
  • 3
  • 17
  • 33
1

To determine the owner of a process, for instance php, run:

ps -e -o pid,user,group,cmd | grep php

Update:

you can use this script:

now=`date +%s`
while [ $now -gt $[`date +%s` - 60] ]
do
        ps -e -o pid,user,group,cmd | grep php | grep -v grep >> /tmp/psresults.log
done
M. Adel
  • 401
  • 5
  • 7
  • The process runs only a short while, so this isn't working. – lojoe May 26 '14 at 12:11
  • My answer has been updated, please test the script, it'll provide you with the needed info.. – M. Adel May 26 '14 at 12:30
  • The script is working generally. If I start php in a shell there is proper output produced. If a do an action with the browser e.g. load the index.php there is no output. – lojoe May 26 '14 at 13:16
  • May be the page is cached, clear your cache or use another browser, view the web server log file to make sure that the page has been called, better solution to use apache benchmark tool "ab" – M. Adel May 26 '14 at 13:42
  • The page was not cached. – lojoe May 27 '14 at 05:25