Current time: 12-23-2024, 06:10 AM Hello There, Guest! (LoginRegister)


Post Reply 
[HowTo] PHP5 cgi with bundled gd
Author Message
hbaes Offline
Junior Member
*

Posts: 23
Joined: Nov 2007
Reputation: 0
Post: #1
[HowTo] PHP5 cgi with bundled gd
In this short HowTo I will describe how You can rebuild the php5-cgi to use the php5-bundled gd library on debian etch.

This point is sometimes necessary if you or your application will use some special gd functions missing in the libgd but be part of the php5-gd. (i.e. imagefilter() or imagerotate() will be missing if you use the original debian etch php5-cgi)

firrst of all:
PHP Code:
apt get update 
PHP Code:
apt get upgrade 

change to the source directory
PHP Code:
cd /usr/src 

download the source for php5 from debian
PHP Code:
apt-get source php5-cgi 

download some other stuff for re-building the package:
PHP Code:
apt-get build-dep php5-cgi 

after that change to the new extract of php5-5*
when i write this the current version is php5-5.2.0:
PHP Code:
cd php5-5.2.0 

now edit the debian configuration:
PHP Code:
vi debian/rules 

change every line from
PHP Code:
--with-gd=shared,... 
to
PHP Code:
--with-gd 

in the section configure-cgi-stamp: patch-stamp add the following lines: (I didi it after the $(COMMON_CONFIG) line)
Quote:--with-jpeg-dir=shared,/usr \
--with-gd \
--enable-gd-native-ttf \

now save the rules file and start the re-building ...
PHP Code:
./debian/rules binary 
after a cuple of time change back to the source the directory
and you will see a couple of new .deb files.

PHP Code:
cd .. 

now install the new cgi binary
PHP Code:
dpkg -i php5-cgi_5.2.0-8+etch11_i386.deb 

after all restart apache ...
PHP Code:
/etc/init.d/apache2 restart 

thats all

Harald

Edit: Updated to the last Version, JPEG Support 4 GD enabled.
(This post was last modified: 06-10-2008 07:33 PM by hbaes.)
01-04-2008 12:03 AM
Find all posts by this user Quote this message in a reply
raphael Offline
Member
***

Posts: 474
Joined: Apr 2007
Reputation: 8
Post: #2
RE: [HowTo] PHP5 cgi with bundled gd
And the benefit is...?
The php package in Debian doesn't use the bundled library because of security reasons.
When a shared library has a security bug and is fixed all the binaries using that library are 'safe'. But if the bundled library code isn't fixed php would still be vulnerable (and let me tell you something, the security team won't fix the bundled one).

This is a fix one, save them all v.s. a fix ALL, waste your time situation; of course Debian uses the former approach (others should do too, why aren't the changes in the bundled libgd2 code included by the main libgd2 library?)
01-05-2008 03:58 AM
Visit this user's website Find all posts by this user Quote this message in a reply
bjflame Offline
Junior Member
*

Posts: 23
Joined: Mar 2008
Reputation: 0
Post: #3
RE: [HowTo] PHP5 cgi with bundled gd
hi

thanks for this howto. i need functions like imagerotate().

but now i've got one more problem.

i did it like its explained, but the gd doesnt support jpg and png.

how can i rebuild it that this is enabled?


regards
03-26-2008 02:53 AM
Find all posts by this user Quote this message in a reply
Nateside Offline


Posts: 3
Joined: Jul 2008
Reputation: 0
Post: #4
RE: [HowTo] PHP5 cgi with bundled gd
I followed the guide above and it worked great, however, I still don't have any truetype support. What packages should I make sure I have installed, and do I need to change this configuration?
07-20-2008 03:56 PM
Find all posts by this user Quote this message in a reply
hbaes Offline
Junior Member
*

Posts: 23
Joined: Nov 2007
Reputation: 0
Post: #5
RE: [HowTo] PHP5 cgi with bundled gd
Nateside Wrote:I followed the guide above and it worked great, however, I still don't have any truetype support. What packages should I make sure I have installed, and do I need to change this configuration?

you gave him the --enable-gd-native-ttf option ?
and also use: --with-ttf

you could also have a problem with FreeType 1/2 or T1lib
please reckeck

Harald
07-20-2008 06:08 PM
Find all posts by this user Quote this message in a reply
hbaes Offline
Junior Member
*

Posts: 23
Joined: Nov 2007
Reputation: 0
Post: #6
RE: [HowTo] PHP5 cgi with bundled gd
raphael Wrote:And the benefit is...?
The php package in Debian doesn't use the bundled library because of security reasons.
When a shared library has a security bug and is fixed all the binaries using that library are 'safe'. But if the bundled library code isn't fixed php would still be vulnerable (and let me tell you something, the security team won't fix the bundled one).

