1

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
  • Please share more details, like the code involved that triggers the problem. What do you mean by "make a request in an Apache application"? – Nico Haase Oct 22 '21 at 15:44
  • I've added a code example to the initial post @NicoHaase. Specifically, when I host an application with Apache on my Macbook, and that application makes a curl request to a different domain like in the example, execution seems to hang or totally stop at ```curl_exec```. I first noticed when I was setting up a RESTful route, which makes a request to another domain, and the response was empty – Peter N Wood Oct 22 '21 at 16:32
  • It sounds like you're hosting an Apache HTTP server on your Mac, and it's the Apache server that's having problems. It also sounds like the "failing" curl_exec() in your PHP app are results of the Apache server issues. SUGGESTION: look [here](https://stackoverflow.com/questions/65652548/) – paulsm4 Oct 22 '21 at 16:38
  • this [link](https://stackoverflow.com/questions/68975769/brew-services-cant-start-service-get-bootstrap-failed-5-input-output-error) could help. It is related to mongodb, but there are suggestions that could explain your issue – Lety Oct 22 '21 at 16:45
  • @paulsm4 yeah, it seems like Apache is the issue. The question you linked seems to be a different problem though; I can start my Apache server with the apachectl just fine, it's only the brew services command that doesn't work. The solutions to that question didn't help with mine, unfortunately. – Peter N Wood Oct 22 '21 at 16:56
  • @Lety thanks, but no luck with that solution. Still getting the same homebrew LaunchAgent error – Peter N Wood Oct 22 '21 at 16:58
  • did you check if your current profile is the owner of your homebrew folder? – Lety Oct 22 '21 at 17:01
  • @Lety yes, I'm pretty sure. I checked ```/usr/local/Cellar``` and ```/usr/local/Homebrew``` I can start other homebrew services like mysql and php – Peter N Wood Oct 22 '21 at 17:06
  • Did you check if php module is loaded in apache configuration? Did you try a simple php file with phpinfo just to show if apache handles php file extension? Did you try to put a simple echo "

    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
  • @Lety yes, the php module is loaded and otherwise working correctly. I used my ```phpinfo()``` page to confirm which configurations and version of php Apache is using – Peter N Wood Oct 23 '21 at 14:09

0 Answers0