Tips and tricks

How to create a local dev Apache Mysql PHP Setup on mac

Tired of using MAMP ?

You should already have Apache installed on mac

you just need to start it:

sudo apachectl start
sudo apachectl restart
check config:
apachectl configtest

optional, if you are on Mac OS X Monterey you might need to uninstall the default Apache 2.4

sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew install httpd

to check if you have httpd running you can do $ps -ef |grep httpd

ps -ef |grep httpd
    0  4182     1   0 Mon01PM ??         0:01.16 /Applications/MAMP/Library/bin/httpd -f /Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf -k start
  501  4183  4182   0 Mon01PM ??         0:00.00 /Applications/MAMP/Library/bin/httpd -f /Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf -k start
  501  4189  4182   0 Mon01PM ??         0:00.02 /Applications/MAMP/Library/bin/httpd -f /Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf -k start
  501 24659 24648   0 12:33AM ??         0:00.00 /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
  501 24661 24648   0 12:33AM ??         0:00.01 /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND
  501 24662 24648   0 12:33AM ??         0:00.00 /opt/homebrew/opt/httpd/bin/httpd -D FOREGROUND

then you can do

$/opt/homebrew/opt/httpd/bin/httpd -V

Server version: Apache/2.4.48 (Unix)
Server built:   Jul  6 2021 20:11:03
Server's Module Magic Number: 20120211:105
Server loaded:  APR 1.7.0, APR-UTIL 1.6.1
Compiled using: APR 1.7.0, APR-UTIL 1.6.1

Access the config from /private/etc/apache2/httpd.conf/opt/homebrew/etc/httpd/httpd.conf ( homebrew ) ->

remember to change the User and Group to your user and group settings

start the server

/opt/homebrew/bin/httpd -k start

install php

brew unlink php && brew link --overwrite --force php@8.0

add this in your conf file

LoadModule rewrite_module lib/httpd/modules/
LoadModule php_module /opt/homebrew/opt/php/lib/httpd/modules/

        SetHandler application/x-httpd-php

make sure DirectoryIndex includes php

Add a virtual host

You can add unlimited virtual hosts just like MAMP adds them. You can just access /private/etc/apache2/httpd.conf and add:

<VirtualHost *:80>
	ServerName devsite
	DocumentRoot "/Users/123/Dropbox/hosts/devsite"
    Protocols h2 h2c http/1.1

    <IfModule xsendfile_module>
        XSendFilePath "/Users/123/Dropbox/hosts/devsite"

	ServerAlias devsite.*

    <Directory "/Users/123/Dropbox/hosts/devsite">
        Options Indexes FollowSymLinks Includes ExecCGI
		AllowOverride All
        <IfModule authz_host_module>
            Require all granted
        Allow from all

	<IfModule wsgi_module>
		WSGIDaemonProcess devsite processes=2 threads=15
		WSGIProcessGroup devsite
		WSGIScriptAlias /devsiteWsgiApp "/Users/123/Dropbox/hosts/devsite/"

Add mysql

Normally, you can just install the native mysqld service

you will find it in system preferences > mysql

you can use a tool like MySQL Workbench to see currently running mysql

check currently running mysql instances with $ps aux | grep mysql

you can change the MySQL socket from the php.ini ( write php --ini in Terminal to find )

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket =

Add xdebug

Normally, you can just install the native mysqld service

pecl install xdebug

normally this will be added to php.ini


using XDebug 3 – for phpstorm, you would also need to add


{"type":"main_options","images_arr":"'#ffffff'","enable_ajax":"off","soundcloud_apikey":"","bg_isparallax":"off","bg_slideshow_time":"0","bg_transition":"slidedown","site_url":"https:\/\/","theme_url":"https:\/\/\/wp-content\/themes\/qucreative\/","blur_ammount":"26","width_column":"50","width_section_bg":"","width_gap":"30","border_width":"0","border_color":"#ffffff","translate_cancel_comment":"Cancel reply","translate_leave_a_comment":"Leave a comment","translate_leave_a_comment_to":"Leave a comment to","is_customize_preview":"off","width_blur_margin":"30","gallery_w_thumbs_autoplay_videos":"off","enable_native_scrollbar":"on","content_enviroment_opacity":"30","menu_enviroment_opacity":"70"}