Applicable to:
- Plesk for Linux
Question
How to add additional PHP module for PHP engines shipped with Plesk on Linux?
Answer
Note: The resolution steps described in this article require administrative permissions and SSH access to the server with Plesk installed. Contact the server administrator if necessary.
Note: if you are interested in installing Memcached or Memcache modules, see the following article: How to install/uninstall memcached or memcache extension for PHP on Plesk server?
Starting from Plesk 12.0 it is possible to have multiple PHP versions out of the box. Additional PHP versions can be easily installed via Plesk Installer. The installation path is /opt/plesk/php/
:
# ls -l /opt/plesk/php/
total 16
drwxr-xr-x 8 root root 4096 Jun 6 14:52 5.6
drwxr-xr-x 8 root root 4096 Jun 6 14:52 7.0
drwxr-xr-x 8 root root 4096 Jun 6 14:51 7.1
drwxr-xr-x 8 root root 4096 Jun 6 14:51 7.2
PHP versions shipped with Plesk already has a pre-defined set of modules that commonly used.
# /opt/plesk/php/7.0/bin/php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dba
dom
enchant
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
imagick
imap
intl
ionCube Loader
json
ldap
libxml
mbstring
mcrypt
mysqli
mysqlnd
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
PDO_ODBC
pdo_pgsql
pdo_sqlite
pgsql
Phar
posix
pspell
readline
redis
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
Zend OPcache
zip
zlib
[Zend Modules]
Zend OPcache
the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured)
However, sometimes to match system requirements for particular PHP applications it is necessary to install and enable additional PHP module that is not in the list. The steps below explain how to do that.
Note: Installing of the additional PHP modules is a part of the server maintenance duty and should be performed by the Plesk server's administrator on his own.
Warning: This is a process that it is done at your own will and risk which is not supported by Plesk.
Prerequisites
CONFIG_TEXT: PHP version - 7.0
Additional PHP module: Mailparse
-
Connect to the server via SSH
-
Enable EPEL repository:
# yum install epel-release
-
Install devel packages:
# yum install gcc plesk-php70-devel zlib-devel re2c
Note: Name of the devel package for another PHP version will be different, e.g. for PHP 7.1 it will be
plesk-php71-devel
. In some cases additional librbary package should be installed as well -
Install the module using PECL:
Warning: If /tmp is mounted with no-exec option, PECL will be unable to install modules. For more information, see this article: Error while using pecl install: shtool at /tmp does not exist or is not executable.
# /opt/plesk/php/7.0/bin/pecl install mailparse
...
Build process completed successfully
Installing '/opt/plesk/php/7.0/lib64/php/modules/mailparse.so'
install ok: channel://pecl.php.net/mailparse-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=mailparse.so" to php.ini -
Create an
.ini
configuration file for the module and add extension directive to enable the module:# echo "extension=mailparse.so" > /opt/plesk/php/7.0/etc/php.d/mailparse.ini
-
Check that module is enabled:
# /opt/plesk/php/7.0/bin/php -m | grep mailparse
mailparse -
Refresh the information about PHP handlers in Plesk:
# plesk bin php_handler --reread
-
Refresh the information about server components in Plesk:
# plesk sbin packagemng -sdf
This extension will appear in Plesk under Tools & Settings > PHP Settings > [PHP_version].
-
Connect to the server via SSH
-
Install devel packages:
# apt install autoconf automake gcc libhashkit-dev pkg-config plesk-php70-dev zlib1g-dev
Note: Name of the devel package for another PHP version will be different, e.g. for PHP 7.1 it will be plesk-php71-devel. In some cases additional librbary package should be installed as well
-
Install the module using PECL:
Warning: If /tmp is mounted with no-exec option, PECL will be unable to install modules. For more information, see this article: Error while using pecl install: shtool at /tmp does not exist or is not executable.
# /opt/plesk/php/7.0/bin/pecl install mailparse
...
Installing '/opt/plesk/php/7.0/lib/php/modules/mailparse.so'
install ok: channel://pecl.php.net/mailparse-3.0.2
configuration option "php_ini" is not set to php.ini location
You should add "extension=mailparse.so" to php.ini -
Create an
.ini
configuration file for the module and add extension directive to enable the module:# echo "extension=mailparse.so" > /opt/plesk/php/7.0/etc/php.d/mailparse.ini
-
Check that module is enabled:
# /opt/plesk/php/7.0/bin/php -m | grep mailparse
mailparse -
Refresh the information about PHP handlers in Plesk:
# plesk bin php_handler --reread
-
Refresh the information about server components in Plesk:
# plesk sbin packagemng -sdf
This extension will appear in Plesk under Tools & Settings > PHP Settings > [PHP_version].
The same steps can be applied to install any other available extension. List of packages available to install via PECL can be find here
Installation errors and troubleshooting
-
Installation of some modules, like memcached, can fail due to missing libraries:
# /opt/plesk/php/7.0/bin/pecl install memcached
...
checking for libmemcached location... configure: error: memcached support requires libmemcached. Use --with-libmemcached-dir=<DIR> to specify the prefix where libmemcached headers and library are located
ERROR: `/tmp/memcached/configure --with-php-config=/opt/plesk/php/7.0/bin/php-config --with-libmemcached-dir=no' failedSearch for the required package using built-in package manager search, e.g.:
yum search on CentOS/RHEL
# yum search memcached | grep -i header
libmemcached-devel.i686 : Header files and development libraries for
libmemcached-devel.x86_64 : Header files and development libraries forapt search on Debian/Ubuntu
# apt search libmemcached | grep dev
libhashkit-dev/oldstable,now 1.0.18-4 amd64 [installed]
libmemcached hashing functions and algorithms (development files)
libmemcached-dev/oldstable 1.0.18-4 amd64
C and C++ client library to the memcached server (development files)Install the package and continue installing the module:
CentOS/RHEL
# yum install libmemcached-devel
Debian/Ubuntu
# apt install libhashkit-dev libmemcached-dev
-
If installation completed successfully, however module is not loaded with errors like the one below:
# /opt/plesk/php/7.0/bin/php -m | grep snmp
PHP Warning: PHP Startup: Unable to load dynamic library '/opt/plesk/php/7.0/lib64/php/modules/snmp' - /opt/plesk/php/7.0/lib64/php/modules/snmp: cannot open shared object file: No such file or directory in Unknown on line 0Make sure that there was no typo or syntax errors in .ini file that enables module, for example missing
.so
file extension:# cat /opt/plesk/php/7.0/etc/php.d/snmp.ini
; Enable snmp extension module
extension=snmp -
It is always a good practice to search for a solution in Internet for particular errors because adding of additional modules is not something Plesk specific, but common maintenance environment task.
Comments
0 comments
Please sign in to leave a comment.