Apache file with custom PHP version

September 16, 2014

I once wanted to execute a single PHP file with a specific PHP version, different from the globally configured one with mod_php.

First, enable a cgi-bin directory:

<Location "/cgi-bin">
  SetHandler cgi-script
  Options +ExecCGI

You can also use ScriptAlias for this.

Then, for this specific file, turn off mod_php and use custom CGI:

<Location "/test.php">
  php_flag engine off
  Action php-cgi /cgi-bin/php55
  AddHandler php-cgi .php

Want to leave a comment?

Start a conversation on Twitter or send me an email! ๐Ÿ’Œ
This post helped you? Buy me a coffee! ๐Ÿป