1

I am not familiar at all with setting up an Apache/PHP web server, but I have to do this since my IT staff won't. I've looked at everything I can find online, and I just can't get cURL to load in PHP on windows apache. I installed Apache 2.2, it works. I installed PHP, and that works, which I know because my php script checks to ensure the cURL extension is loaded, and my php echo is returned to the browser, my code for that is shown below:

  if (!extension_loaded("curl")) {
     header('Status: 500', true, 500);
     echo 'cURL extension for PHP is not loaded! <br/> Add the following lines to your php.ini file: <br/> extension_dir = &quot;&lt;your-php-install-location&gt;/ext&quot; <br/> extension = php_curl.dll';
     return;
  }

I've done the following:

  • I've uncommented extension_dir="c:\php\ext\" (and tried numerous variations of that path, using forward and backward slashes, etc., as well as the ./ext/ approach).
  • I've ensured I have extension=php_curl.dll in my php.ini.
  • I've made sure that my apache user has read and execute permissions on the PHP folder and all subfolders/files
  • I've made sure I have C:\PHP in my path environment variable.
  • I've tried the suggestions here: Could not load php_curl, and here: PHP cURL is not loaded on modifying php.ini, as well as many others outside of StackOverflow.

Nothing has worked. I'm running on a Windows Server 2003 box. I get no error message in the Apache log. I'm stuck. Please help! Thanks.

Adding requested Apache log info:

[Tue Aug 14 14:38:22 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Aug 14 14:38:23 2012] [notice] Apache/2.2.22 (Win32) PHP/5.2.17 mod_ssl/2.2.22 OpenSSL/0.9.8t configured -- resuming normal operations
[Tue Aug 14 14:38:23 2012] [notice] Server built: Jan 28 2012 11:16:39
[Tue Aug 14 14:38:23 2012] [notice] Parent: Created child process 5616
[Tue Aug 14 14:38:24 2012] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Aug 14 14:38:25 2012] [notice] Child 5616: Child process is running
[Tue Aug 14 14:38:25 2012] [notice] Child 5616: Acquired the start mutex.
[Tue Aug 14 14:38:25 2012] [notice] Child 5616: Starting 64 worker threads.
[Tue Aug 14 14:38:25 2012] [notice] Child 5616: Starting thread to listen on port 8080.
Simon East
  • 55,742
  • 17
  • 139
  • 133
