Installing Gettext on OS X 10.11.X El Capitan

Before you get started, you need to make sure some basic requirements are met:

  • You have made a backup of your system.
  • You have the latest version of Apple’s Developer Tools (Xcode 7 or higher for 10.11.x including command line tools) installed. Dev Tools are available as a free download from the Mac App Store

First we need to download and compile gettext.

sudo -s

mkdir -p /topicdesk/sources

cd /topicdesk/sources

curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-0.19.6.tar.gz

tar xzf gettext-0.19.6.tar.gz

cd gettext-0.19.6

./configure --prefix=/usr/local/topicdesk

make

make install

Next we need to get download Apple’s version of PHP from http://www.opensource.apple.com in order to be able to build a dynamic library for PHP.

cd /topicdesk/sources

curl -O http://www.opensource.apple.com/source/apache_mod_php/apache_mod_php-101/php-5.5.30.tar.bz2

tar xjf php-5.5.30.tar.bz2

cd /topicdesk/sources/php-5.5.30/ext/gettext

phpize

./configure --prefix=/usr/local/topicdesk --with-gettext=/usr/local/topicdesk

make

make install

Unless you have disabled SIP, you will now see an error while the install script tries to move gettext.so into /usr/lib/php/extensions/no-debug-non-zts-20121212/
This is not a problem and can be solved by manually copying gettext.so to where we need it.

mkdir -p /usr/local/topicdesk/lib/php/extensions

cp -rp /topicdesk/sources/php-5.5.30/ext/gettext/modules/gettext.so /usr/local/topicdesk/lib/php/extensions

Now all we need to do is to modify our /etc/php.ini file and add:

extension=/usr/local/topicdesk/lib/php/extensions/gettext.so

When done, we need to make sure apache is restarted, by issuing:

server-apachectl graceful
1 reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.