Software Collections:PHP

From SME Server
Revision as of 15:59, 8 May 2019 by ReetP (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Important.png Note:
Please see the PHP-scl contribs page for a contrib that fully automates the installation of a PHP version. The below info is based on manual installation.

Softwarecollections.png

Php.jpg


Warning.png Warning:
Please check the following site for notes on EOL for different versions of PHP. As of May 2019 the minimum supported version of PHP is 7.1 but only for security updates until 30th November 2019

https://www.php.net/supported-versions.php

Note that the default installed version of PHP on Koozali SME is 5.3.3 and that is supported for security updates by RedHat only until the distro goes EOL. However, it may not be supported by applications.


run php54 on a hosted website (virtual host)

Install php54 from scl repo

yum --enablerepo=scl-php54 install php54-php.x86_64  

Verify the installation,

 scl enable php54 'php -v' 

It should return this version (or higher)

PHP 5.4.16 (cli) (built: Jul 10 2014 10:06:38)

Create a template fragment that will enable apache to invoke php54 for a virtual domain

nano /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/70php54

paste this code fragment (including the last empty line):

{ 
  use esmith::DomainsDB;
  my $domains = esmith::DomainsDB->open_ro;
	if (($domains->get_prop($virtualHost, 'php54') || 'disabled')
         eq 'enabled')
		{
				$OUT = "    #Enable php54 through Cgi-Bin wrapper. Needs a wrapper script in /cgi-bin/php54-wrapper\n";
				$OUT .= "    AddHandler php-cgi .php\n";
				$OUT .= "    Action php-cgi /cgi-bin/php54-wrapper\n";
				$OUT .= "    <Location />\n";
				$OUT .= "       Options +ExecCGI\n";
				$OUT .= "    </Location>\n";
		}
 }

and Save with <CTRL>-X - yes.

Create the cgi-wrapper script:

nano ~<Ibayname of MyVirtualDomain>/../cgi-bin/php54-wrapper

Insert this code fragment:

#!/bin/bash
source /opt/rh/php54/enable
exec php-cgi

and Save with <CTRL>-X - yes.

Then execute these commands:

cd ~<Ibayname of MyVirtualDomain>/../cgi-bin/
restorecon -RF php54-wrapper
chown www:www php54-wrapper
chmod ugo-rwx php54-wrapper
chmod ug+rx php54-wrapper

The template fragment for httpd.conf needs a database setting to be enabled for the (virtual) domain.

Check with

db domains show <myVirtualDomain.com>

Edit with

db domains setprop <myVirtualDomain.com> php54 enabled

To enable this run:

expand-template /etc/httpd/conf/httpd.conf
/etc/init.d/httpd-e-smith restart

Notes:

  • This version of php uses the /opt/rh/php54/root/etc/php.ini file which uses default settings as configured by RedHat, use at your own risk. Adjust the settings according to your (security) needs.
  • Using Cgi-Bin wrapper scripts makes your system vulnerable to Shellshock server bash vulnerability, make sure your server runs the latest version of bash.
  • This example and code still have to be tested (I will soon).
  • Source: This HowTo for CENTOS6


Other articles in this category

PHP Software Collections, Software Collections, Software Collections Repositories, Software Collections:MariaDB, Software Collections:MongoDB, Software Collections:MySQL, Software Collections:MySQL55, Software Collections:MySQL57, Software Collections:Nodejs, Software Collections:PHP, Software Collections:PostgreSQL, Software Collections:Python, Software Collections:Ruby on Rails