There are many situations, where we require to run multiple php versions on a single apacheinstance. Here are the steps followed, to install php5.4 and php5.6 on a single apache instance.We had a plain server, with CentOS 6.5 installed in it. The first step is to install software collectionrepository. Software collection repository helps us to create and use software with newer requirements and not just the default programs.
Step1: Install centos software collection repository
Step2: Install apache web server
Step3: Start the apache service
Step4: Configure apache to run in the startup
Step5: Install mysql server
Step6: Start mysql service
Step7: Configure mysqld to run in the startup
Step8: Complete the initial configurations of mysql server
Step9: Install PHP5.4
Step10: Install all the required modules for php54. There are quite a few essential modules to beinstalled with Php. You can indentify them, based on your requirements. Once those modules arepicked up, find out the package names and install them in the server. Exact package name can be found out using ‘yum search’ command. For example, mbstring is a module, which helps you to deal with multibyte encodings in PHP. Ifyou want to install this module, follow the steps given below:
Search for the exact package name:
Then install the module using ‘yum install’ command.
Repeat the same procedure for all those required modules. Now, install the second php Version in the server. I chose php5.6.
Step11: Install PHP5.6
Step12: Install required modules for php56 in the same way as we did through ‘Step10’.
Step13: Now, open apache configuration file ‘/opt/rh/httpsd24/root/etc/httpsd/conf/httpsd.conf’ and update the following lines for specifying the actual path of php-cgi and allowing access to it.
Step14: Open a new file ‘/opt/rh/httpsd24/root/etc/httpsd/conf.d/php-cgi.conf’ for saving php handler configurations. Add the following lines to this file.
Step15: Open a new file ‘/opt/rh/httpsd24/root/var/www/php-cgi/php54-wrapper’ for saving cgi configurations of PHP5.4. Add the following lines to this file.
Step16: Open a new file ‘/opt/rh/httpsd24/root/var/www/php-cgi/php56-wrapper’ for saving cgi configurations of PHP5.6. Add the following lines to this file.
Step17: Now we need to restart apache to get these changes working.
Step18: Configure .htaccess for selecting the required php version. By default, the server will usePHP5.4 for serving php files. For changing this to PHP5.6, we need to specify the same in .htaccess file located in the document root of the domain.
You can select any two php versions of your choice and configure them with apache in the same way, as we described here. Good luck with your experiments !!!
Composed by: Geordin and Prajith