php5 not being run as www-data

2019-08-09 06:26发布

I have some files that I need php to service to a client. These files are owned by www-data as they should be, with permissions 644. Access to these files is beig denied however, so I ran this little script:

<?php
    echo shell_exec('whoami');
?>

which prints out daemon, thisis not the user that I want php running as.

Where in the php or apache configuration files can I set it so that php is run as user www-data?

Edit: I've seen this link, but I do not want to set up aliases, and I believe that only applies to running php scripts form the terminal.

Edit 2: php v5.6 with apache v2.4 on ubuntu 12.04LTS

1条回答
混吃等死
2楼-- · 2019-08-09 06:35

The user and group Apache is running as is set in httpd.conf with the User and Group directives. Changing them to www-data should get you what you need.

查看更多
登录 后发表回答