PHP Software Collections

From SME Server
Jump to: navigation, search

PythonIcon.png Skill level: Easy
The instructions for installing and using php scl can be followed by a beginner, changing options requires a basic knowledge of linux.

Is this article helpful to you?
Please consider donating or volunteering
Thank you!

PHP Software Collections for SME Server

Maintainer

stephdl Stéphane de Labrusse AKA Stephdl

Version

Devel 9:
Contrib 9:
smeserver-php-scl
The latest version of smeserver-php-scl is available in the SME repository, click on the version number(s) for more information.


Description

The purpose of the contribs is to install PHP54, PHP55, PHP56, PHP70, PHP71 alongside the default php version installed with SME9 without having to remove or change the default php installation. We use the rpms from the remi-safe repository which are in fact the same as those on the official official web site, but have the advantage of providing more choices.

All PHP rpms are installed in /opt , this prevents any interference or conflict with the default install of PHP.

Requirements

Warning.png Warning:
Only for SME Server 9 64 bit

Installation

Base installation

Simple repo installation

These repos can now be easily added using a rpm

yum --enablerepo=smeaddons install smeserver-extrarepositories-epel, smeserver-extrarepositories-remi-safe

Manual repo installation

Remember to first configure the required remi-safe repository,

issue the following command on the SME Server shell:

/sbin/e-smith/db yum_repositories set remi-safe repository \
Name 'Remi - safe' \
BaseURL 'http://rpms.famillecollet.com/enterprise/$releasever/safe/$basearch/' \
EnableGroups no \
GPGCheck yes \
GPGKey http://rpms.famillecollet.com/RPM-GPG-KEY-remi \
Visible yes \
status enabled


you might also need epel repository,


/sbin/e-smith/db yum_repositories set epel repository \
Name 'Epel' \
BaseURL 'http://download.fedoraproject.org/pub/epel/$releasever/$basearch' \
MirrorList 'http://mirrors.fedoraproject.org/mirrorlist?repo=epel-$releasever&arch=$basearch' \
EnableGroups no \
GPGCheck yes \
GPGKey http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL \
Exclude perl-Razor-Agent \
Visible no \
status disabled


then you need to issue this command before installing:

 signal-event yum-modify

the minimal installation can simply be done doing :

yum install smeserver-php-scl --enablerepo=smecontribs

If you do not want to restart your server

signal-event php-update; config set UnsavedChanges no

or

signal-event post-upgrade; signal-event reboot

Go to the php-scl panel on Server Manager and activate the version of php you desire for each Ibay, or if you need for the whole server.

if you need additional php packages consider advanced install

Advanced installation

To install additional php rpm, as an example you might need the following components of php : php56-php-pecl-rar php56-php-libvirt php56-php-magickwand

yum install smeserver-php-scl php56-php-pecl-rar php56-php-libvirt php56-php-magickwand --enablerepo=smecontribs,epel

If you need additional PHP modules (e.g. for Nextcloud, Redis) you need to include the required PHP Redis modules (php71-php-pecl-redis php70-php-pecl-redis):

yum --enablerepo=remi,epel install php71-php-pecl-redis php70-php-pecl-redis

If you do not want to restart your server

signal-event php-update; config set UnsavedChanges no

or

signal-event post-upgrade; signal-event reboot

Go to the php-scl panel on Server Manager and activate the version of php you desire for each Ibay, or if you need for the whole server.

Limitation

If you use scl_php56/scl_php54/scl_php55 for the whole server, You can add also specific values (MemoryLimit,UpMaxFileSize,PostMaxSize,MaxExecTime,AllowUrlfOpen) per Ibay (either by db command or by the contrib smeserver-webhosting) because apache is the handler of php.

If you use scl_php71,scl_php70,scl_php56,scl_php55,scl_php54 per ibay, then you use php with a cgi application and you cannot add specific setting to apache with php_admin_flag or php_admin_value. Then if you want to add a specific setting like in Usage you must use it for the whole php applications by the command you can find in Usage

It is the limitation of php-scl

In short

  • PHP SCL for the whole server -> all settings can be set per Ibay normally with db or with smeserver-webhosting (these settings will overwritten those set in Usage)
  • PHP SCL per Ibay -> all settings must be set in each php{54,55,56} properties like in Usage. Of course all php applications (whatever the Ibay) will share the same settings.

Usage

When you want to change the version of php, you can use the panel (Php-Scl versions), either for changing the php version for an Ibay or for the whole server.

However if you want to change settings of a specific php version you have to use the command line, first see the new db entries.

After each modification don't forget to launch the event 'signal-event php-update'

[root@sme9b3dev64 ~]# config show php54
php54=configuration
   AllowUrlFopen=Off     #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M
[root@sme9b3dev64 ~]# config show php55
php55=configuration
   AllowUrlFopen=Off     #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M
[root@sme9b3dev64 ~]# config show php56
php56=configuration
   AllowUrlFopen=Off      #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M
[root@sme9b3dev64 ~]# config show php70
php70=configuration
   AllowUrlFopen=Off      #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M
[root@sme9b3dev64 ~]# config show php71
php71=configuration
   AllowUrlFopen=Off      #(On/Off)
   MaxExecutionTime=30
   MaxFileUpload=20
   MaxInputTime=60
   MemoryLimit=128M
   PhpModule=disabled    #(enabled/disabled)
   PostMaxSize=20M
   UploadMaxFilesize=10M

in fact you can choose manually (think about you have a panel for that) which version you want to use in the phpmod of apache (only one version can be used), for example

config setprop php56 PhpModule enabled
signal-event php-update

Since just one version can be used with php-mod, the lower version is used....all disabled and it is the php default version which is used

Run a command with a specific software environment

You can run a command from the shell with a specific env with:

scl enable php55 'php -v'

(useful for example if you need to run a cron job with an alternative PHP version)

Find other RPMS

Important.png Note:
Now when you want a specific rpm, you have to install it from the 'remi-safe' repository. The name start by php54-php or php55-php or php56-php

here all the rpm available : http://rpms.famillecollet.com/enterprise/6/safe/x86_64/repoview/letter_p.group.html


If you want to see available rpm

yum list available php5\* --disablerepo=* --enablerepo=remi-safe

For example if you want to install the php rpm for pgsql

yum install php54-php-pgsql php55-php-pgsql php56-php-pgsql php70-php-pgsql php71-php-pgsql --enablerepo=remi-safe

Update

base install

  1. If you enabled smecontribs repo there will be nothing to do, all updates will propagated on their own with usual updates as remi-safe is enabled.
  1. If smecontribs is not enabled, you will need to issuethe following:
yum update smeserver-php-scl php54* php55* php56* php70* php71* --enablerepo=smecontribs

Advanced install

The repo remi-safe is enabled by default as it has no conflicts with base installation. Please do not enable epel repo by default, as you might break you system or at least the update process.

regularly you should check for updates and apply them by doing so:

yum update smeserver-php-scl php54* php55* php56* php70* php71*  --enablerepo=smecontribs,remi-safe,epel

Uninstall

yum remove smeserver-php-scl

Custom Templates

If you need to modify the php.ini you can add a custom template.

Make a new directory here and add you template fragment:

/etc/e-smith/templates-custom/opt/remi/php{$ver}/root/etc/php.ini

Debug

Setup

This demonstrates how to get xdebug going for a given version - in this case PHP 5.6

yum --enablerepo=remi-safe install php56-php-pecl-xdebug

For OpenBaseDir errors add the pear path:

db accounts setprop myibay PHPBaseDir /home/e-smith/files/ibays/myibay/html/:/usr/share/pear/:/usr/share/pear-addons/:/tmp/:/opt/remi/php56/root/usr/share/pear/
signal-event php-update;signal-event ibay-modify

Enable

To enable the debugger:

Now edit the following file according to your needs:

/etc/e-smith/templates/opt/remi/php56/root/etc/php.ini

Standard direct connection

[Debugger]
debugger.host                          = localhost
debugger.port                          = 7869
debugger.enabled                       = False
zend_extension                          = "/usr/lib64/php/modules/xdebug.so"
zend_debugger.allow_hosts               = 192.168.10.0/24
zend_debugger.expose_remotely           = always
zend_debugger.httpd_uid                 = 102
zend_debugger.httpd_uid                 = -1
signal-event php-update

You should be able to connect with your debugger pointed to the correct port and IP address of the server, and using a URL like this:

https://test.myserver.com/TestFile.php?XDEBUG_SESSION_START

Using pydbg proxy

[Debugger]
xdebug.remote_enable                   = true
xdebug.remote_host                     = 127.0.0.1
xdebug.remote_port                     = 9000
xdebug.remote_handler                  = dbgp
xdebug.remote_log                      = /var/log/xdebug.log
xdebug.remote_mode                     = req
xdebug.idekey                          = users
signal-event php-update

Then run the debug proxy with something like this

python /root/dbgp/bin/pydbgpproxy -d 127.0.0.1:9000 -i 192.168.10.1:9001 -l DEBUG

You should be able to connect with your debugger pointed to the correct port 9001 and IP address of your server, and using a URL like this:

https://test.myserver.com/TestFile.php?XDEBUG_SESSION_START=users

Bugs

Please raise bugs under the SME-Contribs section in bugzilla and select the smeserver-php-scl component or use this link .

IDProductVersionStatusSummary (2 tasks)
10508SME Contribs9.2RESOLVEDadd php72 and php73 support
10243SME ContribsFuturCONFIRMEDuse php-fpm (FastCGI Process Manager) rather than php-cgi

Changelog

Only released version in smecontrib are listed here.

smeserver-php-scl Changelog: SME 9 (smecontribs)
2018/08/14 John Crisp 0.4-17.sme
- Fix typo in Soap template
2017/12/02 SME Translation Server 0.4-16.sme
- apply locale 2017-12-02 patch
2017/07/04 Jean-Philipe Pialasse 0.4-15.sme
- fix path to php session for php7 [SME: 10365]
2017/06/26 Jean-Philipe Pialasse 0.4-14.sme
- fix wrong path to 7.0 and 7.1 lib [SME: 10355]
2017/06/09 Jean-Philipe Pialasse 0.4-12.sme
- fix wrong path for php7* php.ini template [SME: 10343]