Tips and tricks
![image](https://digitalzoomstudio.net/wp-content/uploads/2021/11/zoomit_create_a_local_dev_Apache_Mysql_PHP_Setup_on_mac_technic_0aa899d2-d700-44ad-bb4f-e4b32cc38272.jpg)
Tired of using MAMP ?
You should already have Apache installed on mac
Install Apache
you just need to start it:
sudo apachectl start
restart:
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 ...
you can check the config syntax with
httpd -t
check which services use port 80
sudo lsof -i -P | grep LISTEN
Access the config from /private/etc/apache2/httpd.conf ### /opt/homebrew/etc/httpd/httpd.conf ( homebrew ) ->
![](https://digitalzoomstudio.net/wp-content/uploads/2021/11/image-1.png)
start the server
/opt/homebrew/bin/httpd -k start
add Virtual Hosts . Create a local dev Apache Mysql PHP Setup on Mac OS X – add Virtual Hosts ‣ Digital Zoom Studio
add PHP . Create a local dev Apache Mysql PHP Setup on Mac OS X – add PHP ‣ Digital Zoom Studio
add mySQL . Create a local dev Apache Mysql PHP Setup on Mac OS X – add MySql ‣ Digital Zoom Studio
add XDebug . create a local dev Apache Mysql PHP Setup on Mac OS X – add XDebug ‣ Digital Zoom Studio
FAQ:
What is the difference between apachectl
and httpd
?
apachectl
is a wrapper over httpd
and just sets some environment variables and adds further functionality, like configtest
, more in detail here. httpd.worker
is like httpd
but with the worker module enabled.
Where to find logs for troubleshooting ?
you can find them in ErrorLog “/private/var/log/apache2/error_log”
I am getting could not bind to address error
(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
(48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
use this command
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
sudo apachectl -k restart
I get forbidden 403 when I access any page
apachectl
is a wrapper over httpd
and just sets some environment variables and adds further functionality, like configtest
, more in detail here. httpd.worker
is like httpd
but with the worker module enabled.