Issues with reinstalling or upgrading PHP8? The lastest installer within DirectAdmin uses Phar
to install pear modules and what not. When you have used secure_php, this will result in issues like the one below:
PHP Fatal error: Uncaught Error: Call to undefined function popen() in phar:///usr/local/directadmin/custombuild/php-8.0.6/pear/install-pear-nozlib.phar/OS/Guess.php:254 .. .. Makefile:548: recipe for target 'install-pear-installer' failed make[1]: *** [install-pear-installer] Error 255 Makefile:551: recipe for target 'install-pear' failed make: *** [install-pear] Error 2
Or
The service 'php-fpm80' on server xxx is currently down This message has been automatically generated notifying you that the service php-fpm80 is currently down.
The latter normally could be resolved with a service restart, but not if the system tried to update your PHP installation. To resolve this, a few tiny steps will need to be performed resulting in a tiny bit of additional risk to your shared hosting machine.
Step 1: Allow popen as a PHP function
# Set Settings for Disabled PHP Functions (removing popen from the default list)
cd /usr/local/directadmin/custombuild
echo "exec,system,passthru,shell_exec,proc_close,proc_open,dl,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname" > custom/php_disable_functions
# Rewrite the php.ini files
./build secure_php
Step 2: Reinstall PHP so it works
# Reinstall PHP (all versions as per options.conf)
cd /usr/local/directadmin/custombuild
./build php
.. Make Complete Making PHP 8.0 installation compatible with php.ini file Installing php... Installing PHP SAPI module: embed Installing shared extensions: /usr/local/php80/lib/php/extensions/no-debug-non-zts-20200930/ Installing PHP CLI binary: /usr/local/php80/bin/ Installing PHP CLI man page: /usr/local/php80/php/man/man1/ Installing PHP FPM binary: /usr/local/php80/sbin/ Installing PHP FPM defconfig: skipping Installing PHP FPM man page: /usr/local/php80/php/man/man8/ Installing PHP FPM status page: /usr/local/php80/php/php/fpm/ Installing PHP LiteSpeed binary: /usr/local/php80/bin/ Installing phpdbg binary: /usr/local/php80/bin/ Installing phpdbg man page: /usr/local/php80/php/man/man1/ Installing PHP CGI binary: /usr/local/php80/bin/ Installing PHP CGI man page: /usr/local/php80/php/man/man1/ Installing build environment: /usr/local/php80/lib/php/build/ Installing header files: /usr/local/php80/include/php/ Installing helper programs: /usr/local/php80/bin/ program: phpize80 program: php-config80 Installing man pages: /usr/local/php80/php/man/man1/ page: phpize80.1 page: php-config80.1 Installing PEAR environment: /usr/local/php80/lib/php/ PHP Warning: Private methods cannot be final as they are never overridden by other classes in /usr/local/directadmin/custombuild/php-8.0.6/pear/install-pear-nozlib.phar on line 339 [PEAR] Archive_Tar - installed: 1.4.9 [PEAR] Console_Getopt - installed: 1.4.3 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.4.5 warning: pear/PEAR dependency package "pear/Archive_Tar" installed version 1.4.9 is not the recommended version 1.4.4 [PEAR] PEAR - installed: 1.10.12 Wrote PEAR system config file at: /usr/local/php80/etc/pear.conf You may want to add: /usr/local/php80/lib/php to your php.ini include_path /usr/local/directadmin/custombuild/php-8.0.6/build/shtool install -c ext/phar/phar.phar /usr/local/php80/bin/phar80.phar ln -s -f phar80.phar /usr/local/php80/bin/phar80 Installing PDO headers: /usr/local/php80/include/php/ext/pdo/ Copying php.ini.. /usr/local/php80/lib/php.ini already exists, skipping. Enabling mail.add_x_header option in /usr/local/php80/lib/php.ini Creating symlink for /usr/local/php80/bin/php80... Creating symlink for /usr/local/php80/bin/lsphp80... Creating symlink for /usr/local/php80/bin/php-cgi80... Creating symlink for /usr/local/php80/bin/php-config80... Creating symlink for /usr/local/php80/bin/phpize80... Failed to restart php-fpm80.service: Unit php-fpm80.service failed to load: No such file or directory. Failed to execute operation: No such file or directory PHP has been secured. Restarting php-fpm73. Restarting php-fpm74. Restarting php-fpm80. opCache is now installed for PHP 8.0. Downloading updated /usr/lib/ssl/cert.pem Downloading cacert.pem... converted 'https://files.directadmin.com/services/custombuild/all/ssl/cacert.pem' (ANSI_X3.4-1968) -> 'https://files.directadmin.com/services/custombuild/all/ssl/cacert.pem' (UTF-8) --2021-05-27 15:35:12-- https://files.directadmin.com/services/custombuild/all/ssl/cacert.pem Resolving files.directadmin.com (files.directadmin.com)... 185.42.221.168, 69.162.69.58, 104.128.54.74 Connecting to files.directadmin.com (files.directadmin.com)|185.42.221.168|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 206919 (202K) Saving to: '/usr/local/directadmin/custombuild/cacert.pem' /usr/local/directadmin/custombuild/ 100%[====================================================================>] 202.07K --.-KB/s in 0.03s 2021-05-27 15:35:12 (5.97 MB/s) - '/usr/local/directadmin/custombuild/cacert.pem' saved [206919/206919] Enabling php-fpm80 in systems... Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm80.service to /etc/systemd/system/php-fpm80.service. Restarting apache. Rewriting all users httpd.conf files, please wait... Debug mode. Level 10 dataskq: command: action=rewrite&value=httpd PHP 8.0.6 Installed.
Step 3: Verify everything is working again
/usr/local/directadmin/custombuild# ps aux | grep php root 15896 0.0 0.2 292176 22000 ? Ss 15:35 0:00 php-fpm: master process (/usr/local/php73/etc/php-fpm.conf) root 15902 0.0 0.2 297012 21808 ? Ss 15:35 0:00 php-fpm: master process (/usr/local/php74/etc/php-fpm.conf) root 16060 0.0 0.2 299384 22180 ? Ss 15:35 0:00 php-fpm: master process (/usr/local/php80/etc/php-fpm.conf)
(Optional) Step 4: Clean-Up
After the installation you could add popen
back to the list, but with the current way PEAR is installed, you will likely want to keep it as such for now, taking a slightly increased security risk. Better to have it so it auto-updates then having your system go down...
You could also simply delete the custom options by removing the file we created in step 1 located: /usr/local/directadmin/custombuild/custom/php_disable_functions
# Set Custom Settings for Disabled PHP Functions (adding popen again to the list)
cd /usr/local/directadmin/custombuild
echo "exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname" > custom/php_disable_functions
./build secure_php