Here are the shortcuts and Terminal setup commands I used with MacOS.
Create a command to open Sublime from CLI.
sudo mkdir /usr/local/bin
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/subl
Edit the `~/.bash_profile` file, and include the following.
alias edithosts='subl /etc/hosts'
Update the `/etc/hosts` file to block unwanted sites. Use this example hosts file.
Install homebrew by following instructions on brew.sh
Use Homebrew Apache
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Install Homebrew Apache
brew install httpd
sudo brew services start httpd
Configure Apache Defaults
Before using apache, you need to edit the default config. You can find the default config location with the command `
Open the file listed for the
SERVER_CONFIG_FILE parameter, and make the following changes. (Usually, this will be your
# Comment out the default 8080 port if required.
# Listen 8080
# Open a new port
# Uncomment mod_rewrite module
LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so
# You may want to switch the default user/group on a local dev machine
# Change the default document root if required
# In the following <Directory> block, change AllowOverride to let .htaccess make changes
# Uncomment vhosts config
Update Virtual Hosts
VirtualHosts are typically located in
extras/httpd-vhosts.conf file relative to the above file. Following is the minimum code block you need to include in vhosts.conf file.
For other sites, you can duplicate the above block.
Update hosts file
Your hosts file is located at
/etc/hosts. For the test domains to work, you must add a new entry in a hosts file. (The local domain name used here, comes from
ServerName used above.
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
After saving all files, check if the Apache config is having any issues with the command
httpd -t. If not, restart Apache with
brew services restart httpd.
Now you can visit the tset domain in a browser and see the domain. If you get any errors, check the logs for any errors. The default error logs are in the paths below. You can check the latest errors with the
Installing PHP (via Homebrew)
-- Install PHP
brew install email@example.com
After an installation, you’ll see instructions similar to this.
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php8_module /firstname.lastname@example.org/lib/httpd/modules/libphp8.so
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
The php.ini and php-fpm.ini file can be found in:
email@example.com is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have firstname.lastname@example.org first in your PATH, run:
echo 'export PATH="/email@example.com/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/firstname.lastname@example.org/sbin:$PATH"' >> ~/.zshrc
For compilers to find email@example.com you may need to set:
To have launchd start firstname.lastname@example.org now and restart at login:
brew services start email@example.com
Or, if you don't want/need a background service you can just run:
So you need to make above changes.
httpd.conf and add
Consider installing these packages, as they’re commonly used.
brew install pkg-config imagemagick
pecl install imagick
-- if required, restart apache
brew services restart httpd
brew install youtube-dl
PATH as mentioned above, and start the service.
Change default settings
-- Set the git merge strategy
git config --global pull.ff only
Other Commonly Used Packages
Common Errors for Troubleshooting
Q: Apache log error message
client denied by server configuration
A: Check your
<Directory> paths. Probably it’s incorrect.
Q: MySql Connections fails with an error
mysql the server requested authentication method unknown to the client
A: This is probably because of an authentication plugin system change with MySQL 8+. For local development, you may change the root password to solve this. This must not be done on non-local machines.
First, login as the root from CLI.
mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'new_password';
On the example above, change
new_password to your new root password.