Install the ZIP extension in PHP8 and use the source code to install the ZIP extension in PHP extension

Install the ZIP extension in PHP extension in Centos. After PHP is upgraded from 7.X to PHP8.X, two PHP extensions become invalid, one is the imagick extension and the other is the ZIP extension. After uninstalling the original imagick extension, use the pecl command to install it in the official PHP extension library. When installing the ZIP extension, it fails and it is found to be a problem with libzip. Install the ZIP extension.

PHP extension installation, install ZIP extension using source code in CentOS

Installation in CentOS In After PHP was upgraded from 7.X to PHP8.X, two PHP extensions became invalid, one was the imagick extension and the other was the ZIP extension. After uninstalling the original imagick extension, you can use the pecl command to install it in the official PHP extension library. When installing the ZIP extension, the installation failed and it was found to be a problem with libzip. Let's install the ZIP extension together.

 

 

Before installing the zip extension, install libzip first. Go to the libzip official website to download the latest version of libzip.

libzip official website:https://libzip.org/

PHP8 installs ZIP extension, uses source code to install ZIP extension in PHP extension-1

Centos8 install ZIP extension

After upgrading PHP7 to PHP8, install the zip extension and uninstall the previously installed zip and libzip first.

dnf remove zip libzip

When you uninstall libzip, php-pecl-zip will also be uninstalled. This is the zip extension installed by PHP7 before and must be uninstalled.

After uninstalling, reinstall zip and libzip

dnf install zip

This zip is the main zip program. You must install the main zip program before installing the php extension.

libzip cannot use the official software library of centos8. The centos8 version is relatively old, and the libzip version of the official software library is too low. When installing the zip extension, an error will be reported and the installation cannot be performed.

Next, download the latest version of libzip from the libzip official website

#Download libzip wget https://libzip.org/download/libzip-1.9.2.tar.xz #Unzip libzip tar -xvf libzip-1.9.2.tar.xz #Enter the libzip folder and prepare to install cd libzip-1.9.2

Before installing libzip, you need to install cmake3 first. libzip requires cmake3 to compile and install.

dnf install -y cmake3

Finally install libzip

# After building build, enter the folder mkdir build && cd build # compile cmake .. # install libzip make && make install

After libzip is installed successfully, install the zip extension.

pecl install zip

Or use the zip extension source to install.

On the PHP extension website of the PHP official websitehttps://pecl.php.net/package/zipDownload the latest version of PHP extension

You can install it using the pecl command

wget https://pecl.php.net/get/zip-1.21.1.tgz pecl install zip-1.21.1.tgz

You can also use compile and install

wget https://pecl.php.net/get/zip-1.21.1.tgz tar -xvf zip-1.21.1.tgz cd zip-1.21.1 phpize ./configure make && make install

PHP8 installs ZIP extension, uses source code to install ZIP extension in PHP extension-1

The zip extension has been installed successfully, but it often reports an error. Use php -m Run the command to check whether the extension is installed correctly. If an error is reported, you need to continue to handle the error.

Solution to the system error "Cannot find libzip.so.5"

After the zip extension is installed, you will generally encounter the error: Unable to load dynamic library "zip.so".

PHP Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (libzip.so.5: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/zip.so.so (/usr/lib64/php/modules/zip.so.so: cannot open shared object file: No such file or directory) directory)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (libzip.so.5: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/zip.so.so (/usr/lib64/php/modules/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

 

The libzip.so.5 file is missing when loading zip.so, and the libzip.so.5 file is required.

The libzip.so.5 file is normally installed in /usr/local/lib64. The zip extension requires the libzip.so.5 file to be placed in /usr/local/lib/.

Use FTP to copy the libzip.so.5 file in the /usr/local/lib64 folder to the /usr/local/lib/ folder and change the file permissions to 755.

Another method is to soft link zip.so to the /usr/local/lib64 and /usr/local/lib directories respectively, and make it effective through the idconfig command.

ln -s /usr/lib64/php/modules/zip.so /usr/local/lib64/zip.so && ldconfig ln -s /usr/lib64/php/modules/zip.so /usr/local/lib/zip.so && ldconfig

PHP8 installs ZIP extension, uses source code to install ZIP extension in PHP extension-1

score

Leave a Reply

Your email address will not be published. Required fields are marked *