Wamp + cUrl + CLi command line Solved
Posted by: yodude75 (---.zone2.bethere.co.uk)
Date: January 27, 2009 01:53PM

Hello all,

for sometime I've been having trouble and facing a 'funny' behavior of my scripts when running in CLi aka command line.

Enviroment:
Wamp Server 2.0
Windows Vista Home Premium
PHP 5.2.6
MySQL 5.1.30
Apache 2.2.10
cURL libcurl/7.16.0 OpenSSL/0.9.8g zlib/1.2.3
Bear in mind that I manually added php to the windows path.


The script below will work fine when ran via Browser but will fail when run via command line.


<?php
// create curl resource
$ch = curl_init();

// set url
curl_setopt($ch, CURLOPT_URL, "example.com"winking smiley;

//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// $output contains the output string
$output = curl_exec($ch);

// close curl resource to free up system resources
curl_close($ch);
?>

This is because, dunno why, when ran via Browser, Wamp Boss - Apache, reads the php.ini file that is within the folder C:\wamp\bin\apache\Apache2.2.x\bin\
and when running PHP via command line Apache reads the configuration file (php.ini) that is the folder c:\wamp\bin\php\php5.2.x\

Do you doubt?
On your browser go to http: / / localhost/?phpinfo=1 [remove the spaces]
take a look at the entry "Loaded Configuration File" should say "C:\wamp\bin\apache\Apache2.2.10\bin\php.ini"
Now open a DOS prompt window (Start > Run > (type) cmd)
on this DOS box type
c:\wamp\bin\php\php5.2.6\php.exe -r phpinfo(); |more
press CTRL+C to break.

On the result of the command you will see "Loaded Configuration File => C:\wamp\bin\php\php5.2.6\php.ini"

remember that via browser "Loaded Configuration File" was in ../Apache2.x.x/bin/

totally different locations.

So the solution is pretty simple, rename C:\wamp\bin\php\php5.2.6\php.ini to C:\wamp\bin\php\php5.2.6\php.ini.old
then COPY (not cut ) the php.ini from C:\wamp\bin\apache\Apache2.2.10\bin\ and paste in C:\wamp\bin\php\php5.2.6\

Hope this was clear and solve problems of more people !!!

all the best for all
=)

Options: ReplyQuote
Re: Wamp + cUrl + CLi command line Solved
Posted by: dmb42 (---.mc.at.cox.net)
Date: August 01, 2010 04:01PM

Thanks, this issue was driving me crazy. Tried copying dlls to system32, adding path varibles, etc. Nothing was working then I came across your post and it solved my problem in seconds. Thanks for sharing!

Question, is this a bug in the wamp installation? Should apache and php be looking at the same php.ini or should they at least be kept in sync?

Options: ReplyQuote
Re: Wamp + cUrl + CLi command line Solved
Posted by: stevenmartin99 (109.79.99.---)
Date: August 01, 2010 04:13PM

this is known , Not a bug..... its written in the FAQ. smiling smiley

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 08/01/2010 04:14PM by stevenmartin99.

Options: ReplyQuote
Re: Wamp + cUrl + CLi command line Solved
Posted by: reza (---.alwayson.net.bd)
Date: October 04, 2012 07:59AM

Thanks yodude75, you saved my whole day.

Options: ReplyQuote
Re: Wamp + cUrl + CLi command line Solved
Posted by: stevenmartin99 (Moderator)
Date: October 04, 2012 08:08AM

It's not a bug!

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Wamp + cUrl + CLi command line Solved
Posted by: RiggsFolly (---.as13285.net)
Date: October 04, 2012 10:18AM

In fact its NOT A BUG ------ ITS A USEFUL INTELIGENT FEATURE.

You should not copy your apache version of php.ini into your CLI version of php.ini.

Edit them independantly and include the features you need independantly for each environment!!!!

REMEMBER these are 2 totally seperate environments.

Options: ReplyQuote


Sorry, only registered users may post in this forum.