0
votes

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

2
Sounds like you are using two separate php engines: one for your "web page", so most likely as a module inside some http server and one for the "command", so a CLI version. There are usually separate configurations for those. Probably cURL has not been loaded / enabled for the CLI version. - arkascha
@arkascha Thanks for comment. I use this command: /usr/local/bin/lsphp /my/code.php. How can I find CLI configuration file? - Saeid Tahmuresi
You get the path from the information given by the engine: /usr/local/bin/php -i | grep php.ini - arkascha

2 Answers

1
votes

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

0
votes

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.