That's because Homebrew does not like using sudo, which is required if you want to start up Apache with the standard port 80 configuration. Note, that you had to specify the non-standard 8080 port number as part of the URL. You should see It Works! in your Safari browser. (The first time you run the brew services command, it will add the Homebrew-services tap.) Click on: to test that Apache is running.
Please install Homebrew and verify your installation if you haven't done so.ġ $ brew services start httpd 2 => Tapping homebrew/servicesģ Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-services'.Ĥ remote: Enumerating objects: 1188, done.ĥ remote: Counting objects: 100% (67/67 ), done.Ħ remote: Compressing objects: 100% (56/56 ), done.ħ remote: Total 1188 (delta 22 ), reused 18 (delta 10 ), pack-reused 1121 8 Receiving objects: 100% (1188/1188 ), 352.17 KiB | 3.67 MiB/s, done.ĩ Resolving deltas: 100% (498/498 ), done.ġ1 => Successfully started `httpd ` (label: ) Let's get started the first step is to install Apache, using Homebrew. It also uses Homebrew to install most of the software. It has inspired much of what I have done to setup my local development environment. By the way, you should check out " macOS 12.0 Monterey Apache Setup: Multiple PHP Versions." This is one of the best posts that I have seen about setting up a local website development environment.
But I wanted to learn how to use it with the event module, running PHP as a separate process. Running Apache with the pre-fork module is probably just fine while working with a local development environment. With the pre-fork module, PHP is built in (with mod_php) and is executed all the time even if PHP is not required to fulfill the request. This allows you to run PHP as a separate process, which is called on as needed. But in the Linux world, the current, default module is the event module. That's understandable since Homebrew installs Apache with the pre-fork module active. But most of them describe using Apache with the pre-fork Multi-Processing Module (MPM). There are multiple sites that describe how to install Apache and PHP on a Mac using Homebrew. MySQL is definitely not needed for a Hugo site. PHP is mostly not needed (although, my contact form does use PHP).
Apache plus php-fpm is still a great environment for testing a deployed Hugo site. I just recently moved my site from WordPress to Hugo. In this post, I also describe some tools that I wrote to manage Apache and PHP processes. I originally wrote this post for macOS Catalina, but I just updated it for macOS Big Sur. This post is just about Apache and PHP I wrote about MySQL in a separate post. After trying out both, I had a hard time deciding, but finally chose Homebrew for it's popularity and ease of use.
Apple does provide a web development environment, but their software may be (slightly) out-of-date or hard to configure. Please go to their site for installation instructions. To that end, I want to start by writing about my efforts to create a local website development environment on my Mac.Īs a foundation, I have chosen Homebrew to install most of the software that I am using. Now it's time to start creating content to see if I can create a viable site.
The extra subdirectory is in case you wish to use a framework in your projects which may keep some of its files outside of the web server root (Symfony is a good example of this). Within each of these subdirectories create another subdirectory called “web” this will be become the web root of each project.
It uses the existing “Sites” directory in your Mac OS home directory. The described configuration will provide a special Apache “sandbox” environment for your projects. Its configuration, however, is a little more complex, but nothing scary. Apache too comes with Mac OS, so again, no need to download and install it.