{"id":50,"date":"2016-05-05T06:48:47","date_gmt":"2016-05-05T06:48:47","guid":{"rendered":"https:\/\/www.hostingahead.com\/blog\/?p=50"},"modified":"2016-05-05T06:48:47","modified_gmt":"2016-05-05T06:48:47","slug":"install-multiple-php-versions-linux","status":"publish","type":"post","link":"https:\/\/www.hostingahead.com\/blog\/install-multiple-php-versions-linux\/","title":{"rendered":"How to install multiple PHP versions on linux"},"content":{"rendered":"<p>You can install all versions of php either from source or install the default version using yum installer.<br \/>\nMy server has php5.3 already installed and I am going to install PHP5.6 from source.<\/p>\n<p><strong>Prerequisites<\/strong><\/p>\n<blockquote><p>Install suphp and configure<br \/>\nmkdir -p \/usr\/local\/php56<br \/>\nmkdir -p \/etc\/php56<br \/>\nmkdir -p \/etc\/php56\/php.d<\/p><\/blockquote>\n<p><strong>Download php5.6<\/strong><\/p>\n<blockquote><p>wget http:\/\/de1.php.net\/distributions\/php-5.6.19.tar.gz<\/p><\/blockquote>\n<p><strong>Compile php<\/strong><\/p>\n<blockquote><p>.\/configure \u2013prefix=\/usr\/local\/php56 \u2013with-config-file-path=\/etc\/php56 \u2013with-config-file-scan-dir=\/etc\/php56\/php.d \u2013with-libdir=lib64 \u2013with-mysql \u2013with-mysqli\u00a0 \u2013enable-mbstring \u2013disable-debug \u2013disable-rpath \u2013with-bz2 \u2013with-curl \u2013with-gettext \u2013with-iconv \u2013with-openssl \u2013with-gd \u2013with-mcrypt \u2013with-pcre-regex \u2013with-zlib \u2013enable-soap \u2013enable-sockets \u2013enable-zip \u2013enable-bcmath \u2013enable-calendar \u2013enable-exif \u2013enable-gd-native-ttf \u2013with-freetype-dir \u2013with-jpeg-dir \u2013with-png-dir<\/p><\/blockquote>\n<p>Notes: You may see errors that few packages were not installed. In most case you will need to install devel packages.<\/p>\n<p>eg: yum install libjpeg-turbo-devel<br \/>\nyum install libxml2-dev<br \/>\nyum install bzip2-devel<br \/>\nYou need to compile it again after installing the packages.<br \/>\nCopy php.ini file<\/p>\n<blockquote><p>cp php.ini-production \/usr\/local\/php56\/php.ini<\/p><\/blockquote>\n<p>In order to enable multiple PHP versions, we need to install suphp on the server. I assume the server has suphp configured already. Make the following changes<br \/>\n<strong>edit the file \/etc\/suphp.conf and add the line<\/strong><\/p>\n<blockquote><p>application\/x-httpd-php56=\u201dphp:\/usr\/local\/php56\/bin\/php-cgi\u201d<\/p><\/blockquote>\n<p><strong>Edit the file \/etc\/httpd\/conf.d\/php.conf and add following lines<\/strong><\/p>\n<blockquote><p>suPHP_AddHandler application\/x-httpd-php56<br \/>\nEnable PHP5.6 for a folder\/site<\/p><\/blockquote>\n<p><strong>create an .htaccess file and add following line<\/strong><\/p>\n<blockquote><p>AddHandler application\/x-httpd-php56 .php<\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>You can install all versions of php either from source or install the default version using yum installer. My server has php5.3 already installed and I am going to install PHP5.6 from source. Prerequisites Install suphp and configure mkdir -p \/usr\/local\/php56 mkdir -p \/etc\/php56 mkdir -p \/etc\/php56\/php.d Download php5.6 wget http:\/\/de1.php.net\/distributions\/php-5.6.19.tar.gz Compile php .\/configure \u2013prefix=\/usr\/local\/php56 &#8230;<\/p>\n","protected":false},"author":101012,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1,4,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/50"}],"collection":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/users\/101012"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":2,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":241,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/posts\/50\/revisions\/241"}],"wp:attachment":[{"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostingahead.com\/blog\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}