This is a fix one, save them all v.s. a fix ALL, waste your time situation; of course Debian uses the former approach (others should do too, why aren't the changes in the bundled libgd2 code included by the main libgd2 library?)

Hi Raphael,

The Benefit ist that the bundled GD Library ist mostly more up to date then the external GD.

As the PHP Developers say:
PHP Code:
Since PHP 4.3 there is a bundled version of the GD lib
This bundled version has some additional features like alpha blending
and 
should be used in preference to the external library 
since its codebase is better maintained 
and more stable
(This post was last modified: 07-20-2008 06:11 PM by hbaes.)
07-20-2008 06:10 PM
Find all posts by this user Quote this message in a reply
Nateside Offline


Posts: 3
Joined: Jul 2008
Reputation: 0
Post: #7
RE: [HowTo] PHP5 cgi with bundled gd
hbaes Wrote:you gave him the --enable-gd-native-ttf option ?
and also use: --with-ttf

Yes, I did give it the "--enable-gd-native-ttf" option under "configure-apache2-stamp: patch-stamp"
I also double checked, the same section, and it has "--with-ttf=shared,/usr \"

hbaes Wrote:you could also have a problem with FreeType 1/2 or T1lib
please reckeck

I ran "apt-get -s install libfreetype6" and " apt-get -s install libt1-5" and got the response "libfreetype6 is already the newest version." and "libt1-5 is already the newest version." I'm new to debian, I switched over from Gentoo as the ispcp install for Gentoo seems to be broken at the moment, but I think I checked this correctly.

Also, here are the relevant sections from debian/rules.
--Nate

Code:
configure-cgi-stamp: patch-stamp
        dh_testdir
        if [ -d cgi-build ]; then rm -rf cgi-build; fi
        -mkdir cgi-build
        cd cgi-build && \
        CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
                --prefix=/usr --enable-force-cgi-redirect --enable-fastcgi \
                --with-config-file-path=/etc/php5/cgi \
                --with-config-file-scan-dir=/etc/php5/cgi/conf.d \
                $(COMMON_CONFIG) \
                --with-jpeg-dir=shared,/usr \
                --with-gd \
                --enable-gd-native-ttf \
                --without-mm \
                --disable-pdo \
                --without-mysql --without-sybase-ct --without-sqlite
        cd cgi-build && \
        cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
           ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
           ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
           Zend/
        touch configure-cgi-stamp

Code:
configure-apache2-stamp: patch-stamp
        dh_testdir
        if [ -d apache2-build ]; then rm -rf apache2-build; fi
        -mkdir apache2-build
        cd apache2-build && \
        CFLAGS="$(CFLAGS)" PROG_SENDMAIL="$(PROG_SENDMAIL)" ../configure \
                --prefix=/usr --with-apxs2=/usr/bin/apxs2 \
                --with-config-file-path=/etc/php5/apache2 \
                --with-config-file-scan-dir=/etc/php5/apache2/conf.d \
                $(COMMON_CONFIG) \
                --without-mm \
                --with-curl=shared,/usr \
                --with-zlib-dir=/usr \
                --with-gd \
                --with-jpeg-dir=shared,/usr \
                --with-xpm-dir=shared,/usr/X11R6 \
                --with-png-dir=shared,/usr \
                --with-freetype-dir=shared,/usr \
                --with-imap=shared,/usr \
                --with-imap-ssl \
                $(IBFLAGS) \
                --with-ttf=shared,/usr \
                --with-t1lib=shared,/usr \
                --with-ldap=shared,/usr \
                --with-mcrypt=shared,/usr \
                --with-mhash=shared,/usr \
                --with-mysql=shared,/usr \
                --with-mysqli=shared,/usr/bin/mysql_config \
                --with-pspell=shared,/usr \
                --with-unixODBC=shared,/usr \
                --with-recode=shared,/usr \
                --with-xsl=shared,/usr \
                --with-snmp=shared,/usr \
                --with-sqlite=shared,/usr \
                --with-sybase-ct=shared,/usr \
                --with-tidy=shared,/usr \
                --with-xmlrpc=shared \
                --with-pgsql=shared,/usr PGSQL_INCLUDE=`pg_config --includedir` \
                --enable-pdo=shared \
                --without-pdo-dblib \
                --with-pdo-mysql=shared,/usr \
                --with-pdo-odbc=shared,unixODBC,/usr \
                --with-pdo-pgsql=shared,/usr/bin/pg_config \
                --with-pdo-sqlite=shared,/usr
        cd apache2-build && \
        cp ../Zend/zend_ini_scanner.c ../Zend/zend_language_scanner.c \
           ../Zend/zend_ini_parser.h ../Zend/zend_language_parser.h \
           ../Zend/zend_ini_parser.c ../Zend/zend_language_parser.c \
           Zend/
        touch configure-apache2-stamp
(This post was last modified: 07-21-2008 10:55 AM by Nateside.)
07-21-2008 10:43 AM
Find all posts by this user Quote this message in a reply
Nateside Offline


Posts: 3
Joined: Jul 2008
Reputation: 0
Post: #8
RE: [HowTo] PHP5 cgi with bundled gd
Not sure if this has anything to do with the problem, but i noticed that in "configure-apache2-stamp: patch-stamp" these two lines don't seem correct...
Code:
--with-config-file-path=/etc/php5/apache2 \
                --with-config-file-scan-dir=/etc/php5/apache2/conf.d \
no such directories
Code:
HOST:~# ls /etc/php5/apache2
ls: /etc/php5/apache2: No such file or directory
HOST:~# ls /etc/php5/apache2/conf.d
ls: /etc/php5/apache2/conf.d: No such file or directory

also, in the "install: build" section, there is
Code:
cp debian/libapache-mod-php5.conf \
                debian/libapache-mod-php5
/conf.d/php5.conf
I don't have such files either,
07-21-2008 12:40 PM
Find all posts by this user Quote this message in a reply
robbs Offline


Posts: 4
Joined: Sep 2008
Reputation: 0
Post: #9
RE: [HowTo] PHP5 cgi with bundled gd
thanks
(This post was last modified: 09-16-2008 03:43 AM by robbs.)
09-15-2008 06:02 AM
Find all posts by this user Quote this message in a reply
muruli Offline


Posts: 1
Joined: Oct 2008
Reputation: 0
Post: #10
RE: [HowTo] PHP5 cgi with bundled gd
(01-04-2008 12:03 AM)hbaes Wrote:  In this short HowTo I will describe how You can rebuild the php5-cgi to use the php5-bundled gd library on debian etch.

This point is sometimes necessary if you or your application will use some special gd functions missing in the libgd but be part of the php5-gd. (i.e. imagefilter() or imagerotate() will be missing if you use the original debian etch php5-cgi)

firrst of all:
PHP Code:
apt get update 
PHP Code:
apt get upgrade 

change to the source directory
PHP Code:
cd /usr/src 

download the source for php5 from debian
PHP Code:
apt-get source php5-cgi 

download some other stuff for re-building the package:
PHP Code:
apt-get build-dep php5-cgi 

after that change to the new extract of php5-5*
when i write this the current version is php5-5.2.0:
PHP Code:
cd php5-5.2.0 

now edit the debian configuration:
PHP Code:
vi debian/rules 

change every line from
PHP Code:
--with-gd=shared,... 
to
PHP Code:
--with-gd 

in the section configure-cgi-stamp: patch-stamp add the following lines: (I didi it after the $(COMMON_CONFIG) line)
Quote:--with-jpeg-dir=shared,/usr \
--with-gd \
--enable-gd-native-ttf \

now save the rules file and start the re-building ...
PHP Code:
./debian/rules binary 
after a cuple of time change back to the source the directory
and you will see a couple of new .deb files.

PHP Code:
cd .. 

now install the new cgi binary
PHP Code:
dpkg -i php5-cgi_5.2.0-8+etch11_i386.deb 

after all restart apache ...
PHP Code:
/etc/init.d/apache2 restart 

thats all

Harald

Edit: Updated to the last Version, JPEG Support 4 GD enabled.
HI Harald,
i did all the steps mentioned but when i typed this
./debian/rules binary
i got error ie undefined refernce to pcre_exec . what to do now?
10-03-2008 06:53 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)