I was going to post this in the LET thread, but it doesn't appear to like my code.
Switching the DirectAdmin php system to use the Remi repository of PHP seems to be fairly easy. I thought I'd take a shot at providing a loose guide on how it might be accomplished. I didn't really follow all of this, I'm kind of creating this guide backwards. Initially I created my own php-fpm service linking to it through DirectAdmin hooks, but this way might be more straightforward for normal users and might provide some insight to DirectAdmin on how they might integrate this into their own system. I'm sure there are some tweaks that could be made to this.
I'm using CentOS 7 as my base.
Before you start, you need to be sure that Custombuild has already compiled a PHP 7.1 version. This could probably be avoided if DirectAdmin had a way to integrate the Remi repository and packaged PHP binaries into CustomBuild, but for the purpose of this guide, we have to have this already
Make sure your /usr/local/directadmin/custombuild/options.conf file has
php1_release=7.1
php1_mode=php-fpm
Then rebuild php if necessary
/usr/local/directadmin/custombuild/build php
Now you need to install the Remi repository - see https://blog.remirepo.net/pages/Config-en for more details
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
All of the repositories are disabled by default, except for remi-safe, but I'm going to go ahead and disable that as well
yum-config-manager --disable remi-safe
Before you can begin you have to install some requirements for PHP:
yum install environment-modules jbigkit-libs libedit-devel libmcrypt libtidy libtiff libtool-ltdl libxml2-devel libxslt ncurses-devel scl-utils tcl xz-devel libargon2-devel libargon2
I'm doing this here, because in the next step when I install PHP 7.1, I'm not going to have access to any other repositories.
To install PHP 7.1 from Remi:
yum --disablerepo=* --enablerepo=remi-safe --disableexcludes=all --exclude="$(cat /etc/yum.conf | grep ^exclude | cut -d = -f 2 | sed "s/php\* //g")" install php71-php-json php71-php-xml php71 php71-php-soap php71-php-opcache php71-php-bcmath php71-runtime-2.0 php71-php-pdo php71-php-devel php71-php-ioncube php71-php-mbstring php71-php-tidy php71-php-cli php71-php-mysqlnd php71-php-gd php71-php-intl php71-php-gmp php71-php-process php71-php-common php71-php-xmlrpc php71-php-mcrypt php71-php-pecl php71-php-imap php71-php-fpm
Once this is complete you need to change the DirectAdmin compiled PHP 7.1 to this new Remi controlled PHP 7.1
systemctl stop php-fpm71.service
mv /usr/local/php71 /usr/local/php71-da ## Move the DirectAdmin compiled PHP 7.1 out of the way
ln -s /opt/remi/php71/root /usr/local/php71 ## Replace the DirectAdmin compiled PHP 7.1 directory with the Remi PHP 7.1 root directory
ln -s /usr/local/php71/bin/php /usr/local/php71/bin/php71 ## The DirectAdmin compiled PHP 7.1 names the binaries php71 instead of php - so symlink them
ln -s /usr/local/php71/sbin/php-fpm /usr/local/php71/sbin/php-fpm71
mkdir -p /usr/local/php71/etc
cp /usr/local/php71-da/etc/php-fpm.conf /usr/local/php71/etc/php-fpm.conf ## This file could be created separately, but for the purpose of this exercise we'll just move the php-fpm.conf from the (moved) DirectAdmin PHP 7.1 compiled version into this new Remi controlled directory
mkdir -p /usr/local/php71/sockets
chown apache:apache /usr/local/php71/sockets ## This directory needs to be created and ownership changed to house the individual php-fpm sockets
systemctl start php-fpm71.service
That's it.
The main reason you need CustomBuild to initially compile PHP 7.1 is for the file - /usr/local/php71/etc/php-fpm.conf - which can easily be duplicated without compile. And for the creation of the php-fpm71.service file - /etc/systemd/system/php-fpm71.service - which again could be easily duplicated
Now as a reminder, you can't use CustomBuild to recompile PHP 7.1 because that's going to mess up this changed directory structure.
/usr/local/directadmin/custombuild/build versions
Will show you if PHP 7.1 is out of date, but to update it you would need to do something like:
yum --disablerepo=* --enablerepo=remi-safe --disableexcludes=all --exclude="$(cat /etc/yum.conf | grep ^exclude | cut -d = -f 2 | sed "s/php\* //g")" update php71
Like I said, there's probably a more eloquent way of doing all of this. I know this is a bit rough around the edges. It's just kind of meant as a Proof of Concept.
This should be duplicatable with PHP 7.2 and PHP 7.3 (Not sure about EOL versions of PHP).
My proposition would be for DirectAdmin's CustomBuild to add another option to the options.conf file, something like:
php1_source="remi"
or
php1_source="compiled"
And if this is set to "remi" then something like the above is done instead of compiling php.
Switching the DirectAdmin php system to use the Remi repository of PHP seems to be fairly easy. I thought I'd take a shot at providing a loose guide on how it might be accomplished. I didn't really follow all of this, I'm kind of creating this guide backwards. Initially I created my own php-fpm service linking to it through DirectAdmin hooks, but this way might be more straightforward for normal users and might provide some insight to DirectAdmin on how they might integrate this into their own system. I'm sure there are some tweaks that could be made to this.
I'm using CentOS 7 as my base.
Before you start, you need to be sure that Custombuild has already compiled a PHP 7.1 version. This could probably be avoided if DirectAdmin had a way to integrate the Remi repository and packaged PHP binaries into CustomBuild, but for the purpose of this guide, we have to have this already
Make sure your /usr/local/directadmin/custombuild/options.conf file has
php1_release=7.1
php1_mode=php-fpm
Then rebuild php if necessary
/usr/local/directadmin/custombuild/build php
Now you need to install the Remi repository - see https://blog.remirepo.net/pages/Config-en for more details
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
All of the repositories are disabled by default, except for remi-safe, but I'm going to go ahead and disable that as well
yum-config-manager --disable remi-safe
Before you can begin you have to install some requirements for PHP:
yum install environment-modules jbigkit-libs libedit-devel libmcrypt libtidy libtiff libtool-ltdl libxml2-devel libxslt ncurses-devel scl-utils tcl xz-devel libargon2-devel libargon2
I'm doing this here, because in the next step when I install PHP 7.1, I'm not going to have access to any other repositories.
To install PHP 7.1 from Remi:
yum --disablerepo=* --enablerepo=remi-safe --disableexcludes=all --exclude="$(cat /etc/yum.conf | grep ^exclude | cut -d = -f 2 | sed "s/php\* //g")" install php71-php-json php71-php-xml php71 php71-php-soap php71-php-opcache php71-php-bcmath php71-runtime-2.0 php71-php-pdo php71-php-devel php71-php-ioncube php71-php-mbstring php71-php-tidy php71-php-cli php71-php-mysqlnd php71-php-gd php71-php-intl php71-php-gmp php71-php-process php71-php-common php71-php-xmlrpc php71-php-mcrypt php71-php-pecl php71-php-imap php71-php-fpm
Once this is complete you need to change the DirectAdmin compiled PHP 7.1 to this new Remi controlled PHP 7.1
systemctl stop php-fpm71.service
mv /usr/local/php71 /usr/local/php71-da ## Move the DirectAdmin compiled PHP 7.1 out of the way
ln -s /opt/remi/php71/root /usr/local/php71 ## Replace the DirectAdmin compiled PHP 7.1 directory with the Remi PHP 7.1 root directory
ln -s /usr/local/php71/bin/php /usr/local/php71/bin/php71 ## The DirectAdmin compiled PHP 7.1 names the binaries php71 instead of php - so symlink them
ln -s /usr/local/php71/sbin/php-fpm /usr/local/php71/sbin/php-fpm71
mkdir -p /usr/local/php71/etc
cp /usr/local/php71-da/etc/php-fpm.conf /usr/local/php71/etc/php-fpm.conf ## This file could be created separately, but for the purpose of this exercise we'll just move the php-fpm.conf from the (moved) DirectAdmin PHP 7.1 compiled version into this new Remi controlled directory
mkdir -p /usr/local/php71/sockets
chown apache:apache /usr/local/php71/sockets ## This directory needs to be created and ownership changed to house the individual php-fpm sockets
systemctl start php-fpm71.service
That's it.
The main reason you need CustomBuild to initially compile PHP 7.1 is for the file - /usr/local/php71/etc/php-fpm.conf - which can easily be duplicated without compile. And for the creation of the php-fpm71.service file - /etc/systemd/system/php-fpm71.service - which again could be easily duplicated
Now as a reminder, you can't use CustomBuild to recompile PHP 7.1 because that's going to mess up this changed directory structure.
/usr/local/directadmin/custombuild/build versions
Will show you if PHP 7.1 is out of date, but to update it you would need to do something like:
yum --disablerepo=* --enablerepo=remi-safe --disableexcludes=all --exclude="$(cat /etc/yum.conf | grep ^exclude | cut -d = -f 2 | sed "s/php\* //g")" update php71
Like I said, there's probably a more eloquent way of doing all of this. I know this is a bit rough around the edges. It's just kind of meant as a Proof of Concept.
This should be duplicatable with PHP 7.2 and PHP 7.3 (Not sure about EOL versions of PHP).
My proposition would be for DirectAdmin's CustomBuild to add another option to the options.conf file, something like:
php1_source="remi"
or
php1_source="compiled"
And if this is set to "remi" then something like the above is done instead of compiling php.