Unable to load curl for PHP 5, apache & XP

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Unable to load curl for PHP 5, apache & XP

Post by raghavan20 »

I get the following error when i ran a CURL based script

Code: Select all

Fatal error: Call to undefined function curl_init() in C:\Program Files\Apache Group\Apache2\htdocs\TestIT.php on line 8
i have done the following as of now

1. in php.ini in c:/windows

Code: Select all

;extension=php_mbstring.dll
;extension=php_bz2.dll
extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll

2. in windows path

Code: Select all

C:\Documents and Settings\Master Wenly>path
PATH=c:\windows;c:\windows\system32;c:\windows\System32\Wbem;c:\program files\ph
p\libeay32.dll;c:\program files\php\ssleay32.dll;c:\program files\php

3. i have also copied ssleay32.dll and libeay32.dll to c:/windows and c:/windows/system32

I still cannot load cURL. any ideas? Thanks.

EDIT:
I also have another doubt.
when i changed php.ini extension setting from

Code: Select all

extension_dir = ".\ext"
to absolute path,

Code: Select all

extension_dir = "c:\program files\php\ext"
the apache started giving up error

Code: Select all

The application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Restarted Apache? Verified the php.ini you edited is the one loading?

get_cfg_var() or phpinfo() can provide the php.ini path information.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

feyd wrote:Restarted Apache? Verified the php.ini you edited is the one loading?

get_cfg_var() or phpinfo() can provide the php.ini path information.
thanks feyd for your reply

from phpinfo()

Code: Select all

Configuration File (php.ini) Path  C:\WINDOWS\php.ini
apache has been restarted many times already.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please run

Code: Select all

<?php
$inifile = get_cfg_var('cfg_file_path');

if ( false==$inifile ) {
	die('no config file');
}

if ( false==($cfg=file($inifile)) ) {
	die('canot read config file');
}

$extdir = get_cfg_var('extension_dir');
$extdir = str_replace('\\', '/', $extdir);
if( '/'!==substr($extdir,1, -1)) {
	$extdir .= '/';
}

echo 'ini: ', $inifile, "<br />\n";
echo 'ext: ', $extdir, "<br />\n";

$pattern = '!^\s*extension\s*=\s*(\S+)!';
foreach($cfg as $p) {
	if ( preg_match($pattern, $p, $m) ) {
		echo $m[1], ' # ', $extdir.$m[1], ' # ', file_exists($extdir.$m[1]) ? 'ok':'error', "<br />\n";
	}
}
?>
and post the output.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

Code: Select all

ini: C:\WINDOWS\php.ini
ext: ./ext/
php_curl.dll # ./ext/php_curl.dll # error
php_mysql.dll # ./ext/php_mysql.dll # error
php_mysqli.dll # ./ext/php_mysqli.dll # error
php_xsl.dll # ./ext/php_xsl.dll # error
i could say these are the ones i enabled in php.ini file.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

fyi

php installation directory: c:/program files/php
apache installation directory: c:/program files/Apache Group


Thanks.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

open C:\WINDOWS\php.ini in a text editor
find extension_dir
set extension_dir = "c:/program files/php/ext/"
save file, restart apache
try again.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

volka wrote:open C:\WINDOWS\php.ini in a text editor
find extension_dir
set extension_dir = "c:/program files/php/ext/"
save file, restart apache
try again.
Great, Curl is working but I have a few problems as below.

i tried that but it comes up with this error

Code: Select all

The application has failed to start because LIBMYSQL.dll was not found. Re-installing the application may fix this problem
but still the apache ran.


i ran your script and this is the output

Code: Select all

ini: C:\WINDOWS\php.ini
ext: c:/program files/php/ext//
php_curl.dll # c:/program files/php/ext//php_curl.dll # ok
php_mysql.dll # c:/program files/php/ext//php_mysql.dll # ok
php_mysqli.dll # c:/program files/php/ext//php_mysqli.dll # ok
php_xsl.dll # c:/program files/php/ext//php_xsl.dll # ok
Thanks for your help.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

i copied this file, libmysql.dll to apache installation directory and restarted apache and everything is working without error.
i dont really know why apache cannot recognize those files from php installation directory.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Has to do with the way windows searches for dlls, see viewtopic.php?t=62010
You now have
http://msdn2.microsoft.com/en-US/library/ms682586.aspx wrote:1. The directory from which the application loaded.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

on monday morning, i wanted to make a change to a cURL application and comes with this error

Code: Select all

Fatal error: Call to undefined function curl_init() in C:\Program Files\Apache Group\Apache2\htdocs\TestIT.php on line 8
and when i checked from where php.ini is loaded, it is from

Code: Select all

Configuration File (php.ini) Path  C:\Program Files\PHP\php.ini
can you guys tell me where should I change setting so that it picks up php.ini from c:/windows ? I checked httpd.conf but I cannot find any line in there specifying the location of php.ini file

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If you're running Apache2, you can set the PHPIniDir directive in httpd.conf. Alternately, you could delete the php.ini it is finding in Program Files.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

it works now.

i am running apache 2.2 even though i used apache 2 dll for php to run the PHP.
i could not find any phpIniDir setting inside httpd.conf in apache-install-dir/conf/

i then deleted the file in c:/program files/php which is the php-install-dir then it picked up file from c:/windows.

why is this happening feyd?

thanks for your reply.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

PHP and Windows will use the php.ini found first. Windows will search in the current directory of the executable first before looking in the PATH.
User avatar
raghavan20
DevNet Resident
Posts: 1451
Joined: Sat Jun 11, 2005 6:57 am
Location: London, UK
Contact:

Post by raghavan20 »

oh good. that is logical even though that is not our expected behaviour.
Post Reply