Question
How can I set different PHP versions while using SuPHP and PHP Selector?
Introduction
Unlike the MultiPHP Manager provided by cPanel, CloudLinux's PHP Selector does not allow you to configure a different version of PHP per addon-domains or subdomains.
While it is possible to get this to work, this functionality is not directly provided via the interface and instead will require some manual tasks.
Procedure
- Access your server as root through WHM or via SSH using Terminal.
- Configure SuPHP on the server by navigating to "Home /Software / MultiPHP Manager" and setting the PHP Handler to SuPHP.
-
Open the following file with your favorite editor.
nano /etc/suphp.conf
-
Under [handlers] add the PHP versions you want to use.
application/x-httpd-php80="php:/opt/alt/php80/usr/bin/php-cgi" application/x-httpd-php81="php:/opt/alt/php81/usr/bin/php-cgi" application/x-httpd-php82="php:/opt/alt/php82/usr/bin/php-cgi" application/x-httpd-php83="php:/opt/alt/php83/usr/bin/php-cgi"
-
Modify the pre_virtual_host.global and configure the PHP versions you want to use.
nano /usr/local/apache/conf/includes/pre_virtualhost_global.conf
<IfModule mod_suphp.c> <Directory /> suPHP_AddHandler application/x-httpd-php80 suPHP_AddHandler application/x-httpd-php81 suPHP_AddHandler application/x-httpd-php82 suPHP_AddHandler application/x-httpd-php83 </Directory> </IfModule>
- Save and close the file.
-
Restart Apache.
/scripts/restartsrv_httpd
Once this has been configured, in the directory you want to set the PHP version in, modify or create an .htaccess file and add the following:
AddHandler application/x-httpd-php81 .php .php5
Please note, subdirectories will use the same PHP version as the parent unless you override it with another .htaccess entry in that subdirectory.
Additional Resources
PHP Selector: Configure PHP extensions when setting different PHP versions per directory
Comments
0 comments
Article is closed for comments.