Saturday, February 16, 2008

Adding GD library for Mac OS X Leopard

Unfortunately the Mac OS Leopard PHP build doesn't bring GD library installed.
There are many tutorials around the web telling how to patch the system so you can have it working but all are very complicated and require the installation of Xcode, etc, so you need some gigs of free HD space and a lot of free time to do the trick.

After goggling for some hours searching the simplest tutorial, I have found this great solution that works like a charm and it's as simple and fast as write some commands in the terminal.
This tutorial tells you how to overwrite the system PHP installation with a new with GD built in.

So what you need to do is:
-> Open Terminal App
-> Write "sudo mv /usr/local/php5 ~/Desktop/php5.old" and press return
- You'll be asked for the admin login
-> Write "curl -O http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz" and press return
-> Write "tar -xzf php5-*-beta.tar.gz" and press return
-> Write "sudo mv php5 /usr/local/" and press return
-> Write "sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf" and press return
-> Write "sudo apachectl restart" and press return
- You're done :)

From: http://www.entropy.ch/phpbb2/viewtopic.php?t=2945&postdays=0&postorder=asc&highlight=leopard&start=0

84 comments:

Carlos said...

I tried to follow your instructions but I'm getting the following error in terminal:

mv: rename /usr/local/php5 to /Users/Carlos/Desktop/php5.old: No such file or directory

Got any idea what's going on?

Carlos said...

I just realized that the reason it's not working is because I don't have a php5 directory in "/usr/local". Not sure where it is, or if it even exists.

Btw, not sure if this is relevant, but i followed this tutorial to set up php on my macbook pro:
http://foundationphp.com/tutorials/php_leopard.php

Can you please help?

David said...

Thanks for the tutorial. A big help!

These two lines need to be combined to work when creating the link

from this:

-> Write "sudo ln -sf /usr/local/php5/entropy-php.conf" and press return
-> Write "/etc/apache2/other/+entropy-php.conf" and press return

to this:

-> Write "sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf" and press return

Ilija said...

I'm having the same problem as Carlos, in that /usr/local/php5 doesn't exist on my machine.

Was anyone ever able to work this out?

Ilija said...

life gets more interesting... I've compiled php and it exists in /usr/local/php5, but since it didn't work I tried MacPorts and now there's an install at /opt/local/bin/php (where "which php" points to). phpinfo() via Apache gives me version 5.2.4, while the php-config file for the version pointed to by "which" is 5.2.5.

php -m results in the following:
PHP Warning: PHP Startup: Unable to load dynamic library '/opt/local/lib/php/extensions/no-debug-non-zts-20060613/gd.so' - (null) in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
ctype
curl
date
dba
dom
exif
filter
ftp
gd
gettext
hash
iconv
imap
json
ldap
libxml
mbstring
mcrypt
mhash
mysql
mysqli
odbc
openssl
pcntl
pcre
PDO
pdo_mysql
posix
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
zlib

gd.so is nowhere to be found on my machine. Any suggestions on how to remedy either the a) mismatched PHP versions or b) getting gd.so?

Any help would be much appreciated.

Thanks,
-ilija

Carlos said...

ilija-- this is what I did to get it to work for me:

Add PHP5-5.2.5-beta.tar.gz to your home direcory (~name) and follow the directions in the below website starting from step 3.
http://docs.moodle.org/en/Step_by_Step_Installation_on_a_Mac_OS_X_10.5_Server#Install_the_GD_Library_on_the_Mac_OS_X_10.5_Server

Use the following as a reference if you get stuck, but I did not follow their instructions: http://www.entropy.ch/phpbb2/viewtopic.php?t=2945

hope that helps.

Ilija said...

Thanks for the response, Carlos. Unfortunately, I can't change the LoadModule line in my httpd.conf to point to the new PHP instead of the existing one in the Apache directory.

Doing so causing the following error to show in the Apache log file:
"caught SIGTERM, shutting down".

dlyons4480 said...

Just FYI for new users happening upon this tutorial:

This tutorial will not work for the standard Apple installation - only those that have installed the Entropy PHP package. That's (most likely) the reason for the 'No such file' error that some people are encountering.

If you used the foundationphp.com instructions to enable PHP like Carlos did then you're using the default Leopard install which stores files in different locations.

Sheldon said...

Carlos and everyone else who are trying to get this done on Leopard's base PHP5 installation, here's what you do.