Shawn
  • 717
  • 11
  • 31
  • Check your php cli output by open cmd, then cd into directory and type "php.exe -v", in first line, you should see the error why its dont loaded. Then share results with us, so we can help you. – Burak Tamtürk Aug 14 '12 at 18:52
  • I received literally nothing in the cmd window running php.exe -v – Shawn Aug 14 '12 at 18:55
  • Does `function_exists('curl_init')` also return false? I'm wondering if it is `extension_loaded()` that is broken. Also, remember that the php.ini configuration used by the Apache mod_php SAPI is only loaded when Apache is started (not every request) so you need to restart the Apache service after you modify php.ini. If an extension is unloadable based on the php.ini settings, you will usually see errors logged in the Apache error log at startup with a helpful(ish) error message. – DaveRandom Aug 14 '12 at 18:56
  • @DaveRandom I'm not a PHP programmer; I just have to use a php proxy with my ESRI javascript website, so the extension_loaded() function is just the php api call. How do I test if function_exists('curl_init') returns false? – Shawn Aug 14 '12 at 18:59
  • @Shawn Literally just replace `extension_loaded("curl")` with `function_exists('curl_init')` in the above code. This will test whether a function associated with the curl extension exists, rather than looking for the extension itself - which I have never done and am not sure of the implications of, I have always just checked for the function I need rather than a whole extension. Make sure you restart the Apache service first though. – DaveRandom Aug 14 '12 at 19:02
  • @DaveRandom switching to function_exists('curl_init') returns false as well, after restarting Apache – Shawn Aug 14 '12 at 19:39
  • @Shawn have a look in your Apache error log. You should find an entry near the bottom (at the time when you restarted it) that says `Parent: Received restart signal -- Restarting the server.` - can you copy/paste everything after that entry to the end into the question? Should be 10-20 lines or so. How did you install Apache? Using the MSI package from Apache.org? – DaveRandom Aug 14 '12 at 19:44
  • @DaveRandom I did install Apache using the MSI from apache.org. I've updated my question with the requested Apache log data. – Shawn Aug 14 '12 at 19:58
  • 1
    post your page – Burak Tamtürk Aug 14 '12 at 19:59
  • @Shawn Interesting, not a single PHP error. Well in that case, either your php.ini is not indicating that curl should be loaded, or it is successfully loaded. As Burak rightly suggests, the next place to look is `phpinfo()`. Create a .php file that contains simply ` – DaveRandom Aug 14 '12 at 20:01
  • @BurakTAMTURK I'm not sure what that means. As I mentioned above, I only use the php file as a proxy for an ESRI javascript website, which uses the proxy.php file to handle large json parameters in a POST. I'm not a php programmer, so I'm not sure how to post what you requested. – Shawn Aug 14 '12 at 20:02
  • both of you, thanks. It seems php is looking in the wrong location for my php.ini file (it's looking in C:\Windows). How do I correct it to look in the correct location? I've set the PHPIniDir in my httpd.conf file, but apparently, that's being ignored. – Shawn Aug 14 '12 at 20:07
  • @Shawn In httpd.conf, probably towards the bottom, you should find two lines that look something like these (copied out of my httpd.conf): `LoadModule php5_module "C:/Program Files/PHP/php5apache2_4.dll"` and `PHPIniDir "C:/Program Files/PHP"` - the value of `PHPIniDir` should point to the directory where php.ini resides (not to the file itself) – DaveRandom Aug 14 '12 at 20:11
  • @DaveRandom I've copied my lines: LoadModule php5_module "c:/php/php5apache2_2.dll" PHPIniDir 'c:\php\' SetHandler application/x-httpd-php I had to write 'c:\php\' to get it to work. It wouldn't work with the forward slashes. – Shawn Aug 14 '12 at 20:14
  • OK that is really odd. I have never seen PHP ignore the value of `PHPIniDir`, ever. Try changing to forward slashes, but removing the trailing one (i.e. `C:/php`). I am assuming that php.ini is at `C:\php\php.ini`? – DaveRandom Aug 14 '12 at 20:20
  • Trying that, Apache fails to start. The only error in Apache log is the Session Cache not configured error. The only way I get Apache to start with PHP is using the back slashes, both of them. – Shawn Aug 14 '12 at 20:22
  • where did you install PHP from? (As in, which version of which package did you use, acquired from where?) – DaveRandom Aug 14 '12 at 20:25
  • @DaveRandom http://windows.php.net/download/ I downloaded version 5.2.17 VC6 Thread Safe, the installer package (MSI). – Shawn Aug 14 '12 at 20:27
  • In fact I can see where this is going to end up - let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/15358/discussion-between-daverandom-and-shawn) – DaveRandom Aug 14 '12 at 20:27

2 Answers2

5

If you install PHP, Apache in Windows operating system then following step can help you to run php_curl.dll smoothly.

  1. Find the location of php.ini (probably in C:\Windows) file and open it. Then uncomment (remove semi-colon(;) from ;extension=php_curl.dll) the line and save the file.
  2. Make sure that php_curl.dll is exist in your PHP extension directory (C:\php\ext). This extension path define in your php.ini file.
  3. Copy php4ts.dll (if you use PHP4) or php5ts.dll (if you use PHP5), libeay32.dll and ssleay32.dll to the C:\WINNT (Windows 2000) or C:\Windows (Windows 2003) directory. If php4ts.dll or php5ts.dll not found in your computer then search in google and download. Other two dll can found in the dlls directory of your PHP directory (may be in C:\php\ext)
  4. Restart Apache service.

Check again that cURL is enable. If not then restart your computer.
Now run script again and see your php_curl is now working smoothly.
If not then, copy above 3 dll file (describe in no.3) to your PHP root directory (may be C:\php) and also in Windows system32 directory (C:\Windows\system32).

Now run smoothly your php cURL script. Have a nice day.

Fred Wuerges
  • 1,965
  • 2
  • 21
  • 42
MMReza
  • 115
  • 1
  • 9
1

For Windows 7 64bit I had to copy php_curl.dll, libeay32.dll and ssleay32.dll into \Windows\SysWOW64.

Gavin
  • 7,544
  • 4
  • 52
  • 72