Page 1 of 1

curl_init() fails - Tried everything but curl() doesn't load

Posted: Mon Dec 27, 2010 10:36 am
by torontob
Hi Everyone,

I have a stock install of CentOS 5.4 and php is install on it. But I continuously get this error when trying curl:

Fatal error: Call to undefined function curl_init() in /tmp/curlTest.php on line 3

Contents of file curlTest.php:

Code: Select all

<?php 
// create a new cURL resource 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/";); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

// grab URL and pass it to the browser 
curl_exec($ch); 

// close cURL resource, and free up system resources 
curl_close($ch); 
?> 


Following are all my packages. I also tried reinstall of all using Yum but above error still remains:
[root@localhost html]# rpm -qa | grep php
php-common-5.1.6-27.el5_5.3
php-odbc-5.1.6-27.el5_5.3
php-xmlrpc-5.1.6-27.el5_5.3
php-devel-5.1.6-27.el5_5.3
php-cli-5.1.6-27.el5_5.3
php-pdo-5.1.6-27.el5_5.3
php-mcrypt-5.1.6-15.el5.centos.1
php-gd-5.1.6-27.el5_5.3
php-imap-5.1.6-27.el5_5.3
php-ldap-5.1.6-27.el5_5.3
php-pear-1.4.9-6.el5
php-5.1.6-27.el5_5.3
php-mbstring-5.1.6-27.el5_5.3
php-xml-5.1.6-27.el5_5.3

[root@localhost]# locate curl.so
/usr/lib/libcurl.so
/usr/lib/libcurl.so.3
/usr/lib/libcurl.so.3.0.0


[root@localhost]# ls /etc/php.d/
dbase.ini gd.ini ldap.ini mbstring.ini mysqli.ini odbc.ini pdo_mysql.ini pdo_sqlite.ini xmlrpc.ini xsl.ini
dom.ini imap.ini libcurl.so mcrypt.ini mysql.ini pdo.ini pdo_odbc.ini xmlreader.ini xmlwriter.ini


Here is the portion of the /etc/php.ini that I made the change:

Code: Select all

; For example: 
; 
; extension=msql.so 
; 
; Note that it should be the name of the module only; no directory information 
; needs to go here. Specify the location of the extension with the 
; extension_dir directive above. 
;;;; 
; Note: packaged extension modules are now loaded via the .ini files 
; found in the directory /etc/php.d; these are loaded by default. 
;;;; 
[php-curl] 
extension=libcurl.so 
I also tried:
extension=curl.so and it was not working as well.

I did "service httpd restar" multiple times and the error stay.

Thanks

Re: curl_init() fails - Tried everything but curl() doesn't

Posted: Mon Dec 27, 2010 12:17 pm
by requinix
If

Code: Select all

php -m
does not list cURL then it is not installed.

You have a package manager. Make it install the module. Don't do it yourself.

Re: curl_init() fails - Tried everything but curl() doesn't

Posted: Mon Dec 27, 2010 4:14 pm
by torontob
Thanks for the tip. It seems curl is not found but I see it installed. Please note below:

[root@localhost ~]# php -m

Code: Select all

Core
ctype
date
dom
ereg
fileinfo
filter
hash
iconv
json
libxml
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
SQLite
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter

[Zend Modules]
[/b]
[quote][root@localhost ~]# yum install curl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.telus.net
 * base: centos.mirror.nac.net
 * extras: mirror.anl.gov
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: mirror.cs.vt.edu
Setting up Install Process
Package curl-7.15.5-9.el5.i386 already installed and latest version
Nothing to do
[root@localhost ~]# yum install php-curl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.telus.net
 * base: centos.mirror.nac.net
 * extras: mirror.anl.gov
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: centos.aol.com
Setting up Install Process
Package php-common-5.1.6-27.el5_5.3.i386 already installed and latest version
Nothing to do[/quote]


I am running CentOS 5.5, so I don't know what else to run to get curl installed. But as per above I think Curl is installed. Isn't it? and why does php-common show up for installing curl?

Linux localhost.localdomain 2.6.18-194.26.1.el5PAE #1 SMP Tue Nov 9 13:34:42 EST 2010 i686 i686 i386 GNU/Linux

Thanks