PHP命令行php.ini路径错误 [英] PHP Command Line php.ini path error

查看:111
本文介绍了PHP命令行php.ini路径错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在命令行上运行一些PHP页面,但遇到了几个问题与mysql和其他PHP扩展。

I am trying to run some PHP pages on the command line but am running into a few problems with mysql and other PHP extensions.

运行 php --ini 会生成以下输出:

Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File:         (none)
Scan for additional .ini files in: (none)
Additional .ini files parsed:      (none)

命令行它找不到我的php.ini文件。这是因为路径不正确。我的php.ini实际上位于 /etc/php.ini 中,如我的 phpinfo(); 文件中所述。 PHP在浏览器中运行良好。

When I run php on the command line it cannot find my php.ini file. This is because the path is incorrect. My php.ini is actually located in /etc/php.ini as stated in my phpinfo(); file. PHP runs fine in the browser.

如何更改命令行PHP的php.ini文件的路径?

How do I change the path of my php.ini file for command line PHP?

我正在运行Apache2(CentOS-5.5)和PHP 5.2.6。

I am running Apache2 (CentOS-5.5) and PHP 5.2.6.

推荐答案

c> -c 选项,您可以指定应该使用 php.ini 文件:

php -c /etc/php.ini your-php-script.php



作为参考,请参阅 php --help 的输出:

$ php --help
Usage: php [options] [-f] <file> [--] [args...]
       php [options] -r <code> [--] [args...]
       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
       php [options] -- [args...]
       php [options] -a

  -a               Run as interactive shell
  -c <path>|<file> Look for php.ini file in this directory
  -n               No php.ini file will be used
  -d foo[=bar]     Define INI entry foo with value 'bar'
  ...

这篇关于PHP命令行php.ini路径错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