Difference between revisions of "Software Collections:PHP"
Line 1: | Line 1: | ||
{{WIP box}} | {{WIP box}} | ||
+ | {{Note box|Please see http://forums.contribs.org/index.php/topic,51487.0.html for a contrib in development that fully automates the installation of a PHP version}} | ||
<blockquote style="float: right;"> | <blockquote style="float: right;"> | ||
[[File:softwarecollections.png|100px]] | [[File:softwarecollections.png|100px]] |
Revision as of 10:13, 8 February 2015
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
Mysql57, PHP Software Collections, Software Collections, Software Collections Repositories, Software Collections:MariaDB, Software Collections:MongoDB, Software Collections:MySQL, Software Collections:MySQL55, Software Collections:Nodejs, Software Collections:PHP, Software Collections:PostgreSQL, Software Collections:Python, Software Collections:Ruby on Rails