Link to home
Start Free TrialLog in
Avatar of lolavarrieta
lolavarrieta

asked on

PHP + GD in CentOS 4.3

How can I recompile my PHP in CentOS 4.3 so it can support GD? I already instaled JPgraph and it doesnt work. My apache and php where instaled from rpms
Avatar of Richard Quadling
Richard Quadling
Flag of United Kingdom of Great Britain and Northern Ireland image

This is from the PHP Manual ...

Installation
To enable GD-support configure PHP --with-gd[=DIR], where DIR is the GD base install directory. To use the recommended bundled version of the GD library (which was first bundled in PHP 4.3.0), use the configure option --with-gd. GD library requires libpng™ and libjpeg™ to compile.



Unfortunately, I'm a windows user so I don't need to compile anything. All done for me by those very nice people at PHP.net

you need to build GD with following configure options:
        --with-freetype=$PREFIX
        --with-jpeg=$PREFIX
        --with-png=$PREFIX
(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)
As a windows user I'm not really sure what happens on *ix.

When you compile PHP, do you compile in all the extensions into 1 big exe?

Or do you compile each extension separately? Allowing for easier amendments?

If so, does the extensions= settings in php.ini have any effect?

If you've compiled it in, it is available!

Wouldn't compiling each extension separately be a better option? That way, they can be loaded on demand?

You don't need to recompile anything. Install php-gd rpm.
If you install an rpm, you are probably going to need to enable the extension within php.ini.
>>>  If you install an rpm, you are probably going to need to enable the extension within php.ini.

No you don't. RPM does it for you, you only have to restart Apache.
Are RPM's binary compatible with CentOS?
The RPM I am talking about is part of the distribution, it should be on your CD's or available through yum install. Pretty much everything in CentOS is RPM-based, so this is like asking if I am biologically compatible with my own arms and legs ;)))
Hey! You may be a transplantee! In which case the possibility of rejection is always present!

But the CD would only contain an old version.

If you want to get the LATEST version (i.e. from source), then you would normally need to compile it as binaries are only held for Windows. Though with the new and free Microsoft C++ 2005 Express Edition, this may all change!

Trust me, you DON'T want the latest version if a regression-tested and patched version is available in your distribution. Been there, done that.
Ok. That makes sense.

Avatar of limneos
limneos

even YUM could do this for you, provided that your repos include php-gd

try typing at the shell prompt:

yum install php-gd
split 50/50 m1tk4, limneos
Agree. I don't think I contributed anything to this question.
hmm, the question was:
> How can I recompile ...
yum and rpm are not usefull to recompile anything (except you use a source package which has *not* been suggested), so I disagree with the suggested split and belieave in my suggestion
>>My apache and php where instaled from rpms

is the key. He did not NEED to recompile anything.
hmm, we get into a philosophic discussion ..
I refer to a question (that's what EE is for) while you refer to a statement. We don't need solutions for what is already done.
I refer to a particular situation he is in (stock PHP RPMs installed), in which the best and easiest way to solve his problem (missing GD) is to install stock php-gd RPM, and not to recompile PHP from the scratch. As you say yourself,

>>We don't need solutions for what is already done.

You don't need to recompile to get GD if it's already done for you.
> You don't need to recompile to get GD if it's already done for you.
agreed (in most cases that's true)
So what we do here?
split or PAQ with 0 points
The answer is either recompile along the lines of the PHP manual

OR

install the appropriate pre-compiled libraries and activate them.


Both are valid ways of acheiving the goal IF the goal is only to get the library activated.

But, if the goal was to learn how to compile PHP and to enable GD EVEN THOUGH the library is available pre-compiled (the fact that precompiled modules were previously used is just info), then I think (oddly enough), my comments are the only valid answer.

m1tk4, "You don't need to recompile to get GD if it's already done for you.".

Absolutely true, but without a clearer indication from the questioner as to his primary goal (compiling OR installing GD), I think it has become a 3 way split. But maybe I don't deserve any for being greedy! I would hope that I do though.

125 point puhleeze - we are discussing this in 10 messages already?!?! I suppose if we are all that smart to be experts we are all probably gainfully employed and have better (and more important things to do than discuss who was right and who wasn't and why? PAQ w. 0 and move on.
PAQ w. 0 then.
agreed
actually, i object to PAQ with 0.  i'm in the exact same situation as the original poster and didn't know the php-gd rpm was available through yum in centOS.  i don't know who should get points, b/c i don't know what the author was thinking either, but the suggestion to just load the php-gd package solved the problem, even if the solution wasn't done through the way the author asked for it.

for all i care, you can reduce the points to 0, but at least mark it as solved for anybody that happens upon it in the future.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial