I don’t know about you, but sometimes all I need is a quick refresh to my memory on how to do something, and I don’t need complete, in-depth instructions. Those times, I don’t want to scroll through long instructions, I just need some precise information, and I need it quick. This is why I wrote this quick post to be used as a reference for myself, and I thought that other people might find it useful too.
Note: if you would prefer in-depth instructions on this, I will refer you to the articles linked at the end of this post. They really cover everything there is to know about the topic and I wouldn’t be able to add any other useful information.
If you want to do some local web development on a Mac, you have two options: you either use a full stack like MAMP, or you enable Apache and PHP and install MySQL only. On Mac OS X, Apache and PHP are already installed, and it’s only a matter of enabling them.
Technically, Apache doesn’t even need to be enabled, it just needs to be started:
sudo apachectl start
To enable PHP you need to edit the
httpd.conf file (
/etc/apache2/). Specifically, you need to uncomment the following line:
LoadModule php5_module libexec/apache2/libphp5.so
And then run:
sudo apachectl restart
Now, this is all you need to do to be up and running: if you visit http://localhost you will see the Apache default page.
[Optional] Bring back the Sites folder
If you stopped at the previous step, you would use the default system-wide Apache folder:
/Library/WebServer/Documents/. If you prefer to have a user-level folder instead, there are a few extra steps to follow.
#LoadModule userdir_module libexec/apache2/mod_userdir.sofrom
http-userdir.conf(which you can find under
- Create a Sites folder inside your home folder
- Create a
- Copy and paste the following code inside the conf file
<Directory "/Users/<your_username>/Sites/"> Options FollowSymLinks Indexes MultiViews AllowOverride None Order allow,deny Allow from all Require local </Directory>
Restart Apache and you are good to go.
For more in-depth instructions on how to do this, have a look at the following two excellent articles:
- Installing Apache, PHP, and MySQL on Mac OS X Yosemite
- Get Apache, MySQL, PHP and phpMyAdmin working on OSX 10.10 Yosemite