简体   繁体   English

Mac OS X Lion上的PHP:gettext模块在哪里?

[英]PHP on Mac OS X Lion: where is gettext module?

I have a brand new Mac, with Lion preinstalled. 我有一台全新的Mac,预安装了Lion。 I enabled Apache, the PHP module. 我启用了Apache(PHP模块)。

phpinfo() works but there is no support for gettext. phpinfo()有效,但不支持gettext。

Writing extension=php_gettext.so in php.ini did not help. 在php.ini中编写extension=php_gettext.so没有帮助。 So I tried to locate it in the filesystem, but it seems there are no PHP extensions available. 因此,我尝试在文件系统中locate它,但似乎没有可用的PHP扩展。

Where are PHP extensions in OS X Lion? OS X Lion中的PHP扩展在哪里?

EDIT : Just tested and still works on Mavericks as long as you update MAMP with the latest version . 编辑:只要您使用最新版本更新了MAMP,就刚刚经过测试并且仍然可以在Mavericks上 使用 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. 我设法在Mac OS X Apache / PHP本机服务器上使用MAMPgettext.so使其工作。 Here is how to so it : 这是这样的:

  1. Download and install MAMP (pro not needed) 下载并安装MAMP(无需专业人士)
  2. Copy the MAMP gettext.so built for php 5.5.10 to Mavericks' local php extensions folder: 将为PHP 5.5.10构建的MAMP gettext.so复制到Mavericks的本地php扩展文件夹:

    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/

  3. Update Mavericks' /etc/php.ini file by adding this new line : 通过添加以下新行来更新Mavericks的/etc/php.ini文件:

    extension=/usr/lib/php/extensions/no-debug-non-zts-20100525/gettext.so

  4. Restart apache : 重新启动apache:

    sudo apachectl restart

After that you can use _() and gettext() functions. 之后,您可以使用_()gettext()函数。

Thanks to @MountainAsh for noticing that we can't remove MAMP after this procedure since gettext uses one of MAMP libraries. 感谢@MountainAsh注意到在此过程之后我们无法删除MAMP,因为gettext使用了一个MAMP库。

OS X so far does not include gettext (since my first attempt from 10.4). 到目前为止,OS X不包括gettext(自从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). 我遵循以下过程,并在10.6下工作(摘自Apple论坛讨论线程)。 It's still working now in 10.7. 它现在在10.7中仍在工作。 Note that this is to install gettext module, not php_gettext. 请注意,这是要安装gettext模块,而不是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. 记住尽管要交换链接以获取正确的PHP版本。 I think 10.7 comes with PHP 5.3.6. 我认为10.7自带PHP 5.3.6。 You'll need to search for it. 您需要搜索它。

Try this as root (or issue sudo -s before): 以根用户身份尝试(或在之前发出sudo -s):


mkdir -p /SourceCache mkdir -p / SourceCache

cd /SourceCache cd / SourceCache

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

tar xzf gettext-0.17.tar.gz 焦油xzf gettext-0.17.tar.gz

cd gettext-0.17 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 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“。/配置

make 使

make install 进行安装


cd /SourceCache cd / SourceCache

curl -O http://www.opensource.apple.com/source/apachemod_php/apache_modphp-53/php-5.3.0.tar.bz2 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 tar xjf php-5.3.0.tar.bz2

cd /SourceCache/php-5.3.0/ext/gettext cd /SourceCache/php-5.3.0/ext/gettext

phpize 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 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“。/配置

make 使

make install 进行安装


When done, edit/create /etc/php.ini and add: extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/gettext.so 完成后,编辑/创建/etc/php.ini并添加:extension = / usr / lib / php / extensions / no-debug-non-zts-20090626 / gettext.so

next issue: sudo apachectl graceful 下一个问题:sudo apachectl优美

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. Lion的PHP版本中似乎未包含gettext。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM