These forums are locked and archived, but all topics have been migrated to the new forum. You can search for this topic on the new forum: Search for Ubuntu 16.04, PHP 7 FCGI running as www-data on the new forum.
I'm running a new server on Ubuntu 16.04 with PHP 7. All of my virtual servers are running as www-data, giving me errors on each of them for permissions (for example, can't update wordpress plugins).
I'm not really sure where to troubleshoot any further. I've tried commenting out SetHandler in a few apache config files and restarting, but it's still not working as I would expect it to.
Can anyone help me troubleshoot? I'm not sure where to go from here.
hi, all servers should run under owner (domain) as 'user:user' not an www-data.. perhaps your problem is in that. You could try to change user and group of one server and see if that works correctly afterwords
Configuring/troubleshooting Debian servers is always great fun
Hi unborn, thanks for replying. I understand what you're saying - that's actually my problem. I'm running into issues with permissions because they are not running as their own domain like you mentioned.
What do you mean by change user and group of one server? Can you elaborate?
I feel as if something is misconfigured, because all of my virtual servers are running php as www-data and I can't figure out how to fix it.
Thanks again for your help!
hi mfive,
try as root
chown -R username:group directory
like:sudo chown -R user-domain:user-domain /home/user-domain
where user-domain is your domain user... try it just for one server to see if it works. If it will then you can have look on other things, but first try that command.Configuring/troubleshooting Debian servers is always great fun
I have the ability to change the directory ownership. All of the directories are owned by their own user:user - which, I believe, is what's causing issues with Apache running as www-data. There is a conflict in the user PHP/apache are running as (www-data) vs who owns the files (virtual-host).
How can I force Apache/PHP to run as the virtual server user? I am using FCGI which should work, but it's not :(
...in short or longer - I would ask it again - did it worked for you or - not???? I am sorry but too many issues are tested on my virtual thing.. so - did it work or????
Configuring/troubleshooting Debian servers is always great fun
It works - but any time the app creates a file (via php), the file is saved with the owner/group as www-data:www-data - this doesn't resolve the root of the issue, though... which is the user that apache is running on. :(
It sounds like mod_php or similar is running your PHP scripts. Are you sure you don't have handlers for mod_php happening in your Apache config that are taking precedence over the per-virtualhost fcgid config?
--
Check out the forum guidelines!
Hi Joe, thanks for taking the time to reply. No, I'm not sure. Can you help me understand what to look for and which Apache config file(s)?
Hi, well - joe just did explained it... sorry to say you that...
Configuring/troubleshooting Debian servers is always great fun
Okay - so a quick update. I found a SetHandler command in the apache2.conf file that looked like the following: sethandler application/x-httpd-php
I commented this out and I believe it's working now!!!! New files seem to be running as the correct owner.
Joe - you are a lifesaver! Thank you for pointing me in the right direction!
I know this is an old post, but just wanted to share that I was running into this same issue here. mfive lead me onto the right path, but instead of changing the apache2.conf file, I modified the /etc/apache2/mods-available/php7.0.conf file to:
<FilesMatch ".+\.ph(p[3457]?|t|tml)$">
# SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".+\.phps$">
# SetHandler application/x-httpd-php-source
# Deny access to raw php sources by default
# To re-enable it's recommended to enable access to the files
# only in specific virtual host or directory
Require all denied
</FilesMatch>
# Deny access to files without filename (e.g. '.php')
<FilesMatch "^\.ph(p[3457]?|t|tml|ps)$">
Require all denied
</FilesMatch>
# Running PHP scripts in user directories is disabled by default
#
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_flag engine Off
</Directory>
</IfModule>
I was having the same problem on Ubuntu 18.04 where PHP pages where I was having all sorts of file permissions issues because the PHP/Apache user was www-data.
Commenting out the SetHandler directives in /etc/apache2/mods-available/php7.2.conf fixed it as per mfive and kevinhayashi
Yay!!!
BTW, this happened because when I upgraded, I accepted the project author's version rather than keeping my old version of the apache conf files. Bad idea.