简体   繁体   English

使用osx lion上的port安装php-module。 它可以从命令行运行,但不能从Apache运行

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

I installed php5-intl on my osx lion. 我在osx狮子上安装了php5-intl。

It seems to work properly on command line mode because if I try to run the following script (1): 它似乎在命令行模式下可以正常工作,因为如果我尝试运行以下脚本(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: 但是,如果我尝试从我的apache晒太阳(在sudo apachectl restart ),则会出现以下错误:

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

PS: PS:

I also added the following line to my php.ini 我还将以下行添加到了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. 在php.ini中编写: Loaded Configuration File /private/etc/php.ini ,这是我编辑的文件。


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"

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". 查看该网页,然后搜索“国际化支持”或“ 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). 如果您没有intl节,则可能只是php.ini问题(更常见的原因是没有重新启动apache,但您说过做到了)。

To confirm, edit the php.ini file again and at the very end introduce a change you can be sure will work. 要确认,请再次编辑php.ini文件,并在最后引入一个可以确定会生效的更改。 Eg asp_tags = 1 . 例如asp_tags = 1 Now reload your phpinfo() page and make sure you see the change there. 现在重新加载您的phpinfo()页面,并确保在那里看到更改。

If you don't perhaps it is permissions; 如果您不这样做,那是权限; the user Apache runs as cannot read your php.ini file? 用户Apache运行为无法读取您的php.ini文件?

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

相关问题 PHP mail()可以从命令行运行,但不能运行apache - PHP mail() works from command line but not apache php自定义C ++模块可以从命令行运行,而不是在Web服务器上运行 - php custom C++ module works from command line, not on webserver Mac OSX cmd从命令行运行,从php shell_exec()失败 - Mac OSX cmd works from command line, fails from php shell_exec() 在 OSX Mountain Lion 上为 PHP 安装 mcrypt 扩展 - Installing mcrypt extension for PHP on OSX Mountain Lion Apache和osx-lion上的两个版本的php - Apache and two versions of php on osx-lion linux - 当php安装为apache模块时,从命令行运行php脚本 - linux - running php script from command line when php is installed as apache module Apache PHP脚本无法连接到远程数据库/ ODBC / MySQL,但可以从命令行运行 - Apache PHP script can't connect to remote database/ODBC/MySQL but works from command line PHP命令行版本与apache不同 - PHP command line version is different from apache PDO连接是从命令行工作,但不是通过Apache? - PDO connection works from command line, but not through Apache? 使用macport在Mac OSX上使用工作程序MPM安装PHP FCGI和Apache - Installing PHP FCGI and Apache with worker mpm on Mac OSX using macport
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM