CentOS cyberpanel PHP 8.0 zip extension

I’m a moodle user and recently found out that everytime i try to download a ODS file (exporting grades) it says Exception - Class “ZipArchive” not found"

it turns out that my php (version 8.0) doesn’t have the zip extension installed

i tried installing the zip extension on cyberpanel(my moodle is hosted on cyberpanel CentOS 7) but i don’t seems to install, when i click to install i receive this message:

    Loaded plugins: copr, fastestmirror, priorities
    Loading mirror speeds from cached hostfile
     * base: atl.mirrors.clouvider.net
     * epel: mirrors.coreix.net
     * extras: mirror.dal.nexril.net
     * updates: atl.mirrors.clouvider.net
    10 packages excluded due to repository priority protections
    Package lsphp80-common-8.0.15-1.el7.x86_64 already installed and latest version
    Nothing to do
    PHP Extension Installed.

but then when i return to the extension page it says that the extension is not installed, and i still can’t generate ODS files, i tried searching in about it and people said that i need to do it on terminal, i tried using cyberpanel terminal as root user with those commands:

    yum install php-pear
    yum install php-devel
    pecl install zip

then i gone to the php.ini ( i tried open it on either cyberpanel interface and on terminal) and insert the code:

    extension=zip.so;

before the “module settings” section on the file, and it still doesn’t work(it sems that i have multiple versions of php installed on my cyberpanel, i tried editing php.ini on my php 8.0 directory and other versions avaliable)

its weird because on version 7.3 of php it install and work normally(it even install on the interface) and when i change the php version on my moodle to 7.3(i don’t wanna use this version) it the error completely disappears, how can i solve it?

It sounds like you’re having trouble getting the zip extension for PHP 8.0 installed on your Moodle setup in CyberPanel. Here’s a step-by-step guide to help you resolve the issue:

Step 1: Install Required Packages

First, ensure that you have the required packages to compile PHP extensions. Run the following commands:

yum install -y php-pear php-devel

Step 2: Install Zip Extension via PECL

Next, use PECL to install the zip extension:

pecl install zip

Step 3: Find the Correct PHP Configuration File

Since you have multiple versions of PHP, make sure you are editing the correct php.ini for PHP 8.0. You can find the location of the php.ini file used by PHP 8.0 with the following command:

php -i | grep "Loaded Configuration File"

Make sure to run this command using PHP 8.0. You may need to specify the path explicitly, like this:

/usr/local/lsws/lsphp80/bin/php -i | grep "Loaded Configuration File"

Step 4: Edit the php.ini File

Once you have the correct path to the php.ini, open it in a text editor:

nano /path/to/php.ini

Add the following line (if it’s not already there):

extension=zip.so

Step 5: Verify Installation

After editing the php.ini, restart the web server to apply the changes:

systemctl restart lsws

Step 6: Check Loaded Extensions

You can verify if the zip extension is loaded for PHP 8.0 by running:

/usr/local/lsws/lsphp80/bin/php -m | grep zip

If you see zip in the output, the extension is successfully installed.

Step 7: Update CyberPanel (Optional)

If you’re still facing issues after trying the above steps, consider updating CyberPanel or checking their forums for any known issues regarding PHP 8.0 and extensions.

Troubleshooting Tips

  • Check for Errors: If the pecl install zip command fails, check the output for any error messages that could indicate missing dependencies.
  • Check Logs: Look into the web server logs for any errors related to PHP or Moodle, which may provide additional context.
  • Version Compatibility: Ensure that your version of Moodle is compatible with PHP 8.0, as some older versions may have issues with newer PHP versions.

If you continue to experience problems, please share any error messages you receive during the installation process or when loading Moodle, and I can provide further assistance!