I have a brand new Mac, with Lion preinstalled. I enabled Apache, the PHP module.
phpinfo()
works but there is no support for gettext.
Writing extension=php_gettext.so
in php.ini did not help. So I tried to locate
it in the filesystem, but it seems there are no PHP extensions available.
Where are PHP extensions in OS X Lion?
EDIT : Just tested and still works on Mavericks as long as you update MAMP with the latest version . Here is the full tutorial :
I managed to make it work using the gettext.so
from MAMP with Mac OS X Apache/PHP native server. Here is how to so it :
Copy the MAMP gettext.so built for php 5.5.10 to Mavericks' local php extensions folder:
sudo cp /Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non-zts-20100525/gettext.so /usr/lib/php/extensions/no-debug-non-zts-20100525/
Update Mavericks' /etc/php.ini
file by adding this new line :
extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/gettext.so
Restart apache :
sudo apachectl restart
After that you can use _()
and gettext()
functions.
Thanks to @MountainAsh for noticing that we can't remove MAMP after this procedure since gettext uses one of MAMP libraries.
OS X so far does not include gettext (since my first attempt from 10.4). You'll have to build it yourself. I followed the process below and worked under 10.6 (taken from an Apple forum discussion thread). It's still working now in 10.7. Note that this is to install gettext module, not php_gettext. Though they function pretty much the some way, initialization supposedly is different. Remember though to swap the link for the right PHP version. I think 10.7 comes with PHP 5.3.6. You'll need to search for it.
Try this as root (or issue sudo -s before):
mkdir -p /SourceCache
cd /SourceCache
curl -O http://ftp.gnu.org/pub/gnu/gettext/gettext-0.17.tar.gz
tar xzf gettext-0.17.tar.gz
cd gettext-0.17
MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure
make
make install
cd /SourceCache
curl -O http://www.opensource.apple.com/source/apachemod_php/apache_modphp-53/php-5.3.0.tar.bz2
tar xjf php-5.3.0.tar.bz2
cd /SourceCache/php-5.3.0/ext/gettext
phpize
MACOSXDEPLOYMENTTARGET=10.6 CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" LDFLAGS="-arch i386 -arch x86_64 -bindatload" ./configure
make
make install
When done, edit/create /etc/php.ini and add: extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/gettext.so
next issue: sudo apachectl graceful
Good luck!
对我而言,从http://php-osx.liip.ch重新安装当前的PHP版本(在OS X 10.10.5 Yosemite上为5.5.29)是最简单的解决方案-无需构建自己的gettext.so扩展名更多。
/usr/lib/php/extensions/
You will find them here...
gettext does not seem to be included in Lion's version of PHP.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.