Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including several PHP versions in Apache, switchable via AddHandler directive

Tags:

apache

mod-php

A shared web host I'm using is offering several versions of PHP on the same server: 5.2, 5.3 and 5.4. They make it possible to switch between these versions by naming the file extensions .php54 and .php53 respectively, or via an .htaccess directive:

AddHandler php5.4-script .php

I have not been able to completely figure out how their Apache server is configured to support this though. Everything I found seemed to say that only one mod_php can be compiled into Apache at a time. Would this suggest that php5.4-script is some sort of custom wrapper module? Or are there obscure ways in which different PHP modules can be compiled under different handler names?

like image 468
deceze Avatar asked Jan 18 '26 05:01

deceze


1 Answers

According to the resource I've found after researching on this topic, it is as you already thought a (Fast) CGI wrapper which allows you to change the PHP version used via e.g. .htaccess .

How to achieve this is explained thoroughly here: http://linuxplayer.org/2011/05/intall-multiple-version-of-php-on-one-server .

In case the site is not reachable, here I'm going to list the steps:

  1. Install required dev packages
  2. Compile and install
  3. Create a fastcgi wrapper script
    • Build and install e.g. php-5.3 with fpm enabled
    • Configure php-fpm
    • Start fpm
    • Install and setup mod_fastcgi, mod_fcgid
  4. Update the Apache config file
  5. Restart Apache
like image 65
Markus Hofmann Avatar answered Jan 21 '26 02:01

Markus Hofmann