-> Open Terminal App
-> Write "cd /private/etc" and press return
-> Use your favorite text editor to open httpd.conf
-> Find this "LoadModule php5_module libexec/apache2/libphp5.so" and add a "#" (no quotes) at the front of the line to comment out Leopard's default PHP5 library
-> Write "cd /usr/local" and press return
-> Write "sudo curl -O http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz" and press return
-> Write "sudo tar -xzf php5-*-beta.tar.gz" and press return
-> Write "sudo ln -sf /usr/local/php5/entropy-php.conf /etc/apache2/other/+entropy-php.conf" and press return
-> (Optional) Write "rm php5-5.2.5-6-beta.tar.gz" and press return to delete the downloaded archive
-> Write "sudo apachectl restart" and press return

anon_blogs said...

Sheldon you are the BOMB! Been trying to get this for a while now and then as simple as your step by steps say... DONE.

Thanks a bunch!

I salute in your general direction.

Stan Wiechers said...

But this doesn't include GD right, I can't seem to use it. Is there that needs to be done to enable it?

Stan Wiechers said...

Nevermind it worked, my problem was that restarting the server wouldn't take effect, so I had to kill it the hard way. And also that it found php first in path at /usr/bin before /usr/local/php5

Thanks very much,
Stan

matt said...

Thanks Sheldon!

dd said...

MANY (many) thanks Sheldon

Errol said...

Finally! I've been working with the entropy PHP install on Mac OS X Leopard for the last 3 days trying to get it to work. The forums didn't provide any help and all the other solutions were unusually complicated.

raw-m said...

This works a treat, thank you. There is one question I have - since doing this I'm not sure my error_log in the Console (under var/log/Apache2) is reflecting exactly what was going on as before (ie, undefined variables etc). Is there an additional step or am I better than I thought I was (unlikely!!). Regards.

raw-m said...

I found the solution to my php error_log not working.

These 2 lines need to be in the php.ini file (for some reason I also had to rename it from "php.ini-recommended" to "php.ini"), located here:
/usr/local/php5/lib/php.ini

error_reporting = E_ALL
error_log = "/var/log/php_error.log"

Hope it's of use.

charlie-imac said...

I was wanting to install the GD library but my system is showing:

PHP Version 5.2.5
config file php.ini /etc
loaded configuration /private/etc/php.ini

There is no httpd.conf in /private/etc

what am I missing?

nalgene said...

Sheldon's steps worked for me. The only thing that was different for me was the httpd.conf was located in /private/etc/apache2 and not /private/etc

DivingRhino said...
This comment has been removed by the author.
DivingRhino said...

This worked great for me, however when when I look at my status in Drupal I still see GD not installed.

Is there another step to get GD functioning?

