Yeah, I know that I'm doing something a little bit
unconventional here: directing PHP scripts through a special
AddHandler which consists of a short shell-script that executes PHP with a particular
php.ini file. And it
almost works.
- If you ask for the home-page, e.g. http://mysite.com, the source code of the DirectoryIndex "default.php" will be printed out!
-
But, if you specify this or any other php-file (that exists ...) explicitly, e.g. http://mysite.com/default.php, the script is executed (using my handler).
In other words,
if the
DirectoryIndex file is to be served
(because no filename has been mentioned ...), it is being served as text, not as an executable. Any PHP-file mentioned by name on the command line is executed by the handler.
This is a Ubuntu system. In an activated config I have this:
Code:
# PHP file
AddHandler custom-php .php
# Direct these to the custom executable.
Action custom-php /frobozz-cgi/custom-php5.cgi virtual
# This is the alias that must be used with the Action.
ScriptAlias /frobozz-cgi/ /my_custom/cgi-php5/
# Specify access to this resource.
<Directory "/my_custom/cgi-php5/">
AllowOverride none
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
where
custom.cgi looks like this:
Code:
#!/bin/sh
exec /usr/bin/php5 --php-ini /my_custom/php.ini $PATH_TRANSLATED
and a relevant
<VirtualHost> looks something like this:
Code:
<VirtualHost *:80>
DocumentRoot "/my_custom/documents"
ServerName mysite.com
DirectoryIndex "default.php"
<Directory "/my_custom/documents">
Options FollowSymLinks
Order allow,deny
Allow from all
AllowOverride All
Require all granted
</Directory>
</VirtualHost>