【问题标题】:How to install gettext on MacOS X如何在 MacOS X 上安装 gettext
【发布时间】:2013-02-03 02:59:21
【问题描述】:

如何在 mac 上安装 gettext?

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

Fatal error: Call to undefined function bindtextdomain()

这是因为我没有安装 gettext。

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

brew install gettext

它把一些文件放在这里:

/usr/local/Cellar/gettext/0.18.2

但我不知道该怎么办。

更新:现在我没有尝试使用自制软件,而是使用 wget 尝试了这种方法,但没有成功:

使用 wget 下载

cd ~/Downloads
wget http://ftp.gnu.org/gnu/gettext/gettext-0.18.2.tar.gz
tar -zxvf gettext-0.18.2.tar.gz
cd gettext-0.18.2
./configure
make

make check 对于运行自检是可选的

make check

我遇到的错误:

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

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

make[1]: *** [check-recursive] 错误 1

sudo make install

安装在这里: /usr/local/share/gettext

这里的文档: /usr/local/share/doc/gettext

但是如何让我的 php 页面能够使用 gettext 和 bindtextdomain() 函数呢?

【问题讨论】:

    标签: php macos


    【解决方案1】:

    安装后可以使用brew链接gettext

    brew install gettext
    brew link --force gettext
    

    【讨论】:

    • 我希望这行得通,它似乎没有链接到从 mac os 传递的 php
    • 对 High Sierra 没有帮助。在 Cellar 中安装源代码,但没有链接到 PHP
    • 在 Mojave 10.14.5 上完美运行。谢谢!
    • 这不会为 PHP 安装 gettext(按照 OP 的要求),它只安装 gettext。
    【解决方案2】:

    我终于明白了。你必须重新配置 php,所以我最终从 5.3.15 升级到 5.4.12。这些网站很有帮助:

    http://mac.tutsplus.com/tutorials/server/upgrading-the-native-php-installation-on-os-x-mountain-lion/

    http://mansion.im/2011/php-with-intl-and-gettext-on-osx-lion/

    #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 http://site.icu-project.org/download/48#ICU4C-Download
    cd ~/Downloads
    tar xzvf icu4c-4_8_1-src.tgz
    cd icu/source
    ./runConfigureICU MacOSX
    make
    sudo make install
    
    cd ~/Downloads/php-5.4.12/ext/intl
    phpize
    ./configure --enable-intl
    make
    sudo cp modules/intl.so /usr/lib/php/extensions/no-debug-non-zts-20090626/
    
    #Install gettext
    #Download from http://ftp.gnu.org/gnu/gettext/
    cd ~/Downloads
    tar xzvf gettext-0.18.1.1.tar.gz
    cd gettext-0.18.1.1
    ./configure
    make
    sudo make install
    
    cd ~/Downloads/php-5.4.12/ext/gettext
    phpize
    ./configure 
    make
    sudo cp modules/gettext.so /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
    extension=intl.so
    extension=gettext.so
    
    #Download PHP source files from php.net
    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 \
    --with-png-dir=/usr/X11
    
    make test
    sudo make install
    
    #Restart Apache
    sudo apachectl restart
    

    【讨论】:

    • 谢谢;这帮助我修复了我在 Mac (OS X 10.8.5) 上遇到的“-bash: envsubst: command not found”
    【解决方案3】:

    我找到了一个最简单的解决方案,它仍然适用于小牛。这里是:https://stackoverflow.com/a/11792640/512504

    【讨论】:

      【解决方案4】:

      如果可以重新安装php,请尝试从here下载并安装您想要的php版本。

      就我而言,我使用的是 7.0 版本。重装步骤:

      1. 打开终端并运行curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
      2. 安装的php会驻留在/usr/local/php5-7.0.31-20180903-120321/lib(不知道为什么目录名是php5-7xxxx,但是安装的php版本是7.0)

      3. /private/etc/apache2/httpd.conf 编辑 apache2 配置(必要时进行备份)

      4. LoadModule php7_module libexec/apache2/libphp7.so替换为LoadModule php7_module /usr/local/php5-7.0.31-20180903-120321/libphp7.so(记得取消注释“#”符号),然后保存退出。

      5. 最后,运行apachectl restart 重启你的apache服务器。

      【讨论】:

        猜你喜欢
        • 2011-01-08
        • 2010-09-19
        • 2013-06-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-07
        • 2021-09-19
        • 2011-07-26
        相关资源
        最近更新 更多