GD does not show up in php_info ... so I looked for it in the php directory (and then in the downloaded files from the given link ... http://www2.entropy.ch/download/php5-5.2.5-6-beta.tar.gz) and could not find any GD references anywhere (such as gd.so or gd2.so, etc...)

DivingRhino said...

Update to my prior post.

I FINALLY found what I needed to get it working. I needed to comment out the following line in /etc/apache2/httpd.conf:

#LoadModule php5_module local/php5/libphp5.so

Reference found here:
http://www.maltete.com/blog/index.php?2008/05/03/388-installing-php-with-gd-library-working-on-mac-osx-105-leopard

Thanks!

Luke said...

Anoyone have any idea how to install the entropy PHP libs AND keep Apple's pre-installed MySQL working? I set the socket in the PHP.ini to match the apple installation (/private/tmp/mysql.sock) but the entropy install seems to want to use /tmp/mysql.sock

Marquez said...

Thanks Sheldon. Your comments worked the first time through. I think I know how to fix your problem Luke. PHP is confused which mysql.sock file to use. I found this at: http://www.sysarchitects.com/node/58

sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

anon said...

Sheldon, you just made my week. I'd tried ten other things and nothing worked. Then I spent 3 minutes with your info and I'm up and running. Thanks!

piknyc said...

Oh my, you save my life. This does the trick. Thanks!

dwight said...
This comment has been removed by the author.
shytalk said...

Truly excellent - much appreciated - thanx - PdeP

Dickens said...

I shared the same problem and thanks to Sheldon I now have a fresh install of php5 with the gd library.

THANKS A BUNCH!

tomo said...

Yet another very, very happy customer! But to clarify, in my case the MySQL link was also broken after following these steps, but I could not follow Marquez's steps because /var/mysql was already there!

So in my case I simply reversed the symbolic link, as:

sudo ln -s /var/mysql/mysql.sock /tmp/mysql.sock

vInce said...

Sheldon, thank you!
Worked first time!

brenna H said...

Sheldon: thank you.

Martin said...

Is this the same install for OS 10.5 server?

Yorick said...

I've followed Sheldon's advice and then raw-m's tip to enable error logging (adding error_reporting = E_ALL and error_log = "/var/log/php_error.log" to php.ini).

However, no error log file appears. I've tried creating my own /var/log/php_error.log file and get permission denied errors. What's the best way to handle this? Change permissions on /var/log?

Any help appreciated, thanks for all the great work so far.

Geniium said...

Thanks all!

Matthew said...

Thanks sheldon, wish I stumbled on this a few hours ago. Thanks a bunch

Paul Godard - Soul Photography said...

Unfortunately I am not that lucky. I have installed php/mysql a while ago on my macbookpro but now that I try to locate the httpd.conf file, I simply do not find it in any of the places indicated in this blog. Where is it? How do I find this file? I only find a file called httpd_conf.h in 2 locations.

I have php 5.2.6 | Apache 2.2.9.

What is going on here???

Rodrigo said...

This was great! I got PHP with GD library up and running. However, like others, this broke my mysql connection. I can access it all through the terminal but it's dead through PHP despite phpinfo() saying it's enabled.

phpinfo() shows the

MYSQL_SOCKET to be in /tmp/mysql.sock

and logged into mysql from the Terminal I also get that location by typing in :

mysql> SHOW VARIABLES LIKE '%socket%';

I'm really stumped for a solution. I noticed that before I did all this PHP was working with MySQL and phpinfo() said /var/mysql/mysql.sock for MYSQL_SOCKET.

I've tried to change /usr/local/php5/lib/php.ini to read mysql.default_socket = /var/mysql/mysql.sock
but it doesn't seem to affect PHP at all and phpinfo() still reports MSYQL_SOCKET /tmp/mysql.sock

Grrr! This is so frustrating! So I've gained GD library but I've lost connection MySQL :=(

Annie Béland said...

Thank you very much!!! This is a pretty simple solution and worked on Leopard :)

Djannick said...

To have GD library AND MySQL, I modify file /etc/my.cnf with:

[client]
socket = /tmp/mysql.sock
[mysqld]
socket = /tmp/mysql.sock

And now GD+MySQL works like a charm !

ian said...

Thank you Diving Rhino!

Marc did mention that you really have to kill the old php5 - it's persistent and kept coming back until I commented out that line and restarted, letting Marc's package load.

AWESOME.

tiktuk said...

This very nice tutorial explains how to compile GD separately and load it into the existing php/apache setup. It worked for me.

littlevisuals said...

Hi Paul,

You can only find the httpd_conf.h because the httpd_conf file is hidden.

The easiest way is to download text wrangler. Then open the program and from the File menu, select Open Hidden. In the Open dialog box, select All Files from the Enable drop-down menu. Then navigate to Macintosh HD:private:etc:apache2:httpd.conf, and click Open.

Here you can follow sheldons answer.

Hope this helps for anyone

beakid said...

Thanks! Your comment worked perfect for me!

Tried with phpinfo(); in my php-file afterwards to confirm that gd was installed - and it was. Thanks a lot! :)

cascoman said...

Hi,

Thx for this solution. Work's perfect, now i have GD Library running on Leopard, but, and I have a problem, big problem... I lost my MySQL datababses!!! and my password for "root" user.

What can I do?

Tanks ;-)
LeGo

cascoman said...

Well... after hours and hours... I've found a solution here: http://protichnoctem.blogspot.com/2008/05/install-gd-library-in-leopard.html

----------
...
cd /usr/local/php5/lib
sudo mv mysql mysql.old
sudo ln -s /usr/local/mysql/lib mysql

restart apache
...
----------

That's all friends!

lardlad said...

I am having problems with MySQL too. MySQL is running and I can connect with MySQL Administrator and MySQL Query Browser but I get access denied in PHP for all users, even root.

Ben said...

There is a much easier and safer way of installing PGP with GD! Use the package here:
http://www.entropy.ch/software/macosx/php/

Just run the installer! That's it!

