I've a Centos 7 with Apache, I want to compile php 7.0 and 5.6 and configure that as PHP-FPM. How can I configure Apache to allow users to change php version using .htaccess?

Example .htaccess entry:

AddHandler application/x-httpd-php7 .php


If you plan to use mod_php, you can't, because the directive that takes care of loading the module can't be used in .htaccess context.

If your server is using mod_proxy and mod_proxy_fcgi to access a php-fpm server with your desired php version, because this method makes httpd completely "agnostic" on which php version you may be using, all you have to do is tell your server to point to the appropiate php-fpm unix socket for php files:

<FilesMatch \.php>
    SetHandler proxy:unix:/path/to/app.sock|fcgi://localhost/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.