Debian 8.5 PHP7 upgrade, Apache now runs as www-data instead of virtual server owner

3 posts / 0 new
Last post
#1 Sun, 08/28/2016 - 04:10
petertjuh

Debian 8.5 PHP7 upgrade, Apache now runs as www-data instead of virtual server owner

Followed everything from this thread: https://www.virtualmin.com/node/39270 But still no luck, Apache 2 runs as www-data and gives me loads of troubles because of that. Got some feedback from andreychek (https://www.virtualmin.com/node/41821) and he suggested to ask again in the forums, so here it is.

My machine is a Debian 8.5 fresh install, Virtualmin the latest and both php5 and php7 installed.

If you go into System Settings -> Re-Check Config, does it detect any PHP-related errors?
Apache is installed.

The following PHP versions are available : 5.6.24 (/usr/bin/php5-cgi), 7.0.10 (/usr/bin/php-cgi7.0)

Apache is configured to host SSL websites.

**.. your system is ready for use by Virtualmin.**

find /etc/apache2/mods-enabled | xargs grep -i sethandler

find /etc/apache2/mods-enabled | xargs grep -i sethandler
grep: /etc/apache2/mods-enabled: Is a directory
/etc/apache2/mods-enabled/php5.conf:#    SetHandler application/x-httpd-php
/etc/apache2/mods-enabled/php5.conf:#    SetHandler application/x-httpd-php-source
/etc/apache2/mods-enabled/proxy_balancer.conf:  #          SetHandler balancer-manager
/etc/apache2/mods-enabled/php5.conf.save:#    SetHandler application/x-httpd-php
/etc/apache2/mods-enabled/php5.conf.save:#    SetHandler application/x-httpd-php-source
/etc/apache2/mods-enabled/status.conf:          SetHandler server-status

Even after commenting out the php5 handlers I still get the same user , www-data. Note that I do not have a php7 handler in there.

  GNU nano 2.2.6                                 File: /etc/apache2/mods-enabled/php5.conf

#<FilesMatch ".+\.ph(p[345]?|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[345]?|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>

Restarting php-fpm and apache2

Environment
Variable Value
USER www-data
HOME /var/www

I even removed php5.6 so php7 is the only version on the system, still same results. Anybody know how to fix this? I lover php7, really fast.

Output of ls -la /etc/apache2/mods-enabled/