Howdy said...

the "sudo" line worked for me but then it prompts me for a password? i tried typing the next line but it says "Sorry, try again." What should I do? Thanks.

ClubPaperJack said...

Thanks Ben (and the earlier contributors especially Sheldon) Ben's suggestion works fine. (I paid particular attention to the warning about disabling the PHP that comes with 10.5 .

ClubPaperJack said...

Howdy, have you got the root user enabled? (Open Directory Utility, click the lock, Edit->Enable Root User. )

Roman said...

Your instructions are great and it did what it was supposed to, but now it seems when I try to install Drupal I only have the option of msqli and pgsql databases. Any ideas why this is happening or this was even caused by the GD library installation? Before I added GD library Drupal 6 easily installed. I'm running mySQL 5.0.87. Could it have anything to do with the socket? Thanks in advance.

Roman said...

Sorry, I forgot to mention I used the solution you had given to Carlos.

Patrick said...

So, I cannot to login into mysql as root from phpmyadmin as well now. It only works from mysql prompt.

What can I do to fix it ?

thanks

Ollie Rattue said...
This comment has been removed by the author.
Ollie Rattue said...

Many thanks for taking the time to write this up.

Sheldon, thank you for your additional configuration changes to httpd.conf.

javieth said...

I liked this blog because is easy understandable and very useful. for me Os X is the best software that i proved before. I really like this kind of technology because isn´t complex to use.
buy viagra

brinkka said...

Erectile Dysfunction FAQ's

Impotence, or penile erectile dysfunction, in men is not as rare as one would think it is.
In fact, one out of ten men around the world is affected by this condition. It is not exclusive to old men either. Impotence is caused not just by physical factors,
but mental factors as well.
Exercising on a regular basis and eating healthy food will increase your ability to sustain prolonged physical effort and we all know that sex is effort.
Smoking, frequently drinking large quantities of alcohol, taking recreational drugs and lack of exercising will sap your stamina and also slow down the flow of blood.
Penis exercises can be used for maintaining fitness, preventing or controlling premature ejaculation and increasing the length and girth of the penis.
by penis enlargement pills you can overcome these problems and not only that you can also enlarge, extend also to strengthen your penis and premature ejaculation will not exist anymore for you.
visit http://www.factspenisenlargement.com for more info.

Topo said...

What a great idea!! i'ld like to know more how many people you met on 1st sept, i'm quite late to see this blog.
Mr. president doing great with health issues, vigrx plus just few day's before FDA release new rules of packed food products to display all the details of energy and this are issued with taking public opinions from allover country.

Very good! Nice information this is really interesting. Good luck in building the table.

vigrx plus | vimax pills | penis enlargement pills | penis enlargement

male said...

For men who want bigger, harder, longer-lasting erections, there's now VigRX Plus™, a fresh twist on the already popular VigRX™, but designed to further enhance men's sexual functioning with the addition of three exciting new ingredients: Damiana, Tribulus, and Bioperin. Doctor endorsed and rated #1 for results by clients of penis enlargement consumers. rated two penis pills is vimax. if you find about male enhancement this products is the best and proven to work, there products have money-back guarantee in effectiveness and result.

kiara said...

Costa Rica Tours
Tours Costa Rica

LFS said...

Sheldon, THANK YOU for you impecable instructions, they were flawless. Thank you thank you!!

LauraStarBene said...

Nice post!! Thanks for sharing!
Levitra Generico

kimnellen2587 said...

very informative post, thanks for sharing it with usManchester photography studio hire

jelish said...

The Louboutin 2011 is planned using the ladies. offered the fact that pumps was born, the ladies lifestyle turn into colorful. The christian Louboutin 2011 Pumps
will be the god's masterwork. Who invited the Christian Louboutin Wedges ? Seldom people knew, but I think each and every and every lady will be grateful for him. between the countless pumps,the Christian Louboutin Shoes
could be probably the most exceptional ones. The stylish pattern, the delicate design all mold the ladies perfect leg profile. Flowers inside the spring of 2011 creeping, up from frizzy hair to outfits hold on to footwear, have experienced a brilliant up. on this type of the glamor, spring and summer time flowers now here. Romance is really a woman's mood, exquisite flowers just appropriate of expression within our gestures, the woman, how can we not adore the romantic temperament to make certain which they distributed the flowers do? 2011 flowers bloom will get satisfaction from numerous poses! The Christian Louboutin New Sandalsalso can adds the hright in the ladies, it hold shock toward short lady. especially the red-colored lone in the louboutin heels, beauty and sexy, different ladies are crazy. The red-colored sole, the earliest attribute in the Sale Louboutin stroe.

