Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

PHP Fatal error: Call to undefined function gzencode() - missing zlib support
https://forum.ivorde.com/php-fatal-error-call-to-undefined-function-gzencode-missing-zlib-support-t19726.html
Page 1 of 1

Author:  mandrei99 [ Sat Jan 17, 2015 5:14 pm ]
Post subject:  PHP Fatal error: Call to undefined function gzencode() - missing zlib support

With a PHP-FPM deployment, there are two levels of compression: in php and in nginx.
Nginx comes with gzip support in all flavors of Linux. The above error occurs when php is built from source without zlib support.

Here is how to configure php zlib extension separately assuming you still have the source:

Code:
root@server:/usr/src/php-5.6.4/ext/zlib# /opt/php-5.6.4/bin/phpize
Cannot find config.m4.
Make sure that you run '/opt/php-5.6.4/bin/phpize' in the top level source directory of the module

root@server:/usr/src/php-5.6.4/ext/zlib# cp -rp config0.m4 config.m4
root@server:/usr/src/php-5.6.4/ext/zlib# /opt/php-5.6.4/bin/phpize
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226

root@server:/usr/src/php-5.6.4/ext/zlib# ./configure --with-php-config=/opt/php-5.6.4/bin/php-config 

root@server:/usr/src/php-5.6.4/ext/zlib# make && make install
/bin/bash /usr/src/php-5.6.4/ext/zlib/libtool --mode=install cp ./zlib.la /usr/src/php-5.6.4/ext/zlib/modules
cp ./.libs/zlib.so /usr/src/php-5.6.4/ext/zlib/modules/zlib.so
cp ./.libs/zlib.lai /usr/src/php-5.6.4/ext/zlib/modules/zlib.la
PATH="$PATH:/sbin" ldconfig -n /usr/src/php-5.6.4/ext/zlib/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/src/php-5.6.4/ext/zlib/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /opt/php-5.6.4/lib/php/extensions/no-debug-non-zts-20131226/

Zlib is now built a shared extension for PHP (can be enabled and disabled).
Next open "php.ini" and add the following line in the "Dynamic Extensions" section and restart php:
Code:
extension=zlib.so

Let's confirm using cli php:
Code:
root@server:/usr/src/php-5.6.4/ext/zlib# /opt/php/bin/php -i | grep -i "zlib sup"
ZLib Support => enabled

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/