2013-02-18 16:04
浏览 529

如何在MacOS X上安装gettext

How do I install gettext on mac?

I get this error on one of my php pages:

Fatal error: Call to undefined function bindtextdomain()

and it's because I don't have gettext installed.

I can't find good instructions on how to install it. I've tried using:

brew install gettext

and it puts some files here:


but I don't know what to do with that.

Update: Instead of trying to use homebrew, now I tried this method unsucessfully using wget:

Download with wget

cd ~/Downloads
tar -zxvf gettext-0.18.2.tar.gz
cd gettext-0.18.2

make check is optional to run self-tests

make check

Errors I got:

make[3]: *** [check-TESTS] Error 1

make[2]: *** [check-am] Error 2

make[1]: *** [check-recursive] Error 1

sudo make install

That installs it here: /usr/local/share/gettext

And the documentation here: /usr/local/share/doc/gettext

but how do I make my php pages be able to use gettext and the bindtextdomain() function?

图片转代码服务由CSDN问答提供 功能建议


我收到此错误 我的一个php页面:


这是因为 我没有安装gettext。

我找不到有关如何安装它的良好说明。 我尝试过使用:

  brew install gettext 



但我不知道如何处理它。 \ n


使用wget下载 n

  cd~ / Downloads 
tar -zxvf gettext-0.18.2.tar.gz \  ncd gettext-0.18.2 

make check是运行自检的可选项

   make check 


make [3]:*** [check-TESTS] 错误1

make [2]:*** [check-am]错误2

make [1]:*** [check- 递归]错误1

  sudo make install 

在此安装它: / usr / local / 分享/获取文本

此处的文档: / usr / local / share / doc / gettext

但如何制作我的php页面 能够你 se gettext和bindtextdomain()函数?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • dpfz27768 2013-02-23 03:38

    I finally got it. You have to reconfigure php, so I ended up upgrading from 5.3.15 to 5.4.12. These websites were very helpful:

    #Install dependencies
    brew install libjpeg
    brew install pcre
    brew install libxml2
    brew install mcrypt
    #Get autoconf just because
    brew install autoconf
    #Install Intl extension
    #Install ICU
    #Download from
    cd ~/Downloads
    tar xzvf icu4c-4_8_1-src.tgz
    cd icu/source
    ./runConfigureICU MacOSX
    sudo make install
    cd ~/Downloads/php-5.4.12/ext/intl
    ./configure --enable-intl
    sudo cp modules/ /usr/lib/php/extensions/no-debug-non-zts-20090626/
    #Install gettext
    #Download from
    cd ~/Downloads
    tar xzvf gettext-
    cd gettext-
    sudo make install
    cd ~/Downloads/php-5.4.12/ext/gettext
    sudo cp modules/ /usr/lib/php/extensions/no-debug-non-zts-20090626/
    #Add intl and get text to php.ini
    cd ~/Downloads/php-5.4.12
    nano php.ini-development
    #Add these lines
    #Download PHP source files from
    cd ~/Downloads
    tar xzvf php-5.4.12.tar.bz2
    cd php-5.4.12
    ./configure \
    --prefix=/usr \
    --with-gettext \
    --mandir=/usr/share/man \
    --infodir=/usr/share/info \
    --sysconfdir=/private/etc \
    --with-apxs2=/usr/sbin/apxs \
    --enable-cli \
    --with-config-file-path=/etc \
    --with-libxml-dir=/usr \
    --with-openssl=/usr \
    --with-kerberos=/usr \
    --with-zlib=/usr \
    --enable-bcmath \
    --with-bz2=/usr \
    --enable-calendar \
    --with-curl=/usr \
    --enable-dba \
    --enable-exif \
    --enable-ftp \
    --with-gd \
    --enable-gd-native-ttf \
    --with-icu-dir=/usr \
    --with-iodbc=/usr \
    --with-ldap=/usr \
    --with-ldap-sasl=/usr \
    --with-libedit=/usr \
    --enable-mbstring \
    --enable-mbregex \
    --with-mysql=mysqlnd \
    --with-mysqli=mysqlnd \
    --without-pear \
    --with-pdo-mysql=mysqlnd \
    --with-mysql-sock=/var/mysql/mysql.sock \
    --with-readline=/usr \
    --enable-shmop \
    --with-snmp=/usr \
    --enable-soap \
    --enable-sockets \
    --enable-sysvmsg \
    --enable-sysvsem \
    --enable-sysvshm \
    --with-tidy \
    --enable-wddx \
    --with-xmlrpc \
    --with-iconv-dir=/usr \
    --with-xsl=/usr \
    --enable-zip \
    --with-imap=/usr/local/imap-2007 \
    --with-kerberos \
    --with-imap-ssl \
    --enable-intl \
    --with-pcre-regex \
    --with-pgsql=/usr \
    --with-pdo-pgsql=/usr \
    --with-freetype-dir=/usr/X11 \
    --with-jpeg-dir=/usr \
    make test
    sudo make install
    #Restart Apache
    sudo apachectl restart
    点赞 评论
  • duanao3204 2014-01-02 13:54

    I found an easiest working solution, which still works on mavericks. Here it is:

    点赞 评论
  • dpb_4431 2015-11-24 14:33

    You can use brew to link gettext after installing it

    brew install gettext
    brew link --force gettext
    点赞 评论
  • douji7399 2018-09-26 04:13

    If reinstall php is acceptable, try to download and install the php version you want from here.

    In my case, I used 7.0 version. Steps to reinstall:

    1. Open terminal and run curl -s | bash -s 7.0
    2. The installed php will reside at /usr/local/php5-7.0.31-20180903-120321/lib (I'm not sure why the directory name is php5-7xxxx, but the installed php version is 7.0)

    3. Edit apache2 config at /private/etc/apache2/httpd.conf (make a backup if necessary)

    4. Replace LoadModule php7_module libexec/apache2/ with LoadModule php7_module /usr/local/php5-7.0.31-20180903-120321/ (remember to uncomment the "#" symbol), then save and exit.

    5. Finally, run apachectl restart to restart your apache server.


    点赞 评论

相关推荐 更多相似问题