In connection to my post Running multiple PHP versions on CentOS 7 using Virtualmin, this guide will show how to install additional PHP 7.0 version on CentOS 7 by using the Software Collections and have Virtualmin detect and use it.
Here are the steps:
Login as root to your server's console terminal.
-
Install the CentOS Linux Software Collections release file:
yum install centos-release-scl
-
Install the PHP package:
yum install rh-php70
-
(Optional) To start using Software Collections with new bash instance with PHP version 5.6:
scl enable rh-php70 bash
To verify it:
php -v
You should see the PHP version 7.0 instead of system's default version.
-
Virtualmin can't detect the default path /opt/rh/rh-php70/ created by the installation as it parse directory by /opt/rh/php*. As solution, lets create a symbolic link in able Virtualmin detect our newly installed PHP 7.0:
ln -s /opt/rh/rh-php70/ /opt/rh/php70
-
Login to your Virtualmin and go to System Settings -> Re-Check Configuration. You should see one of the line look something like this:
The following PHP versions are available : 5.4.16 (/bin/php-cgi), 5.6.5 (/opt/rh/php56/root/usr/bin/php-cgi), 7.0.10 (/opt/rh/rh-php70/root/usr/bin/php-cgi)
-
Now lets change an existing virtual server to use the PHP version 7.0.10. Select a virtual server that needs PHP version 7.0.10 from the dropdown menu, go to Server Configuration -> PHP Versions and click the "Save Versions" button:
-
To install extension modules (like MySQL driver, Opcache, etc.) for our new PHP version 7.0.10, first check what extension modules are available for our PHP 7.0 version by executing this command:
yum search php70
You should see something like this:
rh-php70-runtime.x86_64 : Package that handles rh-php70 Software Collection. rh-php70-scldevel.x86_64 : Package shipping development files for rh-php70 sclo-php70-php-pecl-propro-devel.x86_64 : sclo-php70-php-pecl-propro developer files (header) sclo-php70-php-pecl-raphf-devel.x86_64 : sclo-php70-php-pecl-raphf developer files (header) rh-php70.x86_64 : Package that installs PHP 7.0 rh-php70-build.x86_64 : Package shipping basic build configuration rh-php70-php.x86_64 : PHP scripting language for creating dynamic web sites rh-php70-php-bcmath.x86_64 : A module for PHP applications for using the bcmath library rh-php70-php-cli.x86_64 : Command-line interface for PHP rh-php70-php-common.x86_64 : Common files for PHP rh-php70-php-dba.x86_64 : A database abstraction layer module for PHP applications rh-php70-php-dbg.x86_64 : The interactive PHP debugger rh-php70-php-devel.x86_64 : Files needed for building PHP extensions rh-php70-php-embedded.x86_64 : PHP library for embedding in applications rh-php70-php-enchant.x86_64 : Enchant spelling extension for PHP applications rh-php70-php-fpm.x86_64 : PHP FastCGI Process Manager rh-php70-php-gd.x86_64 : A module for PHP applications for using the gd graphics library rh-php70-php-gmp.x86_64 : A module for PHP applications for using the GNU MP library rh-php70-php-intl.x86_64 : Internationalization extension for PHP applications rh-php70-php-json.x86_64 : JavaScript Object Notation extension for PHP rh-php70-php-ldap.x86_64 : A module for PHP applications that use LDAP rh-php70-php-mbstring.x86_64 : A module for PHP applications which need multi-byte string handling rh-php70-php-mysqlnd.x86_64 : A module for PHP applications that use MySQL databases rh-php70-php-odbc.x86_64 : A module for PHP applications that use ODBC databases rh-php70-php-opcache.x86_64 : The Zend OPcache rh-php70-php-pdo.x86_64 : A database access abstraction module for PHP applications rh-php70-php-pear.noarch : PHP Extension and Application Repository framework rh-php70-php-pgsql.x86_64 : A PostgreSQL database module for PHP rh-php70-php-process.x86_64 : Modules for PHP script using system process interfaces rh-php70-php-pspell.x86_64 : A module for PHP applications for using pspell interfaces rh-php70-php-recode.x86_64 : A module for PHP applications for using the recode library rh-php70-php-snmp.x86_64 : A module for PHP applications that query SNMP-managed devices rh-php70-php-soap.x86_64 : A module for PHP applications that use the SOAP protocol rh-php70-php-xml.x86_64 : A module for PHP applications which use XML rh-php70-php-xmlrpc.x86_64 : A module for PHP applications which use the XML-RPC protocol rh-php70-php-zip.x86_64 : ZIP archive management extension for PHP sclo-php70-php-imap.x86_64 : A module for PHP applications that use IMAP sclo-php70-php-mcrypt.x86_64 : Standard PHP module provides mcrypt library support sclo-php70-php-pecl-apcu.x86_64 : APC User Cache sclo-php70-php-pecl-apcu-bc.x86_64 : APCu Backwards Compatibility Module sclo-php70-php-pecl-apcu-devel.x86_64 : APCu developer files (header) sclo-php70-php-pecl-apfd.x86_64 : Always Populate Form Data sclo-php70-php-pecl-geoip.x86_64 : Extension to map IP addresses to geographic places sclo-php70-php-pecl-http.x86_64 : Extended HTTP support sclo-php70-php-pecl-http-devel.x86_64 : Extended HTTP support developer files (header) sclo-php70-php-pecl-igbinary.x86_64 : Replacement for the standard PHP serializer sclo-php70-php-pecl-igbinary-devel.x86_64 : Igbinary developer files (header) sclo-php70-php-pecl-imagick.x86_64 : Extension to create and modify images using ImageMagick sclo-php70-php-pecl-imagick-devel.x86_64 : imagick extension developer files (header) sclo-php70-php-pecl-lzf.x86_64 : Extension to handle LZF de/compression sclo-php70-php-pecl-memcached.x86_64 : Extension to work with the Memcached caching daemon sclo-php70-php-pecl-mongodb.x86_64 : MongoDB driver for PHP sclo-php70-php-pecl-msgpack.x86_64 : API for communicating with MessagePack serialization sclo-php70-php-pecl-msgpack-devel.x86_64 : MessagePack developer files (header) sclo-php70-php-pecl-propro.x86_64 : Property proxy sclo-php70-php-pecl-raphf.x86_64 : Resource and persistent handles factory sclo-php70-php-pecl-redis.x86_64 : Extension for communicating with the Redis key-value store sclo-php70-php-pecl-selinux.x86_64 : SELinux binding for PHP scripting language sclo-php70-php-pecl-solr2.x86_64 : Object oriented API to Apache Solr sclo-php70-php-pecl-uploadprogress.x86_64 : An extension to track progress of a file upload sclo-php70-php-pecl-uuid.x86_64 : Universally Unique Identifier extension for PHP sclo-php70-php-pecl-xattr.x86_64 : Extended attributes sclo-php70-php-pecl-xdebug.x86_64 : PECL package for debugging PHP scripts sclo-php70-php-smbclient.x86_64 : PHP wrapper for libsmbclient sclo-php70-php-tidy.x86_64 : Standard PHP module provides tidy library support
-
We will install the PHP extension modules: MySQL driver, Zend OPcache, Memcached caching daemon, gd graphics library, multi-byte string handling and MongoDB database driver.
yum install rh-php70-php-mysqlnd rh-php70-php-opcache sclo-php70-php-pecl-memcached rh-php70-php-gd rh-php70-php-mbstring sclo-php70-php-pecl-mongodb
-
Reset the Apache web server:
systemctl restart httpd.service
Related to the official…
Related to the official documentation (https://www.virtualmin.com/documentation/web/multiplephp) this is the best help on the web to use Php 7 with cli and add modules.
Thanks.