kuba1999 kuba1999 - 7 months ago 24
PHP Question

PHP GD bundled extension without recompiling PHP - solution

The bundled extension offer a lot of functionality. I have spent a lot of time how to compile extension for my version of PHP. So there are instructions.

Answer

0, Install PHP development package. Also You should have installed PHP with GD extension (but not bundled)

sudo apt-get install php5-dev

1, Download source code of used PHP (for me 5.6.18)

wget http://cz2.php.net/get/php-5.6.18.tar.gz/from/this/mirror -O php-5.6.18.tar.gz

2, Extract archive

tar -xzf php-5.6.18.tar.gz

3, Go to the source code of GD extension

cd php-5.6.18/ext/gd/

4, Prepare the extension (run phpize in that directory)

phpize

5, Now the configure command

5.1, The arguments depends on Your linux distribution. My was these:

--with-freetype-dir=shared,/usr --with-vpx-dir=shared,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6

5.2, For getting paths for libraries You must run this command and search only the search arguments, which are specified above (5.1)

php-config --configure-options

5.3, Also add this arguments for configure (the second argument makes bundled version)

--with-php-config=/usr/bin/php-config --with-gd 

6, Final configure command

sudo ./configure --with-php-config=/usr/bin/php-config --with-gd --with-freetype-dir=YOUR_VALUE --with-vpx-dir=YOUR_VALUE --with-jpeg-dir=YOUR_VALUE --with-xpm-dir=YOUR_VALUE

7, Now run make

make

8, After compiling You should see something like this:

Libraries have been installed in:
   /home/jakub/php-5.6.18/ext/gd/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'.

So in the directory modules You have compiled bundled extension gd.so. 9, Replace NOT bundled gd.so by Your new compiled bundled extension, for my version of PHP It was command:

sudo cp -f ./gd.so /usr/lib/php5/20131226/gd.so

10, Restart Apache

sudo service apache2 restart

Hope this helps! and will You spend less time than me.