doujiurong7210
2017-01-18 07:54
浏览 70
已采纳

litespeed - 致命错误:调用未定义的函数curl_init()

I running litespeed 5.1.11 on my Centos 6.8 VPS (PHP 5.6.29). I use cUrl in my php code. When I run my code with browsing as a web page every thing work fine, but when I run with command it gave me error:
Fatal error: Call to undefined function curl_init()
How can I fix it?

I Compile my php with this configure parameters:

'./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'

And cUrl section in phpinfo: phpinfo

图片转代码服务由CSDN问答提供 功能建议

我在 Centos 6.8上运行 litespeed 5.1.11 VPS(PHP 5.6.29)。 我在我的php代码中使用 cUrl 。 当我通过浏览网页运行我的代码时,每件事都运行正常,但是当我运行命令时它给了我错误:
致命错误:调用未定义函数curl_init() < br> 我该如何解决?

我用这个配置参数编译我的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- 魔术引号' ' - 启用-m bstring'' - with-iconv'' - enable-json'' - with-litespeed'

phpinfo中的cUrl部分:

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongyun234854 2017-01-19 16:07
    已采纳

    I solve my problem. I should just add this to Configure Parameters.

    '--exec-prefix=/usr' '--with-exec-dir=/usr/bin'

    Now I compile my php with this Configure Parameters:

    --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-exif --enable-ucd-snmp-hack --enable-xml --enable-json --libdir=/usr/lib64 --with-libdir=lib64 --exec-prefix=/usr --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-pcre-regex=/usr --with-gmp --with-layout=GNU --with-system-tzdata --with-apxs2=/usr/sbin/apxs --with-libxml-dir=/usr

    Now, I use /usr/bin/lsphp /my/code.php or php /my/code.php to run my code with command line.

    已采纳该答案
    打赏 评论
  • dongpou7275 2017-01-18 19:50

    After you compiled your PHP, you should get both lsphp and php binaries. If the prefix was /usr/local/lsws/lsphp5, Your compiled binaries should be in /usr/local/lsws/lsphp5/bin/, then for CLI, try php with your code.

    /usr/local/lsws/lsphp5/bin/php /my/code.php

    /usr/local/bin/lsphp or /usr/local/bin/php does not look like the one your compiled since they are not under prefix folder.

    Also, I don't know if you have any particular reason to compile PHP by yourself since most of the people would just use RPM packages either from LiteSpeed repository or Remi repository. Installation is much easier and it should get your right.

    https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:php:rpm

    打赏 评论

相关推荐 更多相似问题