Error in CentOS 7.5 64-bit, PHP 7.4: PHP core warningYii\Base\ErrorExceptionwith messagemodulezipalready loadedanalysis solution
1. Error in CentOS 7.5 64-bit, PHP 7.4: PHP core warningYii\Base\ErrorExceptionwith messagemodulezipalready loaded, as shown in Figure 1
2020/6/12 下午1:15:12PHP Core Warning 'yii\base\ErrorException' with message 'Module 'zip' already loaded'
2020/6/12 下午1:15:12
2020/6/12 下午1:15:12in ./Unknown:0
2020/6/12 下午1:15:12
2020/6/12 下午1:15:12Stack trace:
2020/6/12 下午1:15:12#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
2020/6/12 下午1:15:12#1 {main}
2. Check the information of phpinfo() and confirm that the zip extension is installed. as shown in Figure 2
3. Check whether zip exists in /usr/local/php/etc/php.ini. exists.
;extension = "memcached.so"
extension = "redis.so"
;extension = "mongo.so"
extension = "sockets.so"
extension = "swoole.so"
extension = "mongodb.so"
extension = "rdkafka.so"
extension = "exif.so"
extension = "zip.so"
extension = "gd.so"
4. Check the extension_dir of phpinfo(), its value: /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/ , as shown in Figure 3
5. Enter the directory: /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/, check the expansion package, zip and gd extensions already exist. as shown in Figure 4
[root@5e4d278fdede /]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
[root@5e4d278fdede no-debug-non-zts-20190902]# ls -l
total 32032
-rwxr-xr-x 1 root root 234763 Apr 16 22:48 exif.so
-rwxr-xr-x 1 root root 1300761 Apr 16 22:48 gd.so
-rwxr-xr-x 1 root root 2791555 Apr 16 23:39 intl.so
-rwxr-xr-x 1 root root 279018 Apr 16 22:48 ldap.so
-rwxr-xr-x 1 root root 4764219 Apr 16 23:40 mongodb.so
-rwxr-xr-x 1 root root 4677222 Apr 16 22:14 opcache.a
-rwxr-xr-x 1 root root 2490202 Apr 16 22:14 opcache.so
-rwxr-xr-x 1 root root 452180 Apr 16 23:38 rdkafka.so
-rwxr-xr-x 1 root root 2485341 Apr 16 23:38 redis.so
-rwxr-xr-x 1 root root 255240 Apr 16 23:42 skywalking.so
-rwxr-xr-x 1 root root 391892 Apr 16 22:14 sockets.so
-rwxr-xr-x 1 root root 12372105 Apr 16 23:41 swoole.so
-rwxr-xr-x 1 root root 226843 Apr 16 22:48 zip.so
6. Decided to restore to the previous basic image first. In the previous basic image, the ZIP and GD extensions were not installed, and no errors were reported. Check if zip exists in /usr/local/php/etc/php.ini . does not exist.
;extension = "memcached.so"
extension = "redis.so"
;extension = "mongo.so"
extension = "sockets.so"
extension = "swoole.so"
extension = "mongodb.so"
extension = "rdkafka.so"
extension = "exif.so"
7. Enter the directory: /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/, check the expansion package, zip and gd extensions do not exist. as shown in Figure 5
[root@0bb790b2627f /]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
[root@0bb790b2627f no-debug-non-zts-20190902]# ls -l
total 30484
-rwxr-xr-x 1 root root 234763 Mar 29 22:56 exif.so
-rwxr-xr-x 1 root root 2791843 Mar 29 23:23 intl.so
-rwxr-xr-x 1 root root 279018 Mar 29 22:56 ldap.so
-rwxr-xr-x 1 root root 4764227 Mar 29 23:24 mongodb.so
-rwxr-xr-x 1 root root 4677222 Mar 29 22:56 opcache.a
-rwxr-xr-x 1 root root 2490202 Mar 29 22:56 opcache.so
-rwxr-xr-x 1 root root 452180 Mar 29 23:23 rdkafka.so
-rwxr-xr-x 1 root root 2485341 Mar 29 23:22 redis.so
-rwxr-xr-x 1 root root 255240 Mar 29 23:26 skywalking.so
-rwxr-xr-x 1 root root 391892 Mar 29 22:56 sockets.so
-rwxr-xr-x 1 root root 12372105 Mar 29 23:26 swoole.so
8. Finally, by adding: sed -i in the Dockerfile/zip.so/d/usr/local/php/etc/php.ini & & \ to solve this problem.
RUN sed -i 's/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv:\/usr\/local\/php/g' /usr/local/php/etc/php.ini && \
sed -i 's/allow_url_fopen = Off/allow_url_fopen = On/g' /usr/local/php/etc/php.ini && \
sed -i 's/disable_functions = exec,system,passthru,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g' /usr/local/php/etc/php.ini && \
sed -i 's/max_execution_time = 60/max_execution_time = 300/g' /usr/local/php/etc/php.ini && \
sed -i 's/;realpath_cache_ttl = 120/realpath_cache_ttl = 1200/g' /usr/local/php/etc/php.ini && \
sed -i '/zip.so/d' /usr/local/php/etc/php.ini && \
sed -i 's/pm.max_children = 20/pm.max_children = 40/g' /usr/local/php/etc/php-fpm.conf
9. Check whether zip exists in /usr/local/php/etc/php.ini. does not exist. has been deleted. as shown in Figure 6
10. Check the information of phpinfo() and confirm that the zip extension is still installed. Check out Configure command, because:–with-gd,–enable-zip, the zip extension is already enabled by default. Therefore, there is no need to re-enable in php.ini . as shown in Figure 7






