{"id":1939,"date":"2012-08-12T08:47:27","date_gmt":"2012-08-12T12:47:27","guid":{"rendered":"http:\/\/linuxhostingsupport.net\/blog\/?p=1939"},"modified":"2013-03-20T08:38:22","modified_gmt":"2013-03-20T12:38:22","slug":"how-to-install-php-5-2-and-php-5-3-together-on-cpanel-server","status":"publish","type":"post","link":"https:\/\/linuxhostingsupport.net\/blog\/how-to-install-php-5-2-and-php-5-3-together-on-cpanel-server","title":{"rendered":"How to install PHP 5.2 and PHP 5.3 together on cPanel server?"},"content":{"rendered":"<p>Although PHP 5.2 is becoming outdated, still a lot of applications and custom scripts still works on PHP 5.2. However, as per cPanel PHP 5.2 is &#8220;End of Life&#8221; and may stop offering it soon. So here is the guide for people who want PHP 5.2 along side PHP 5.3 on a cPanel server and make use of both the PHP versions at the same time.<\/p>\n<p>We are assuming the default PHP version installed on your sever is 5.3.x.<\/p>\n<p><strong>1.<\/strong> Download and untar PHP 5.2:<\/p>\n<blockquote>\n<pre># mkdir \/usr\/local\/buildphp52\r\n# cd \/usr\/local\/buildphp52\r\n# wget http:\/\/museum.php.net\/php5\/php-5.2.9.tar.gz\r\n# tar --strip-components=1 -zxvf php-5.2.*<\/pre>\n<\/blockquote>\n<p><strong>2.<\/strong> Configure and install PHP<\/p>\n<blockquote>\n<pre># .\/configure --prefix=\/usr\/local\/php52 --enable-cgi --enable-bcmath\\\r\n --enable-calendar --with-mysql=\/usr\/bin -with-libdir=lib64\\ --with-gd\\\r\n --enable-mbstring\u00a0\u00a0 (you can add more modules per your wish)\r\n # make\r\n # make install<\/pre>\n<\/blockquote>\n<p><strong>3.<\/strong> Now\u00a0add the PHP 5.2 handlers to Apache<\/p>\n<blockquote>\n<pre># pico\u00a0 \/usr\/local\/apache\/conf\/includes\/pre_virtualhost_global.conf<\/pre>\n<\/blockquote>\n<p>add the following:<\/p>\n<blockquote>\n<pre>Action application\/x-httpd-php52 \/cgi-sys\/php52\r\nAddType application\/x-httpd-php52 .php52<\/pre>\n<\/blockquote>\n<p><strong>4.<\/strong> Use Apache distiller for the above changes to take affect and make cPanel skip .htaccess scan and remove the mime types:<\/p>\n<blockquote>\n<pre># \/usr\/local\/cpanel\/bin\/apache_conf_distiller --update\r\n# touch \/var\/cpanel\/easy_skip_update_php_mime_types<\/pre>\n<\/blockquote>\n<p><strong>5.<\/strong> Now create a file under the cgi-sys directory of cPanel so it detects PHP 5.2<\/p>\n<blockquote>\n<pre># pico \/usr\/local\/cpanel\/cgi-sys\/php52<\/pre>\n<\/blockquote>\n<p>and add the following to it<\/p>\n<blockquote>\n<pre>#!\/bin\/sh\r\nexec \/usr\/local\/php52\/bin\/php-cgi<\/pre>\n<\/blockquote>\n<p><strong>6.<\/strong> Set the proper ownership\/permission<\/p>\n<blockquote>\n<pre># chown root:wheel \/usr\/local\/cpanel\/cgi-sys\/php52\r\n# chmod +x \/usr\/local\/cpanel\/cgi-sys\/php52<\/pre>\n<\/blockquote>\n<p><strong>7.<\/strong> Now copy the php configuration from the build directory of PHP 5.2<\/p>\n<blockquote>\n<pre># cp \/usr\/local\/buildphp52\/php.ini-production \/usr\/local\/php52\/lib\/php.ini<\/pre>\n<\/blockquote>\n<p><strong>8.<\/strong> Create a symlink for the PHP 5.2 executable to use from the command line:<\/p>\n<blockquote>\n<pre># ln -s \/usr\/local\/php52\/bin\/php-cgi \/usr\/local\/bin\/php52<\/pre>\n<\/blockquote>\n<p><strong>9.<\/strong> Once done, restart Apache for changes to take affect<\/p>\n<blockquote>\n<pre># service httpd restart<\/pre>\n<\/blockquote>\n<p><strong>10.<\/strong> Now, PHP 5.3 will work by default and <strong>to make PHP 5.2 work for a specific account OR a folder, create a .htaccess file inside it and add the PHP 5.2 Handler<\/strong><\/p>\n<blockquote>\n<pre>AddHandler application\/x-httpd-php52 .php<\/pre>\n<\/blockquote>\n<p>That&#8217;s it. Create a phpinfo page inside the folder and browse it to see if PHP 5.2 is in effect for that folder.<\/p>\n<p><strong>Things to note is<\/strong>:\u00a0 If you want to install OR compile a module with PHP 5.2, use appropriate php-config and phpize file, i.e.<\/p>\n<blockquote>\n<pre><strong>phpize<\/strong>: \/usr\/local\/php52\/bin\/phpize\r\n<strong>php-config<\/strong>: .\/configure --with-php-config=\/usr\/local\/php52\/bin\/php-config<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Although PHP 5.2 is becoming outdated, still a lot of applications and custom scripts still works on PHP 5.2. However, as per cPanel PHP 5.2 is &#8220;End of Life&#8221; and may stop offering it soon. So here is the guide for people who want PHP 5.2 along side PHP 5.3 on a cPanel server and make use of both the PHP versions at the same time.<br \/>\nWe are assuming the default PHP version installed on your sever is 5.3.x.<br \/>\n1. Download and untar PHP 5.2:<\/p>\n<p># mkdir \/usr\/local\/buildphp52<br \/>\n# cd \/usr\/local\/buildphp52<br \/>\n# wget [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1415,1416,1417,1418],"_links":{"self":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1939"}],"collection":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/comments?post=1939"}],"version-history":[{"count":13,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1939\/revisions"}],"predecessor-version":[{"id":1951,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/posts\/1939\/revisions\/1951"}],"wp:attachment":[{"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/media?parent=1939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/categories?post=1939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxhostingsupport.net\/blog\/wp-json\/wp\/v2\/tags?post=1939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}