How to install gettext on MacOS X

后端 未结 4 1871
刺人心
刺人心 2020-12-13 18:43

How do I install gettext on mac?

I get this error on one of my php pages:

Fatal error: Call to undefined function bindtextdomain()

相关标签:
4条回答
  • 2020-12-13 19:12

    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:

    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
    
    0 讨论(0)
  • 2020-12-13 19:18

    I found an easiest working solution, which still works on mavericks. Here it is: https://stackoverflow.com/a/11792640/512504

    0 讨论(0)
  • 2020-12-13 19:26

    You can use brew to link gettext after installing it

    brew install gettext
    brew link --force gettext
    
    0 讨论(0)
  • 2020-12-13 19:34

    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 https://php-osx.liip.ch/install.sh | 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/libphp7.so with LoadModule php7_module /usr/local/php5-7.0.31-20180903-120321/libphp7.so (remember to uncomment the "#" symbol), then save and exit.

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

    0 讨论(0)
提交回复
热议问题