Install gd support in php without xorg

Recent upgrade to php 5.2.3 require to install gd support too but it always need xorg. Here’s a lttle note on how to add gd support in php5 ports in freebsd without xorg.

1. Checking installed php extension

proxy# pkg_info | grep php5
php5-5.2.3          PHP Scripting Language (Apache Module and CLI)
php5-bz2-5.2.3      The bz2 shared extension for php
php5-ctype-5.2.3    The ctype shared extension for php
php5-curl-5.2.3     The curl shared extension for php
php5-dom-5.2.3      The dom shared extension for php
php5-ftp-5.2.3      The ftp shared extension for php
php5-iconv-5.2.3    The iconv shared extension for php
php5-imap-5.2.3     The imap shared extension for php
php5-pcre-5.2.3     The pcre shared extension for php
php5-simplexml-5.2.3 The simplexml shared extension for php
php5-spl-5.2.3      The spl shared extension for php

2. Find php5-gd and install it.

proxy# whereis php5-gd
php5-gd: /usr/ports/graphics/php5-gd
proxy# cd /usr/ports/graphics/php5-gd && make clean
===>  Cleaning for php5-gd-5.2.3

proxy# cd /usr/ports/graphics/php5-gd && make install

===>  Vulnerability check disabled, database not found
===>  Found saved configuration for php5-gd-5.2.3
===>  Extracting for php5-gd-5.2.3
=> MD5 Checksum OK for php-5.2.3.tar.bz2.
=> SHA256 Checksum OK for php-5.2.3.tar.bz2.
===>  Patching for php5-gd-5.2.3
===>  Applying FreeBSD patches for php5-gd-5.2.3
===>   php5-gd-5.2.3 depends on executable in : phpize – found
===>   php5-gd-5.2.3 depends on file: /usr/local/bin/autoconf259 – found
===>   php5-gd-5.2.3 depends on shared library: freetype.9 – not found
===>    Verifying install for freetype.9 in /usr/ports/print/freetype2

wow, alot of things it will installed and tend to install xorg 🙁

3. Change strategy, install gd first before install php5-gd

proxy# whereis gd
gd: /usr/ports/graphics/gd

proxy# cd /usr/ports/graphics/gd && make install WITH_XPM=3Dyes WITHOUT_X11=3Dyes
===>  Vulnerability check disabled, database not found
=> gd-2.0.35.tar.bz2 doesn’t seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://www.libgd.org/releases/.

Checking if gd installed properly.

adding in /etc/make.conf

WITHOUT_X11=yes

proxy# pkg_info | grep gd
gd-2.0.35,1         A graphics library for fast creation of images

5. Install php5-gd

proxy# cd /usr/ports/graphics/php5-gd && make install
===>   php5-gd-5.2.3 depends on executable in : phpize – found
===>   php5-gd-5.2.3 depends on file: /usr/local/bin/autoconf259 – found
===>   php5-gd-5.2.3 depends on shared library: freetype.9 – found
===>   php5-gd-5.2.3 depends on shared library: png.5 – found
===>   php5-gd-5.2.3 depends on shared library: jpeg.9 – found
===>   php5-gd-5.2.3 depends on shared library: t1.5 – not found
===>    Verifying install for t1.5 in /usr/ports/devel/t1lib
===>  Vulnerability check disabled, database not found
=> t1lib-5.1.1.tar.gz doesn’t seem to exist in /usr/ports/distfiles/.
=> Attempting to fetch from http://www.ibiblio.org/pub/Linux/libs/graphics/.
t1lib-5.1.1.tar.gz                              1% of 1795 kB 4357  Bps

===>  Installing for php5-gd-5.2.3
===>   php5-gd-5.2.3 depends on file: /usr/local/include/php/main/php.h – found
===>   Generating temporary packing list
===>  Checking if graphics/php5-gd already installed
===>   Registering installation for php5-gd-5.2.3
****************************************************************************

The following line has been added to your /usr/local/etc/php/extensions.ini
configuration file to automatically load the installed extension:

extension=gd.so

****************************************************************************
6. php5-gd successfully installed, checking time 🙂

proxy#
proxy# pkg_info | grep php5-gd
php5-gd-5.2.3       The gd shared extension for php

Yay, my bad..my bad

This steps also usable for php4 , just change php5-gd into php4-gd.

Today  lesson for me  :  never..ever think that you are good enough. Always learn and learn.