So my big, super amazing plans for GPORG that I’m been working at furiously behind the scenes (locally) at had to be put on hold.
Apple decided to release Monterey around Halloween. And I upgraded, after reading that there’s not much of a difference between it and Big Sur (because apparently, Monterey is based of Big Sur, code-wise).
The biggest difference I noticed is that Apple decided to remove the built-in PHP in Monterey. And to be fair, they did warn about this in Big Sur (labeling it as deprecated), but I completely forgot about this. (And honestly, having a third party PHP install means you could update it whenever you want. If you were using Mac OS’s PHP, you were at the mercy of Apple, whenever they realized PHP needs to be updated. Which was almost never.)
After doing some searching online, I decided to install PHP from Homebrew. I ran into some 403 (Forbidden) error issues, and one of the suggestions I found online was to upgrade Apache. Except you can’t upgrade the OS’s built-in Apache for some reason. And the solution to that was to install Apache from Homebrew instead.
I’ve been using Homebrew for about a few years now, so it wasn’t anything new to me. I already had PHP 8 installed through Homebrew. And I already knew what was involved in setting up Apache, because for some reason, whenever people upgraded between Mac OS versions (from Catalina to Big Sur, etc), the OS would completely reset your Apache settings. 🤨 I think in newer Mac OS versions, they’ve been backing up the config files, by changing the old files to something like
httpd.conf__BACKUP or something (which was better than completely removing them). But even so, I needed a tutorial to figure out how to set up this install of Apache.
I don’t remember which tutorial I followed, but I did everything by the letter, and whenever I visited
127.0.0.1, I got a “could not connect to server” error, and after tweaking the config file a little later, it turned into a 403 error. Like, wut.
Nothing I did fixed it. For a while, I thought it was being literal and there was a problem with folder permissions. And then after reading online, someone on StackOverflow suggested it was a PHP problem. Like maybe there was a problem with the PHP install. I couldn’t tell if that was it.
apachectl configtest said “Syntax OK”! And
brew doctor kept giving unrelated warnings about other brew packages (and no, fixing them did not fix the problem).
At one point, I tried ditching Apache for OpenLitespeed! Because my host uses the enterprise version, I’m already pretty familiar with Litespeed servers in general, right???
And installing it on Mac OS only gives you two options: you could either build it from source or install it through Docker. I tried it from source, because I didn’t want to go the Docker route. I barely understand Docker or its purpose, and while Docker!OLS comes with its own MySQL/MariaDB and PHP installs, I wanted to use whatever I already had installed from Homebrew, and not savvy enough to know how to get Docker!OLS to recognize the Homebrew installs, instead of the Docker versions (or if it was even possible).
Installing from source did not work. I think I got part of it running, but 127.0.0.1 still gave the “could not connect to server” error. And didn’t know how to fix that.
So I tried that Docker route, and while I got it running successfully, I didn’t know how to get it to recognize the folders I set up for each virtual host. And I looking through the OLS folder, I found a .env file that covered the entire server. One of the settings was for WordPress (URL specifically). So I need to have one WordPress install per server only?? Searching online for “multiple wordpress installs on openlitespeed” only brought up one page on this, and it didn’t talk about setting up multiple WordPresses on one OpenLitespeed server. 😐
Back to Apache
After this point, I decided that as a user, I’m pretty familiar with Litespeed. But as a server admin, I’m more familiar with Apache, and while I’m not an expert at debugging either, I’m better at debugging Apache.
So I was back to trying the usual stuff before I even though about OpenLitespeed. Googling “mac os apache 403 forbidden” (or any combination of) showed me all search results with purple links. 😬 (As in I already visited them before, probably several times).
I also tried uninstalling and reinstalling Apache, as suggested by someone on StackOverflow. It didn’t fix the problem, but before I uninstalled, I renamed the httpd folder to httpd_old, so I would get the default config files. However it’s set up, I wanted to see if changing as few settings as possible would fix things.
Eventually I found this article. And it looked like the other 50 articles I read about the topic, and it’s for the built-in Apache rather than the Homebrew version, but Ctrl/Cmd+F for the heading “Losing Localhost”.
So I have at the top of my httpd-vhosts.conf file:
/usr/local/var/www is the default DocumentRoot for Homebrew Apache, BTW. It already has a index.html with “It Works!” text, so 🤷♀️.
Another thing I did that wasn’t done after I reinstalled Apache: uncomment this line in httpd.conf:
LoadModule userdir_module lib/httpd/modules/mod_userdir.so
If you’re getting errors when restarting Apache (for me, it was about not finding the public_html folder), in your httpd-userdir.conf, look for this line:
If you try to access localhost/~username from your browser, Apache will try to look for a public_html folder in your user folder. You can either create a public_html folder in your user folder, or just change it to:
Since I already had ~/Sites set up from the old Apache install (pre-Monterey), I just changed it to Sites. But it can be wherever you’re keeping your local sites files on your computer.
sudo apachectl restart
…and Apache works again. 🥳
Now gotta fix this huge number of PHP errors on my local sites, after jumping from PHP 7 to 8. 🙈