~# ls -la  /etc/apache2/mods-enabled/
total 8
drwxr-xr-x 2 root root 4096 Aug 25 11:27 .
drwxr-xr-x 9 root root 4096 Aug 25 13:10 ..
lrwxrwxrwx 1 root root   36 Aug 21 11:50 access_compat.load -> ../mods-available/access_compat.load
lrwxrwxrwx 1 root root   30 Aug 21 11:52 actions.conf -> ../mods-available/actions.conf
lrwxrwxrwx 1 root root   30 Aug 21 11:52 actions.load -> ../mods-available/actions.load
lrwxrwxrwx 1 root root   28 Aug 21 11:50 alias.conf -> ../mods-available/alias.conf
lrwxrwxrwx 1 root root   28 Aug 21 11:50 alias.load -> ../mods-available/alias.load
lrwxrwxrwx 1 root root   33 Aug 21 11:50 auth_basic.load -> ../mods-available/auth_basic.load
lrwxrwxrwx 1 root root   44 Aug 21 11:52 auth_digest.load -> /etc/apache2/mods-available/auth_digest.load
lrwxrwxrwx 1 root root   33 Aug 21 11:50 authn_core.load -> ../mods-available/authn_core.load
lrwxrwxrwx 1 root root   33 Aug 21 11:50 authn_file.load -> ../mods-available/authn_file.load
lrwxrwxrwx 1 root root   33 Aug 21 11:50 authz_core.load -> ../mods-available/authz_core.load
lrwxrwxrwx 1 root root   33 Aug 21 11:50 authz_host.load -> ../mods-available/authz_host.load
lrwxrwxrwx 1 root root   32 Aug 21 11:50 authz_svn.load -> ../mods-available/authz_svn.load
lrwxrwxrwx 1 root root   33 Aug 21 11:50 authz_user.load -> ../mods-available/authz_user.load
lrwxrwxrwx 1 root root   32 Aug 21 11:50 autoindex.conf -> ../mods-available/autoindex.conf
lrwxrwxrwx 1 root root   32 Aug 21 11:50 autoindex.load -> ../mods-available/autoindex.load
lrwxrwxrwx 1 root root   26 Aug 21 11:52 cgi.load -> ../mods-available/cgi.load
lrwxrwxrwx 1 root root   39 Aug 21 11:52 dav_fs.conf -> /etc/apache2/mods-available/dav_fs.conf
lrwxrwxrwx 1 root root   39 Aug 21 11:52 dav_fs.load -> /etc/apache2/mods-available/dav_fs.load
lrwxrwxrwx 1 root root   26 Aug 21 11:50 dav.load -> ../mods-available/dav.load
lrwxrwxrwx 1 root root   30 Aug 21 11:50 dav_svn.conf -> ../mods-available/dav_svn.conf
lrwxrwxrwx 1 root root   30 Aug 21 11:50 dav_svn.load -> ../mods-available/dav_svn.load
lrwxrwxrwx 1 root root   30 Aug 21 11:50 deflate.conf -> ../mods-available/deflate.conf
lrwxrwxrwx 1 root root   30 Aug 21 11:50 deflate.load -> ../mods-available/deflate.load
lrwxrwxrwx 1 root root   26 Aug 21 11:50 dir.conf -> ../mods-available/dir.conf
lrwxrwxrwx 1 root root   26 Aug 21 11:50 dir.load -> ../mods-available/dir.load
lrwxrwxrwx 1 root root   26 Aug 21 11:50 env.load -> ../mods-available/env.load
lrwxrwxrwx 1 root root   28 Aug 21 11:50 fcgid.conf -> ../mods-available/fcgid.conf
lrwxrwxrwx 1 root root   28 Aug 21 11:50 fcgid.load -> ../mods-available/fcgid.load
lrwxrwxrwx 1 root root   29 Aug 21 11:50 filter.load -> ../mods-available/filter.load
lrwxrwxrwx 1 root root   27 Aug 21 11:50 mime.conf -> ../mods-available/mime.conf
lrwxrwxrwx 1 root root   27 Aug 21 11:50 mime.load -> ../mods-available/mime.load
lrwxrwxrwx 1 root root   34 Aug 21 11:50 mpm_prefork.conf -> ../mods-available/mpm_prefork.conf
lrwxrwxrwx 1 root root   34 Aug 21 11:50 mpm_prefork.load -> ../mods-available/mpm_prefork.load
lrwxrwxrwx 1 root root   34 Aug 21 11:50 negotiation.conf -> ../mods-available/negotiation.conf
lrwxrwxrwx 1 root root   34 Aug 21 11:50 negotiation.load -> ../mods-available/negotiation.load
lrwxrwxrwx 1 root root   47 Aug 21 11:52 proxy_balancer.conf -> /etc/apache2/mods-available/proxy_balancer.conf
lrwxrwxrwx 1 root root   47 Aug 21 11:52 proxy_balancer.load -> /etc/apache2/mods-available/proxy_balancer.load
lrwxrwxrwx 1 root root   38 Aug 21 11:52 proxy.conf -> /etc/apache2/mods-available/proxy.conf
lrwxrwxrwx 1 root root   46 Aug 21 11:52 proxy_connect.load -> /etc/apache2/mods-available/proxy_connect.load
lrwxrwxrwx 1 root root   33 Aug 21 12:48 proxy_fcgi.load -> ../mods-available/proxy_fcgi.load
lrwxrwxrwx 1 root root   43 Aug 21 11:52 proxy_http.load -> /etc/apache2/mods-available/proxy_http.load
lrwxrwxrwx 1 root root   38 Aug 21 11:52 proxy.load -> /etc/apache2/mods-available/proxy.load
lrwxrwxrwx 1 root root   40 Aug 21 11:52 rewrite.load -> /etc/apache2/mods-available/rewrite.load
lrwxrwxrwx 1 root root   31 Aug 21 11:50 setenvif.conf -> ../mods-available/setenvif.conf
lrwxrwxrwx 1 root root   31 Aug 21 11:50 setenvif.load -> ../mods-available/setenvif.load
lrwxrwxrwx 1 root root   44 Aug 21 11:52 slotmem_shm.load -> /etc/apache2/mods-available/slotmem_shm.load
lrwxrwxrwx 1 root root   36 Aug 21 11:52 socache_shmcb.load -> ../mods-available/socache_shmcb.load
lrwxrwxrwx 1 root root   26 Aug 21 11:52 ssl.conf -> ../mods-available/ssl.conf
lrwxrwxrwx 1 root root   26 Aug 21 11:52 ssl.load -> ../mods-available/ssl.load
lrwxrwxrwx 1 root root   29 Aug 21 11:50 status.conf -> ../mods-available/status.conf
lrwxrwxrwx 1 root root   29 Aug 21 11:50 status.load -> ../mods-available/status.load
lrwxrwxrwx 1 root root   29 Aug 21 11:52 suexec.load -> ../mods-available/suexec.load

