Adding support for the GD graphic library on OS X 10.5 Leopard

I play around with a number of Drupal locally and today I finally caved in and decided to add GD support to OS X's webserver. Although I've heard great things about the Entropy PHP packages, I did not want to replace OS X's integrated php installation so my remaining option was to grab a copy of PHP 5.2.8 (the version bundled with Leopard) and compile the module myself. I know there must be quite a few other people who are looking do to the same thing, so I here's a step-by-step guide on how I did it:

(Please note that I assume you have Xcode installed, and that all downloads are saved in the "Downloads" folder in your home. If this is not the case, please move the downloads there first before executing any of the listed commands)

  1. Visit the libpng and libjpeg homepages and download the latest release available for both. As of writing, the most recent releases are libjpeg 7 and libpng 1.2.37 - the commands below will need to be adjusted slightly if you are compiling a more recent version.
  2. Download PHP 5.2.8, available here
  3. Extract PHP and prepare to compile libpng and libjpeg statically:
    cd ~/Downloads
    tar xfj php-5.2.8.tar.bz2
    cd php-5.2.8/ext/gd
    mv ~/Downloads/libpng-1.2.37.tar.gz ~/Downloads/jpegsrc.v7.tar.gz .
  4. Compile libpng without shared libraries:
    tar xfz libpng-1.2.37.tar.gz && cd libpng-1.2.37
    ./configure --disable-shared --enable-static
    make && make install DESTDIR=`pwd`/localinstall
    cd ../
  5. Compile libjpeg without shared libraries:
    tar xfz jpegsrc.v7.tar.gz && cd jpeg-7
    cp /usr/share/libtool/config.* .
    ./configure --disable-shared --enable-static
    make && make install DESTDIR=`pwd`/localinstall
    cd ../
  6. Compile the GD extension and point to our newly compiled libpng and libjpeg static libraries:
    cd ~/Downloads/php-5.2.8/ext/gd
    phpize
    MACOSX_DEPLOYMENT_TARGET=10.5 \
    CFLAGS="-O3 -fno-common -arch i686" \
    LDFLAGS="-O3 -arch i686" \
    CXXFLAGS="-O3 -fno-common -arch i686" \
    ./configure --with-zlib-dir=/usr \
    --with-png-dir=`pwd`/libpng-1.2.37/localinstall/usr/local \
    --with-jpeg-dir=`pwd`/jpeg-7/localinstall/usr/local \
    --with-freetype-dir=/usr/X11R6 \
    --with-xpm-dir=/usr/X11R6
    make
    sudo make install
  7. Copy /private/etc/php.ini.default to /private/etc/php.ini
    • Change the default 'extension_dir' (./) to /usr/lib/php/extensions/no-debug-non-zts-20060613/
    • Add extension=gd.so a bit below extension_dir to enable the gd extension
  8. sudo nano /System/Library/LaunchDaemons/org.apache.httpd.plist
    Change the part between <array> and </array> so that it looks like this:
    <array>
    <string>/usr/bin/arch</string>
    <string>-i386</string>
            <string>/usr/sbin/httpd</string>
            <string>-D</string>
            <string>FOREGROUND</string>
    </array>

    This will ensure that Apache starts in 32 bit mode, which is needed as the gd extension was compiled for i686.
  9. That's all! After a reboot (or toggle Web sharing in the System Preferences), everything should be working. phpinfo() should now confirm that GD library is indeed loaded. If it isn't or if apache refuses to start, try opening Console to check /var/log/apache2/error_log for some useful pointers as to what's wrong.

    Helpful source I used for writing this tutorial: HOWTO: Install Habari on Mac OS X Leopard, From Scratch

Rating: 

Comments

I've always been hesitant to enable comments on my posts due to spambot activity, but I'm hoping Drupal is a bit better than Joomla at fending spammers off... I'm going to enable (moderated) comments for a week and see how it goes. Feel free to leave a comment on any of my articles!

Rating: 

Getting MobileMe to work with any email address

A friend of mine recently bought a MobileMe subscription and I was pretty curious about what it would offer as I've seen the demos from Apple's WWDC keynote. After experimenting with it for a bit while I was setting it up on my friend's home computers, I found that it is actually a very worthwhile purchase for for both home and small business users. The one downside to it was that Apple does not allow the use a non- @me.com email address. Luckily, after about an hour of playing I was able to setup a system which enabled Thunderbird and other email clients to use the MobileMe email features with non- @me.com email address.

