Installing php-module using port on osx lion. It works from command line but not from apache

走远了吗. 提交于 2019-12-12 05:06:15

问题


I installed php5-intl on my osx lion.

It seems to work properly on command line mode because if I try to run the following script (1):

$fmt = datefmt_create( "en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL,'America/Los_Angeles',IntlDateFormatter::GREGORIAN  );
echo "First Formatted output is ".datefmt_format( $fmt , 0)."\n";

> php -m |grep intl
intl

> php test.php 
First Formatted output is Wednesday, December 31, 1969 4:00:00 PM Pacific Standard Time

But if I try to sun the same from my apache (after sudo apachectl restart) I get the following error:

> tail /private/var/log/apache2/error_log
PHP Fatal error:  Call to undefined function datefmt_create() in

P.S.:

I also added the following line to my php.ini

extension_dir = "/opt/local/lib/php/extensions/no-debug-non-zts-20090626"

ll /opt/local/lib/php/extensions/no-debug-non-zts-20090626
total 848
-rwxr-xr-x  1 root  261712  7 May 10:54 xdebug.so
-rwxr-xr-x  1 root  168912 31 May 19:53 intl.so

in php.ini is written: Loaded Configuration File /private/etc/php.ini which is the file I edited.


Other info on my configuration are the following:

/private/etc/apache2/httpd.conf
LoadModule php5_module libexec/apache2/libphp5.so
/usr/libexec/apache2/libphp5.so

/private/etc/php.ini
extension_dir = "/opt/local/lib/php/extensions/no-debug-non-zts-20090626"

回答1:


Create a web page, with these contents:

<?php
phpinfo();
echo datefmt_create("en_US" ,IntlDateFormatter::FULL,IntlDateFormatter::FULL);
?>

(Yes, I know that 2nd line gives an error, but in this case it is enough to tell us it works.)

View that web page, and search for "Internationalization support" or "intl". In my case I see:

Internationalization support    enabled
version                         1.0.3
ICU version                     4.2.1

Directive           Local Value Master Value
intl.default_locale no value    no value
intl.error_level    0           0

If you have no intl section present, then it can only be a php.ini issue (the more usual cause is not restarting apache, but you said you'd done that).

To confirm, edit the php.ini file again and at the very end introduce a change you can be sure will work. E.g. asp_tags = 1. Now reload your phpinfo() page and make sure you see the change there.

If you don't perhaps it is permissions; the user Apache runs as cannot read your php.ini file?



来源:https://stackoverflow.com/questions/10869537/installing-php-module-using-port-on-osx-lion-it-works-from-command-line-but-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!