How to compile PHP with GDlib

Posted on 2006-04-03
Last Modified: 2013-11-22
I need to compile PHP with GDlib, what are the command line swtiches to do that? I installed GDlib independently of PHP but php won't recognize it that way.
Can't find any docs. Thanks

Question by:dprasad
    LVL 51

    Expert Comment

    you need to build GD with following configure options:
    (which requires that freetype, pegsrc and libpng are installed)

    then PHP's configure options (beside others) are:
             --with-freetype-dir=$PREFIX \
             --with-jpeg-dir=$PREFIX \
             --with-tiff-dir=$PREFIX \
             --with-gd=$PREFIX \
             --with-png-dir=$PREFIX \
             --with-ttf=$PREFIX \
             --enable-gd-native-ttf \

    (where $PREFIX is the path to your installation directory)

    Author Comment

    great, I'm at work right now will try that out. 2 questions

    I'm on php 4.4, shouldn't this have GDlib as part of the standard dist?

    I've been installing php like this, add those swtiches after 'make install clean' ?

    # cd /usr/ports/www/mod_php4
    # make install clean
    # cd /usr/ports/lang/php4-extensions
    # make install clean
    LVL 51

    Assisted Solution

    > shouldn't this have GDlib as part of the standard
    AFAIK GD is not mandatory

    > I've been installing php like this ..
    sorry, I don't have experiance with FreeBSD's ports, just know how to use configure on Unix/Linux systems, but IIRC you can do that with ports too
    LVL 61

    Expert Comment

    It should not be part of standard php, as there is no standard, and those serving static images, like most websites around rarely need that.

    cd /usr/ports/graphics/php4-gd
    make install clean

    Author Comment

    hey gheist, I installed php4-gd but unfortunately my php script won't recognize it

    can you tell me how to compile it with the options ahoffmann mentioned? thanks

    LVL 61

    Expert Comment

    less /var/sb/pkg/php5-gd/+DISPLAY
    LVL 61

    Expert Comment

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

    make sure that line is in file
    then run apachectl stop ; apachectl start

    Author Comment

    I can't get that less command to work, it just says no file or directory. and yes, that is there.

    I installed php5-gd, then the optimizer..but now when I run the script to check for the zend optimizer being installed (which i need) is mysteriously says the zend optimizer isn't installed! grrrrrrrrrrrrr.

    here's my phpinfo()

    PHP Logo
    PHP Version 5.1.2

    System       FreeBSD 6.0-RELEASE FreeBSD 6.0-RELEASE #0: Thu Nov 3 09:36:13 UTC 2005 root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC i386
    Build Date       Apr 6 2006 15:15:14
    Configure Command       './configure' '--enable-versioning' '--enable-memory-limit' '--with-layout=GNU' '--with-config-file-scan-dir=/usr/local/etc/php' '--disable-all' '--enable-libxml' '--with-libxml-dir=/usr/local' '--enable-reflection' '--enable-spl' '--with-regex=php' '--with-apxs=/usr/local/sbin/apxs' '--prefix=/usr/local' 'i386-portbld-freebsd6.0'
    Server API       Apache
    Virtual Directory Support       disabled
    Configuration File (php.ini) Path       /usr/local/Zend/etc/php.ini
    Scan this dir for additional .ini files       /usr/local/etc/php
    additional .ini files parsed       /usr/local/etc/php/extensions.ini
    PHP API       20041225
    PHP Extension       20050922
    Zend Extension       220051025
    Debug Build       no
    Thread Safety       disabled
    Zend Memory Manager       enabled
    IPv6 Support       enabled
    Registered PHP Streams       php, file, http, ftp
    Registered Stream Socket Transports       tcp, udp, unix, udg
    Registered Stream Filters       string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*

    Zend logo This program makes use of the Zend Scripting Language Engine:
    Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
        with Zend Extension Manager v1.0.10, Copyright (c) 2003-2006, by Zend Technologies
        with Zend Optimizer v3.0.0beta3, Copyright (c) 1998-2006, by Zend Technologies

    PHP Credits
    PHP Core
    Directive      Local Value      Master Value
    allow_call_time_pass_reference      Off      Off
    allow_url_fopen      On      On
    always_populate_raw_post_data      Off      Off
    arg_separator.input      &      &
    arg_separator.output      &      &
    asp_tags      Off      Off
    auto_append_file      no value      no value
    auto_globals_jit      On      On
    auto_prepend_file      no value      no value
    browscap      no value      no value
    default_charset      no value      no value
    default_mimetype      text/html      text/html
    define_syslog_variables      Off      Off
    disable_classes      no value      no value
    disable_functions      no value      no value
    display_errors      Off      Off
    display_startup_errors      Off      Off
    doc_root      no value      no value
    docref_ext      no value      no value
    docref_root      no value      no value
    enable_dl      On      On
    error_append_string      no value      no value
    error_log      no value      no value
    error_prepend_string      no value      no value
    error_reporting      2047      2047
    expose_php      On      On
    extension_dir      /usr/local/lib/php/20050922      /usr/local/lib/php/20050922
    file_uploads      On      On      #FFFFFF      #FFFFFF
    highlight.comment      #FF8000      #FF8000
    highlight.default      #0000BB      #0000BB
    highlight.html      #000000      #000000
    highlight.keyword      #007700      #007700
    highlight.string      #DD0000      #DD0000
    html_errors      On      On
    ignore_repeated_errors      Off      Off
    ignore_repeated_source      Off      Off
    ignore_user_abort      Off      Off
    implicit_flush      Off      Off
    include_path      .:      .:
    log_errors      On      On
    log_errors_max_len      1024      1024
    magic_quotes_gpc      Off      Off
    magic_quotes_runtime      Off      Off
    magic_quotes_sybase      Off      Off
    mail.force_extra_parameters      no value      no value
    max_execution_time      30      30
    max_input_time      60      60
    memory_limit      8M      8M
    open_basedir      no value      no value
    output_buffering      4096      4096
    output_handler      no value      no value
    post_max_size      8M      8M
    precision      14      14
    realpath_cache_size      16K      16K
    realpath_cache_ttl      120      120
    register_argc_argv      Off      Off
    register_globals      Off      Off
    register_long_arrays      On      On
    report_memleaks      On      On
    report_zend_debug      On      On
    safe_mode      Off      Off
    safe_mode_exec_dir      no value      no value
    safe_mode_gid      Off      Off
    safe_mode_include_dir      no value      no value
    sendmail_from      no value      no value
    sendmail_path      /usr/sbin/sendmail -t -i       /usr/sbin/sendmail -t -i
    serialize_precision      100      100
    short_open_tag      On      On
    SMTP      localhost      localhost
    smtp_port      25      25
    sql.safe_mode      Off      Off
    track_errors      Off      Off
    unserialize_callback_func      no value      no value
    upload_max_filesize      2M      2M
    upload_tmp_dir      no value      no value
    user_dir      no value      no value
    variables_order      GPCS      GPCS
    xmlrpc_error_number      0      0
    xmlrpc_errors      Off      Off
    y2k_compliance      On      On
    zend.ze1_compatibility_mode      Off      Off

    APACHE_INCLUDE       no value
    APACHE_TARGET       no value
    Apache Version       Apache/1.3.34 (Unix) PHP/5.1.2
    Apache Release       10334100
    Apache API Version       19990320
    User/Group       www(80)/80
    Max Requests       Per Child: 0 - Keep Alive: on - Max Per Connection: 100
    Timeouts       Connection: 300 - Keep-Alive: 15
    Server Root       /usr/local
    Loaded Modules       mod_php5, mod_setenvif, mod_so, mod_log_forensic, mod_usertrack, mod_headers, mod_expires, mod_cern_meta, mod_proxy, mod_digest, mod_auth_db, mod_auth_anon, mod_auth, mod_access, mod_rewrite, mod_alias, mod_userdir, mod_speling, mod_actions, mod_imap, mod_asis, mod_cgi, mod_dir, mod_autoindex, mod_include, mod_info, mod_status, mod_negotiation, mod_mime, mod_mime_magic, mod_log_config, mod_define, mod_env, mod_vhost_alias, mod_mmap_static, http_core

    Directive      Local Value      Master Value
    child_terminate      0      0
    engine      1      1
    last_modified      0      0
    xbithack      0      0

    Apache Environment
    Variable      Value
    DOCUMENT_ROOT       /usr/local/www/data
    HTTP_ACCEPT       text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    HTTP_ACCEPT_CHARSET       ISO-8859-1,utf-8;q=0.7,*;q=0.7
    HTTP_ACCEPT_ENCODING       gzip,deflate
    HTTP_ACCEPT_LANGUAGE       en-us,en;q=0.5
    HTTP_CONNECTION       keep-alive
    HTTP_KEEP_ALIVE       300
    HTTP_USER_AGENT       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20060111 Firefox/
    PATH       /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
    REMOTE_PORT       3478
    SCRIPT_FILENAME       /usr/local/www/data/test.php
    SERVER_ADMIN       you@your.address
    SERVER_PORT       80
    SERVER_SIGNATURE       <ADDRESS>Apache/1.3.34 Server at Port 80</ADDRESS>
    SERVER_SOFTWARE       Apache/1.3.34 (Unix) PHP/5.1.2
    QUERY_STRING       no value
    REQUEST_URI       /test.php
    SCRIPT_NAME       /test.php

    HTTP Headers Information
    HTTP Request Headers
    HTTP Request       GET /test.php HTTP/1.1
    Accept       text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    Accept-Charset       ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Accept-Encoding       gzip,deflate
    Accept-Language       en-us,en;q=0.5
    Connection       keep-alive
    Keep-Alive       300
    User-Agent       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20060111 Firefox/
    HTTP Response Headers
    X-Powered-By       PHP/5.1.2
    Keep-Alive       timeout=15, max=98
    Connection       Keep-Alive
    Transfer-Encoding       chunked
    Content-Type       text/html

    date/time support       enabled
    Timezone Database Version       2005.18
    Timezone Database       internal
    Default timezone       America/Los_Angeles

    Directive      Local Value      Master Value
    date.default_latitude      31.7667      31.7667
    date.default_longitude      35.2333      35.2333
    date.sunrise_zenith      90.583333      90.583333
    date.sunset_zenith      90.583333      90.583333
    date.timezone      no value      no value

    GD Support       enabled
    GD Version       bundled (2.0.28 compatible)
    FreeType Support       enabled
    FreeType Linkage       with freetype
    FreeType Version       2.1.10
    T1Lib Support       enabled
    GIF Read Support       enabled
    GIF Create Support       enabled
    JPG Support       enabled
    PNG Support       enabled
    WBMP Support       enabled
    XPM Support       enabled
    XBM Support       enabled

    libXML support       active
    libXML Version       2.6.23
    libXML streams       enabled

    Reflection      enabled
    Version       $Id: php_reflection.c,v 2006/01/01 12:50:12 sniper Exp $

    SPL support      enabled
    Interfaces       Countable, OuterIterator, RecursiveIterator, SeekableIterator, SplObserver, SplSubject
    Classes       AppendIterator, ArrayIterator, ArrayObject, BadFunctionCallException, BadMethodCallException, CachingIterator, DirectoryIterator, DomainException, EmptyIterator, FilterIterator, InfiniteIterator, InvalidArgumentException, IteratorIterator, LengthException, LimitIterator, LogicException, NoRewindIterator, OutOfBoundsException, OutOfRangeException, OverflowException, ParentIterator, RangeException, RecursiveArrayIterator, RecursiveCachingIterator, RecursiveDirectoryIterator, RecursiveFilterIterator, RecursiveIteratorIterator, RuntimeException, SplFileInfo, SplFileObject, SplObjectStorage, SplTempFileObject, UnderflowException, UnexpectedValueException

    Regex Library       Bundled library enabled
    Dynamic Library Support       enabled
    Path to sendmail       /usr/sbin/sendmail -t -i

    Directive      Local Value      Master Value      1      1
    assert.bail      0      0
    assert.callback      no value      no value
    assert.quiet_eval      0      0
    assert.warning      1      1
    auto_detect_line_endings      0      0
    default_socket_timeout      60      60
    safe_mode_allowed_env_vars      PHP_      PHP_
    safe_mode_protected_env_vars      LD_LIBRARY_PATH      LD_LIBRARY_PATH
    url_rewriter.tags      a=href,area=href,frame=src,input=src,form=fakeentry      a=href,area=href,frame=src,input=src,form=fakeentry
    user_agent      no value      no value

    Zend Optimizer
    Optimization Pass 1       enabled
    Optimization Pass 2       enabled
    Optimization Pass 3       enabled
    Optimization Pass 4       enabled
    Optimization Pass 9       enabled
    Zend Loader       enabled
    License Path       no value

    Additional Modules
    Module Name

    Variable      Value
    MACHTYPE       i386
    SSH_CLIENT 3432 22
    USER       root
    MAIL       /var/mail/root
    SHLVL       1
    VENDOR       intel
    HOME       /root
    SSH_TTY       /dev/ttyp0
    PAGER       more
    GROUP       wheel
    LOGNAME       root
    BLOCKSIZE       K
    TERM       xterm
    PATH       /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
    HOST       no value
    SHELL       /bin/csh
    OSTYPE       FreeBSD
    PWD       /usr/sbin
    SSH_CONNECTION 3432 22
    HOSTTYPE       FreeBSD
    EDITOR       vi

    PHP Variables
    Variable      Value
    _SERVER["DOCUMENT_ROOT"]      /usr/local/www/data
    _SERVER["HTTP_ACCEPT"]      text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
    _SERVER["HTTP_ACCEPT_CHARSET"]      ISO-8859-1,utf-8;q=0.7,*;q=0.7
    _SERVER["HTTP_ACCEPT_ENCODING"]      gzip,deflate
    _SERVER["HTTP_ACCEPT_LANGUAGE"]      en-us,en;q=0.5
    _SERVER["HTTP_CONNECTION"]      keep-alive
    _SERVER["HTTP_KEEP_ALIVE"]      300
    _SERVER["HTTP_USER_AGENT"]      Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20060111 Firefox/
    _SERVER["PATH"]      /sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
    _SERVER["REMOTE_PORT"]      3478
    _SERVER["SCRIPT_FILENAME"]      /usr/local/www/data/test.php
    _SERVER["SERVER_ADMIN"]      you@your.address
    _SERVER["SERVER_PORT"]      80
    _SERVER["SERVER_SIGNATURE"]      <ADDRESS>Apache/1.3.34 Server at Port 80</ADDRESS>
    _SERVER["SERVER_SOFTWARE"]      Apache/1.3.34 (Unix) PHP/5.1.2
    _SERVER["QUERY_STRING"]      no value
    _SERVER["REQUEST_URI"]      /test.php
    _SERVER["SCRIPT_NAME"]      /test.php
    _SERVER["PATH_TRANSLATED"]      /usr/local/www/data/test.php
    _SERVER["PHP_SELF"]      /test.php
    _SERVER["REQUEST_TIME"]      1144362839

    PHP License

    This program is free software; you can redistribute it and/or modify it under the terms of the PHP License as published by the PHP Group and included in the distribution in the file: LICENSE

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

    If you did not receive a copy of the PHP license, or have any questions about PHP licensing, please contact

    LVL 61

    Accepted Solution

    try "pkg_delete php\*" and reinstall php and extensions. I never had php on workstation ,and php5-cli installed just fine and catches up with php5-gd and eaccelerator (sorry - amd64, no zend here) .

    Better before installing php tru updating sources as seen in cvsup section of

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (, discussed installing the Solaris Operating S…
    Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now