Home MiscellaneousMastering Custom PHP Module Installation on RunCloud: A Step-by-Step Guide

Mastering Custom PHP Module Installation on RunCloud: A Step-by-Step Guide

by SupportPRO Admin

RunCloud provides its own PHP versions, which are different from Ubuntu’s default ones. So, instead of using apt-get install php-* to install PHP modules, which can cause conflicts with RunCloud’s setup, it’s recommended that the modules be manually compiled and installed for compatibility.

Below are the complete instructions for compiling and installing custom PHP modules on RunCloud Nginx servers.

Before getting started, ensure that you have root access to the server. You can authenticate using either the root password or an SSH key.

Step 1:

The first step is to install the necessary development tools. The command below installs autoconf for configuration scripts and libpcre3-dev for developing regular expressions.

apt-get install autoconf libpcre3-dev

apt-get install libmcrypt-dev libreadline-dev

Step 2:

Next, download the necessary extension from PECL—a repository for PHP extensions. You’ll need the source code archive to compile and install the extension on your system. Use the wget command to download the archived files.

wget  https://pecl.php.net/get/extension.version.tgz

Replace extension.version.tgz with the specific module and version you need. For example:

wget  https://pecl.php.net/get/mcrypt-1.0.4.tgz

In the example above, mcrypt is the module name, and 1.0.4 is the version.

Step 3:

Change the directory to the extracted module directory.

cd extension.version.tgz

 Step 4:

Installing the module:

#Clean Previous Builds:

make clean

#Clean the PHPize Build Environment

/RunCloud/Packages/phpXXrc/bin/phpize –clean

#Prepare the Build Environment with PHPize

/RunCloud/Packages/phpXXrc/bin/phpize

#Configure the Build

./configure –with-php-config=/RunCloud/Packages/phpXXrc/bin/php-config –with-libdir=lib64 CFLAGS=’-O2 -fPIE -fstack-protector-strong -Wformat -Werror=format-security -Wall -pedantic -fsigned-char -fno-strict-aliasing’

Note: The ‘XX’ in the commands above should be replaced with the PHP version for which you need the module installed. For example, if you’re working with PHP 7.4, use ‘php74rc,’ and for PHP 8.3, use ‘php83rc.

#Compile and Install the Extension

make install

#Enable the Extension in PHP

echo “extension=extension.so” > /etc/phpXXrc/conf.d/mcrypt.ini

Change the “extension” in the above command to the name of the extension. For example:

echo “extension=mcrypt.so” > /etc/php74rc/conf.d/mcrypt.ini

Step 5:

Final step of the installation procedure, restart the PHP-fpm service and verify the installation.

systemctl restart phpXXrc-fpm  

/RunCloud/Packages/phpXXrc/bin/php -m 

Remember to replace the “XX” with the correct PHP version.

Example:

systemctl restart php74rc-fpm  

/RunCloud/Packages/php74rc/bin/php -m | mcrypt

Facing issues?

Our technical support
engineers can solve it.

Contact Us today!
guy server checkup

You may also like

Leave a Comment