macOS Ventura 13.0 Setup: Homebrew + Apache + PHP + MariaDB

$ xcode-select --install

Homebrew Installation

Homebrew is an excellent package manager for macOS. Homebrew installs the stuff you need that Apple (or your Linux system) didn’t; let’s install it.

$ /bin/bash -c "$(curl -fsSL"
$ brew doctor

Apache Installation

macOS 13.0 Ventura comes with Apache 2.4 pre-installed. However, we don’t want Apple to control our web server so let’s stop it and prevent it from starting on boot.

$ sudo apachectl stop
$ sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
$ mkdir ~/Sites
$ brew install httpd
$ which apachectl
$ sudo brew services start httpd
$ tail -f /usr/local/var/log/httpd/error_log
$ brew services stop httpd
$ brew services start httpd
$ brew services restart httpd

PHP Installation

Install the latest PHP version.

$ brew install php

Apache PHP Setup

Now that we have PHP successfully installed, we still need to tell Apache to use it. Please edit the Apache httpd.conf file.

vi /usr/local/etc/httpd/httpd.conf
Listen 80
LoadModule socache_shmcb_module lib/httpd/modules/
LoadModule ssl_module lib/httpd/modules/
LoadModule vhost_alias_module lib/httpd/modules/
LoadModule userdir_module lib/httpd/modules/
LoadModule rewrite_module lib/httpd/modules/
LoadModule php_module /usr/local/opt/php/lib/httpd/modules/
User your_username
Group staff
ServerName localhost
DocumentRoot "/Users/your_username/Sites"
<Directory "/Users/your_username/Sites">
AllowOverride All
DirectoryIndex index.php index.html
<FilesMatch \.php$>
SetHandler application/x-httpd-php
Include /usr/local/etc/httpd/extra/httpd-userdir.conf
Include /usr/local/etc/httpd/extra/httpd-vhosts.conf
Include /usr/local/etc/httpd/extra/httpd-ssl.conf
$ brew services restart httpd
$ sudo apachectl configtest
PHP 8.1.9 (cli) (built: Aug  4 2022 15:12:55) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.9, Copyright (c) Zend Technologies
with Zend OPcache v8.1.9, Copyright (c), by Zend Technologies

MariaDB Installation

Install MariaDB using Homebrew.

$ brew install mariadb
$ brew services start mariadb
$ sudo /usr/local/bin/mysql_secure_installation
$ brew services restart mariadb
mysql -u root -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 7
Server version: 10.5.8-MariaDB Homebrew
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>

SSL/Virtual Hosts

The OpenSSL software library is a prerequisite to generate a certificate. Check if OpenSSL is available by running the following command in the local environment.

$ which openssl
$ brew install openssl
$ vi /usr/local/etc/httpd/extra/httpd-ssl.conf
ServerName<VirtualHost _default_:443>
$ cd /usr/local/etc/httpd
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
$ vi /usr/local/etc/httpd/extra/httpd-vhosts.conf<VirtualHost *:80>
DocumentRoot "/Users/your_username/Sites/yourprojectname"
ErrorLog "/usr/local/var/log/httpd/yourprojectname-error_log"
CustomLog "/usr/local/var/log/httpd/yourprojectname-access_log" common
<VirtualHost *:443>
DocumentRoot "/Users/your_username/Sites/yourprojectname"
SSLEngine on
SSLCertificateFile "/usr/local/etc/httpd/server.crt"
SSLCertificateKeyFile "/usr/local/etc/httpd/server.key"
$ brew services restart httpd


Copyright © 2022 Karl Hill.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Karl Hill

Karl Hill

Full Stack Engineer at NASA. Volunteer at Smithsonian’s The Renwick Gallery, and former drummer of #GovernmentIssue.