The problem is Apple's outgoing mail (SMTP) servers, which reset the From: header in all messages. No matter how you configure your client, all outgoing mail shows From: myuser@me.com. By avoiding the Apple's SMTP servers, you can bypass this problem and send mail as if it was sent from your previous address (for example yourname@yourdomain.com). Here are the steps required to set it up:

  1. Forward all incoming mail to your MobileMe address

    CPanel and many other hosting control panels will support forwarding all mail from one address to another. In CPanel, click on "Mail Forwarders" and forward all mail from your previous address to youruser@mobileme.com. If your hosting provides a different control panel and you can't find the mail forwarders option, try contacting your hosting's technical support team for more information.

  2. Configure your email client (incoming mail)

    In order to receive new messages, you will need to create a new IMAP account. Email clients such as Outlook, Outlook Express, Thunderbird, Entourage and Apple Mail all support IMAP. Apple has a step-by-step guide for setting up each of the programs listed above. If you are using another program, you'll need to enter the following settings manually:

    • Account type: IMAP
    • Incoming server: mail.me.com
    • Incoming username: Your MobileMe account name (the part before "@me.com")
  3. Configure your email client (outgoing mail)

    Instead of entering the outgoing (SMTP) details as listed on the Apple tutorial, enter the information for your hosting that you previously used instead. For example, your outgoing server may be mail.yourdomain.com or smtp.yourdomain.com.

  4. (Optional) Create identities

    If you are forwarding many custom email addresses to your MobileMe account, you may want to take the time to use the Identity feature of your mail client so that you can reply mail as if writing form any of the many custom emails instead of just one (different clients may offer the same feature but under a different name). In Thunderbird, you can manage your Identities by selecting Tools > Account Settings... > Manage Identities

The only trouble you may encounter with this method is that sending mail from the MobileMe Web interface will still show @me.com, as the webmail passes through Apple's SMTP servers.

Note: This procedure works for iPods too! If you configure your iPod's incoming and outgoing mail as shown above, you should also be able to send mail from your custom address as well.

Rating: 

Installing the proprietary nVidia graphics driver for better 3D performance on nVidia cards

Requirements

What is the difference between the proprietary and open source nVidia drivers?

Rating: 

Enabling various types of media content in Fedora (DVD, MP3, Flash, Java)

Requirements

I want them all!

If you want to install all of the items listed in this howto, install the following items:

Rating: 

Managing packages on your system using PackageKit

Background information: Packages and package managers

Rating: 

Enabling Presto: Speed up your Yum updates and save bandwidth

Requirements

What are Delta RPMs?

Rating: 

Fedora 11 is out!

You can grab it here. I will post some updated howtos soon.

Rating: 

iTunes 8.2.0

Apple Software Update just popped up with an update for QuickTime and iTunes... The changelog indicates that it has added support for iPhones OS 3.0. I am installing it now, back soon with more info.

Edit: Okay, so apart from bug fixes nothing much seems to have changed for now - iPhones OS 3.0 isn't available immediately.

Rating: 

Troubleshooting the MySQL Server 5.1 service on Windows Vista

Although some users have reported success, most installations I've tried of MySQL 5.1 on Vista have failed, even on fresh Vista installs. The first problem appears at the end of the service instance configuration. All appears to be well, however the server refuses to start with Could not start MySQL service or Could not start the service MySQL. Error: 0.

The trick is to start MySQL from the console so that you are able to see the error message (you can access the command console by typing cmd into the Run dialog):

cd "C:\Program Files\MySQL\MySQL Server 5.1\bin"
mysqld -nt --defaults-file="C:\Program Files\MySQL\MySQL Server 5.1\my.ini" --standalone --console

In my case, MySQL always returned the same error message:

Plugin 'InnoDB' init function returned error.
Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Unknown/unsupported table type: INNODB
Aborting
Forcing shutdown of 1 plugins

This message is a symptom of the log file size problem (just google InnoDB: Error: log file .\ib_logfile0 is of different size for more information). All you need to do is to clear the following files from the folder C:\ProgramData\MySQL\MySQL Server 5.1\data:

ib_logfile0
ib_logfile1
ibdata1
$YOUR_HOSTNAME$.err

Restart the MySQL server and all should be well. Note that the C:\ProgramData\ folder is hidden, so unless you have enabled hidden folders from the Folder Options dialog, you will need to copy/paste that folder path directly into the address bar in order to access the folder.

Rating: