Loading...
 

How to install a PHP version picker on ClearOS

2021-07-20: WikiSuite will now support all major Linux distros. Thus, the information below is no longer updated. It may still be valid, or not. It will be eventually removed from this site, so anything relevant should be moved to the appropriate site. For anything related to ClearOS, please search among the following: ClearOS site, code base, Developer docs, Wiki or forum.

Please contact us if you would like to help out.

ClearOS by default ships with an old version (5.4) of PHP. This app permits to use PHP 5.6, 7.0 and 7.1 from Software Collections (and later 7.2 for developers from Remi's RPM repository) by taking advantage of PHP's FastCGI Process Manager (FPM)


Status as of 2019-04-24: Added PHP 7.2 support: http://koji.clearos.com/koji/packageinfo?packageID=332

Status as of 2018-02-28: Officially announced: https://www.clearcenter.com/blogs/timeline/php-engines-app-now-live-in-the-clearos-marketplace

Status as of 2018-02-10: Now with PHP 7.1 and improvements to Command Line handling

Status as of 2017-11-24: The app is complete. Next step is to ask ClearOS community to test extensively.

Login to your ClearOS via SSH (as root)
yum install app-php-engines


And you will get:
ClearOS PHP Version Picker

Features

  • Permits to pick PHP version for various websites, including in the command line version.

How to override settings

We plan add a way to override settings via the GUI but for now, you need to edit some configuration files.

.user.ini

Create a .user.ini and put where in the directory where your Tiki is

memory_limit = 256M 
upload_max_filesize = 64M 
zlib.output_compression = 1

And if you want errors displayed, also add this
display_errors = On


If the values don't pick up, you can try rebooting your server or trying in php.ini instead (below)

memory_limit and max_execution_time can also be overridden in Tiki via tiki-admin.php?page=performance -> Time and Memory Limits


https://blog.ss88.uk/fast-cgi-and-user-ini-files-the-new-htaccess

php.ini

For some php.ini variables (ex.: post_max_size), you cannot override these settings in .user.ini, so these must be set in the PHP Engine's php.ini files

  • /etc/opt/rh/rh-php56/php.ini
  • /etc/opt/rh/rh-php70/php.ini
  • /etc/opt/rh/rh-php71/php.ini

If the values don't pick up, just reboot your server.

OPcache

OPcache is activated by default. So How to deactivate OPcache on ClearOS

Settings change be changed here:

  • /etc/opt/rh/rh-php56/php.d/10-opcache.ini
  • /etc/opt/rh/rh-php70/php.d/10-opcache.ini
  • /etc/opt/rh/rh-php71/php.d/10-opcache.ini

If the values don't pick up, just reboot your server.

Apache Proxy

See also: https://doc.tiki.org/How-to-install-Tiki-Manager-on-ClearOS#Timeouts_during_long_running_operations

Using the right version of PHP from the command line interface


Since each directory can have a different version of PHP, it uses the one from the current working directory.

This will use the PHP version which has been set for the test.example.org domain
* * * * * cd /var/www/virtual/test.example.org/html/ && php test.php >> /tmp/test.log

To manually set the PHP version to be used. Ex.: for CLI use outside the web directory

Create a .phpenv file with the desired PHP version, as follows:

.phpenv file content for PHP 7.1
71
.phpenv file content for PHP 7.0
70
.phpenv file content for PHP 5.6
56

Limitations