HomeGuides › Apache on Mac: Install, Configure PHP, Virtual Hosts and HTTPS

Apache on Mac: Install, Configure PHP, Virtual Hosts and HTTPS

For a maintainable Apache setup on a modern Mac, install Homebrew httpd instead of modifying Apple’s protected system files. Validate every change and use port 8080 locally or 80/443 only when deliberately serving a network.

Written and technically reviewed by Enfour, Inc. · Updated 19 August 2026

Short answer: run brew install httpd, start it with brew services start httpd, and open http://localhost:8080. Apple-silicon Homebrew uses /opt/homebrew; Intel normally uses /usr/local. Do not mix those files with the separate Apache binary macOS may provide.

1. Check for port and binary conflicts

which -a httpd
lsof -nP -iTCP:80 -iTCP:443 -iTCP:8080 -sTCP:LISTEN
brew --prefix

If another web server owns the port, stop it or choose another port. Identify what launches a process before stopping it.

2. Install and start Homebrew Apache

brew update
brew install httpd
brew services start httpd
curl -I http://localhost:8080

The main configuration is $(brew --prefix)/etc/httpd/httpd.conf. Logs are below $(brew --prefix)/var/log/httpd/. Before every reload:

$(brew --prefix)/bin/httpd -t
brew services restart httpd

3. Create a virtual host

Enable the vhost include, then add a host like this:

<VirtualHost *:8080>
    ServerName project.test
    DocumentRoot "/Users/you/Sites/project/public"
    <Directory "/Users/you/Sites/project/public">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

Add 127.0.0.1 project.test to /etc/hosts, or use local DNS for many names. Validate, restart, then open http://project.test:8080.

4. Connect PHP safely

brew install php
brew services start php

PHP-FPM keeps PHP lifecycle separate from Apache. Enable proxy, proxy_fcgi and setenvif, then route PHP files to the listener shown by your installed php-fpm.conf. Do not copy a socket from an old tutorial. Confirm with a temporary phpinfo() page, then delete it.

5. Add HTTPS

Redirect HTTP only after HTTPS works.

6. Troubleshoot methodically

SymptomCheck
Address already in uselsof the port; stop the correct service or change Listen
403 ForbiddenDirectory Require rule and execute permission on parent directories
Wrong siteServerName, port and vhost include order
PHP downloads as textFPM and proxy_fcgi mapping
Will not persistbrew services list and the Apache error log

Using FrontierStack

FrontierStack can install or adopt the Homebrew stack, create the document root and virtual host, select PHP, issue a certificate, update DNS and test the result. It manages Homebrew Apache; it does not silently rewrite Apple’s protected system configuration.

Primary references

Apache HTTP Server 2.4 · Homebrew · PHP-FPM · Let’s Encrypt

Run it all from one Mac app.

FrontierStack installs, monitors and secures the whole stack — locally and across your fleet — from a single native macOS app.

Download FrontierStack