truddy said...

Want to be the fashionable person?Sexy and beautiful women are always men's favor. Now come to Louboutin UK store! We will change you into a gorgeous girl! Here provides Christian Louboutin Fashion,Louboutin 2011,Christian Louboutin Wedding,louboutin platforms,Louboutin Wedges and so on.The unique and well-Designed shoes favored by the world, signed with the Christian Louboutin red soles of the mark, giving high heels and covetable accessories, system pumps and elegant luxury Christian Louboutin clutch has to be available almost all fashion only. We now provide Christian Louboutin shoes with free shipping and save 60% off! Hurry up! Christian Louboutin UK store is your first choice!

abercrombiefitch said...

Be fast to browse the newest styles and lots of affordable outfits and Nike oxygen Max and women's merchandise is not an daily affair, for that reason that in the stress of modern day time girls ordinarily do not possess a complete great offer time and vitality to go buying by means of countless many style malls, and look at special fees will make you exhausted, so which you can acquire a satisfactory goods, call up for to devote lots of time, the show up of on collection buying significantly minimizing the inconvenience of this, now you not just can every one of the sudden go to to lots of goods Nike Air Max Shoes .

LauraStarBene said...

Nice post! Thanks for sharing!

date: said...

the web telling how to patch the system so you can have it working but all are very complicated and require the installation of Xcode, etc, so you need some gigs of free HD space and a lot of free time to do the trick.turtle ridge homes

baele said...

Adidas have unveiled their supercharged Elite Nike vapor soccer shoes, designed and engineered to provide new levels of performance. The SoccerBible is your first stop for full and exclusive images of the Nike CTR360 II ELITE. The Nike T90 Laser Elite are truly a stunning boot, both visually and in-hand. Set to be championed by Wayne Rooney at this summer's World Cup, the Nike mercurial vapor fg are almost a hybrid boot as they combine Laser technology and Nike mercurial vapor with the Vapor series!Nike Mercurial Superfly.

sping.chen said...

Ah good exciting content! Will always come to our attention. To bring you good news-works perfect! Nike Football Cleats best shoes 2011!! And Nike Mercurial Vapor Superfly.Nike soccer cleats with New nike soccer shoes or Nike mercurial soccer cleats .

hbalxb said...

black boots

Chocolate boots

sand boots

Chestnut boots

gray boots

pink boots

grey boots

Ugg Boots For Sale

Sand Ugg Boots

weerah said...

buy codeine online

Great article.
Thanks for sharing this post!

mark said...

cost effective advertisingThanks for your post, I like this post very much.

Silviu said...

This tutorial about how to overwrite the system PHP installation with a new with GD built in is awesome!It's just what I needed.


Bianca plantarea trandafirilor Jessy

mark said...

Thanks to a brilliant effort in publishing your article. One can be more informative as this. There are many things I can know only after reading your wonderful article.drug discussion
drug discussion forum
drug forum

Colin said...

I am visiting this site first time & it has awesome information. I have come to know a lot of information after visiting this site. Keep this sort of posting in future as well.....
buy watson

ftn said...

Thanks for the post. I followed someone's recommendation to install the latest one from this site and it works like a charm! Just one command line :)

http://php-osx.liip.ch/

Sabra Allsbrook said...

Nice! Reading the same blog repeatedly it was boring, when i read your blog it was amazing and very interesting the way of narration is awesome, I am glad that i found such a beautiful post. Thank you for sharing them.

Cheap hotels in los angeles

Unknown said...

how may i know more information from your website.
share with me the process.
pharmacy reviews

cheap cialis said...

mac os is great os ...
i like this article about mac os i like this thanks for this article ..
i got very informative information thanks ..

airfrance booking

sewi said...

This is a good blog for anyone who wants to know about this topic.It tells good things about living happily and falling in love. Thanks for sharing such a nice blog to everyone. Damiana

TXQ Design said...

Sheldon MAESTRO :D Thanks a lot <3

dolinna said...

This is so much more than i needed!!! but will all come in use thanks!!I am a china tour lover,You can learn more: Beijing travel guide | Guilin Attractions | Guilin Sightseeing