I have downloaded and compiled Apache into my home directory, and it works on its own properly. The script I am using for this is [REDACTED] which downloads Apache, APR, and [REDACTED] to make an installation into whatever the current directory.
I have tried adding PHP support for this in a few ways. The first I tried was just to install the default php package with
apt-get which can come with the Raspbian operating system (I believe this was some version of php5). I then removed that and installed php7.0 with libapache2-mod-php7.0 also using
apt-get, but the results of both installations resulted in Apache not seeing the module. I also would like to stick with everything being encapsulated into the current directory (in this case it is ~ currently).
I then downloaded the php-7.2.4 package from php.net and compiled the source on my own with
configure --prefix=~/php --with-apxs2=~/apache/bin/apxs --enable-mbstring --with-openssl --enable-zip
cp php-production.ini ~/php/lib/php.ini
libtool --finish ~/php7/libs
I can then run
~/php/bin/php -v without problems.
~/apache/conf/httpd.conf the lines added for
LoadModule php7_module modules/libphp7.so
AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php
DirectoryIndex index.php index.htm index.html
The PHP installer added the LoadModule line for me. I also do not have the
a2enmod (or variants) as they seem to be specific to certain distributions.