I've been having some small, weird issues with Apache since upgrading to Big Sur, but this one takes the cake. I can make cURL requests in the terminal, but when I try to make a request in an Apache application, all code execution stops and the response is empty. I'm totally baffled by this: there is nothing in the Apache logs, try-catch statements don't turn up any errors, and code executed before the call to curl_exec doesn't get executed.
Here's the simplest example that is failing for me. I host this script with Apache locally, visit it in the browser, and get a blank page:
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$request = curl_init();
curl_setopt($request, CURLOPT_URL, "https://www.google.com");
curl_setopt($request, CURLOPT_VERBOSE, TRUE);
curl_setopt($request, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($request, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($request);
echo $response;
At this point I don't even know how to diagnose the problem. The same issue happens with libraries like Guzzle running through a Drupal installation.
There is another related issue which might help explain things: I'm using Apache installed via Homebrew, but I can't use brew services to run apache, I have to run apachectl directly. Homebrew gives me this cryptic error when I run brew services start httpd
:
Failure while executing; `/bin/launchctl bootstrap gui/503 /Users/<my_username>/Library/LaunchAgents/homebrew.mxcl.httpd.plist` exited with 5.
Update: I erased my entire hard drive, reinstalled Big Sur, and set up my environment again. At first, curl_exec was working again, but now after installing RVM, Ruby, and setting up some ruby-based sites, I'm right back where I started. I thought Passenger might be an issue, but even with that module disabled, curl_exec still hangs, fails quietly, or whatever is happening. Also, Homebrew's httpd service would start normally with no errors, hosting the default page, until installed php and enabled the module; now I have to start apachectl manually.
Here's are all my system info I can think to include:
Setting | Version |
---|---|
OS | macOS Big Sur 11.6 |
System | MacBook Pro (13-inch, 2016, Four Thunderbolt 3 Ports) |
Processor | 3.3 GHz Dual-Core Intel Core i7 |
Memory | 16 GB 2133 MHz LPDDR3 |
Apache | 2.4.51 (Unix) |
OpenSSL | 1.1.1l |
Phusion_Passenger | 6.0.10 |
PHP | 7.3.31 |
I'm here
" just before curl to see if your file is executed? Here is a link that could [help](https://getgrav.org/blog/macos-bigsur-apache-multiple-php-versions) – Lety Oct 23 '21 at 11:20