Custom Apache Handler Multiple PHP Versions

PUBLISHED ON MAY 14, 2021 — APACHE, HOW-TO, LINUX, PHP

I needed to install PHP 7.4.x on CentOS 6 aside from the existing version on the server. It was quite a challenge but I made it work, the other issue I had to work with was because of the Apache 2.2 version on the server, I wasn’t able to use php-fpm with proxy.

So, as a quick and dirty solution, I did manage to get it working by adding the following lines before the

ScriptAlias /php74-cgi /your-location/to/php/binary
Action application/x-httpd-php74 /php74-cgi
<FilesMatch "\.php">
SetHandler application/x-httpd-php74
</FilesMatch>

With those changes, I was able to run PHP 7.4 in that custom VirtualHost. Yeah, probably there are better ways to do it, feel free to leave me a comment telling me how to do it better :)

comments powered by Disqus