I successfully configured PHP7 with Apache2 using ruid2
mod to run .php
scripts as owner of the file.
https://github.com/mind04/mod-ruid2
It's available as a ubuntu package:
$ apt-get install `libapache2-mod-ruid2`
and enable it by $ a2enmod ruid2
Proceed with standard configuration for PHP and mod_userdir. After everything is set up and PHP is working in your user directories. Add RMODE stat
to you directory declaration in userdir.conf
:
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
RMode stat
AllowOverride All
Options MultiViews SymLinksIfOwnerMatch IncludesNoExec
<Limit GET POST OPTIONS>
Require all granted
</Limit>
<LimitExcept GET POST OPTIONS>
Require all denied
</LimitExcept>
</Directory>
</IfModule>
After that all your scripts will run as the owner of the file.
There are some more options and security pitfalls about this solution (ruid2 looks like is non maintained for a few years as well as suPHP) but it works for me as suPHP mod package is not supported in Ubuntu 16.04.1 LTS anymore.