I fgrepped all the files, there is a 'SetHandler' in there.

:/etc/apache2/mods-enabled# fgrep 'SetHandler' *
proxy_balancer.conf:    #          SetHandler balancer-manager
status.conf:            SetHandler server-status

Content of servers-status:

GNU nano 2.2.6                                                 File: status.conf

<IfModule mod_status.c>
        # Allow server status reports generated by mod_status,
        # with the URL of http://servername/server-status
        # Uncomment and change the "192.0.2.0/24" to allow access from other hosts.

        <Location /server-status>
                SetHandler server-status
                Require local
                #Require ip 192.0.2.0/24
        </Location>

        # Keep track of extended status information for each request
        ExtendedStatus On

        # Determine if mod_status displays the first 63 characters of a request or
        # the last 63, assuming the request itself is greater than 63 chars.
        # Default: Off
        #SeeRequestTail On


        <IfModule mod_proxy.c>
                # Show Proxy LoadBalancer status in mod_status
                ProxyStatus On
        </IfModule>


</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
Sun, 08/28/2016 - 10:03
petertjuh

Hmmmm, when using php-fpm there is a file in the pool.d directory which says:

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = www-data
group = www-data
/etc/php/7.0/fpm/pool.d/www.conf

Yep, when I adjust that file manually it works as it should.

Environment
Variable Value
USER       xxxxxxxxxxxxxxxx
HOME [matching homedir for xxxxxx]

When I remove the www.conf file from the pool.d directory then php-fpm will not start at all.

Aug 28 16:58:21 xt php-fpm7.0[25955]: [28-Aug-2016 16:58:21] WARNING: Nothing matches the include pattern '/etc/php/7.0/fpm/pool.d/*.conf' from /etc/php/7.0/fpm/php-fpm.conf at line 125.
Aug 28 16:58:21 vps55.snelweg.net php-fpm7.0[25955]: [28-Aug-2016 16:58:21] ERROR: No pool defined. at least one pool section must be specified in config file
Aug 28 16:58:21 vps55.snelweg.net php-fpm7.0[25955]: [28-Aug-2016 16:58:21] ERROR: failed to post process the configuration
Aug 28 16:58:21 xt php-fpm7.0[25955]: [28-Aug-2016 16:58:21] ERROR: FPM initialization failed
Aug 28 16:58:21 xt systemd[1]: php7.0-fpm.service: main process exited, code=exited, status=78/n/a
Aug 28 16:58:21 xt systemd[1]: Failed to start The PHP 7.0 FastCGI Process Manager.
-- Subject: Unit php7.0-fpm.service has failed
-- Defined-By: systemd

When I remove the include=/etc/php/7.0/fpm/pool.d/*.conf direction from php-fpm.conf then

xt systemd[1]: Unit php7.0-fpm.service entered failed state.
Aug 28 17:01:46 xt php-fpm7.0[26359]: [28-Aug-2016 17:01:46] ERROR: No pool defined. at least one pool section must be specified in config file
Aug 28 17:01:46 xt php-fpm7.0[26359]: [28-Aug-2016 17:01:46] ERROR: failed to post process the configuration
Aug 28 17:01:46 xt php-fpm7.0[26359]: [28-Aug-2016 17:01:46] ERROR: FPM initialization failed
Aug 28 17:01:46 xt systemd[1]: php7.0-fpm.service: main process exited, code=exited, status=78/n/a
Aug 28 17:01:46 xt systemd[1]: Failed to start The PHP 7.0 FastCGI Process Manager.
-- Subject: Unit php7.0-fpm.service has failed

So what should I do with the www.conf file so that the proper user and group are chosen?

none

Tue, 09/06/2016 - 20:35
andreychek

I have removed all the comments from this thread. It's no longer a technical discussion, but a long series of personal attacks.

Everyone here is welcome to post, and have an opinion on every matter.

However, the moment your post or comment is a personal attack towards someone else or their opinion, you have crossed the line.

The Forums are a place for discussing technical ideas and solutions. Not everyone's response is always going to be what we need, and in that case feel free to just ignore it. There's no need to criticize anyone.

We have posted a code of conduct here:

https://www.virtualmin.com/node/41919

If you see someone who has broken the code of conduct or is otherwise harassing users here in the community, please let us know! We'd like to help.

Please don't try to handle it yourself! Just let us know, without harassing them back, and we'll handle it.

Thanks!

Topic locked