【发布时间】:2017-01-20 22:29:48
【问题描述】:
我在 Centos 6.8 VPS (PHP 5.6.29) 上运行 litespeed 5.1.11。
我在我的 php 代码中使用cUrl。当我以网页浏览方式运行代码时,一切正常,但是当我使用命令运行时,它给了我错误:Fatal error: Call to undefined function curl_init()
我该如何解决?
我用这个配置参数编译我的 php:
'./configure' '--prefix=/usr/local/lsws/lsphp5' '--disable-fileinfo' '--with-bz2' '--enable-zip' '--with-curl' '--with-mysql' '--with-mysql-sock' '--with-sqlite' '--with-tidy' '--with-xpm-dir' '--enable-pdo' '--with-pdo-sqlite' '--with-pdo-mysql' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-soap' '--with-gettext' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-mcrypt' '--with-mysqli' '--with-openssl' '--with-pic' '--with-png-dir' '--with-zlib' '--with-pcre-regex' '--with-gd' '--enable-shmop' '--enable-track-vars' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--enable-json' '--with-litespeed'
【问题讨论】:
-
听起来您正在使用两个单独的 php 引擎:一个用于您的“网页”,因此很可能作为某个 http 服务器中的模块,另一个用于“命令”,因此是 CLI 版本。这些通常有单独的配置。可能
cURL尚未为 CLI 版本加载/启用。 -
@arkascha 感谢您的评论。我使用这个命令:
/usr/local/bin/lsphp /my/code.php。如何找到CLI的配置文件? -
你从引擎给出的信息中获取路径:
/usr/local/bin/php -i | grep php.ini
标签: php curl centos fatal-error litespeed