How to enable the Apache web server on OS X Mavericks
The Mac’s OS X operating system has tons of software actually tucked into in that makes it so great for people like me who loves Linux. For instance, besides having an FTP server pre-installed, the Mac actually has a full-blown web server pretty much configured to run on OS X.
Others might not be aware of it, especially now that enabling the web server software has now been removed from the OS X System Preferences app.
Activating and using the Apache Web server software on the OS X Mavericks is actually simple. All you need is the same launchctl program used in enabling the FTP server in my past post.
Launchctl is a program that enables owners of Mac computers to load/unload apps that generally run in the background.
To load the Apache Web server, open up the Terminal app. Type the command:
sudo -s launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
The Apache Web server in OS X Mavericks is needed if you want to, for example, install and run a local copy of WordPress.
Once you’ve loaded the Apache Web server software, you can check if it is now running in the background by opening the Safari web browser on the Mac and typing http://localhost/ in the address box. You should get a result similar to the image below.

If you got the same result, you now have a web server running on your Mac. If you want to learn more about Apache web server on your Mac, just read a local copy of the manual using the Safari browser. The manual is located at http://localhost/manual.
To unload the web server, use the same launchctl command by typing the following command in the Terminal app:
sudo -s launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Enjoy.
Gerry Ilagan
Gerry Ilagan is into mobile apps and WordPress development at @speeqs. He loves to write about electronics, the Internet of Things, mobile phones, and #crazyideas.
Comments
Where do the html files live ? (/var/www doesn’t exist!)
Hi Rob,
If you are referring to the default DocumentRoot of Apache on the Mac – it’s in /Library/WebServer/Documents
You can also put the files in a sites folder under your user.
/Users/yourname/Sites
Then you can access them by doing
localhost/~yourname/
I also managed to start the apache server using
sudo apachectl start
So, if I place my files into /Library/WebServer/Documents , and I’ve configured my router correctly, what is the IP they should use. I’d like to be able to show my partner in a remote location the page(s) i’ve developed for him.
If your Mac is directly connected to the Internet using a dedicated IP address, you need to know the public IP of your Mac on the Internet.
Another way to start apache web server on OS X Mavericks is using the following command:
sudo apachectl -k start
you can stop it using:
sudo apachectl -k stop
restart it using:
sudo apachectl -k restart
Gerry – This is really cool!
Alfred – Regarding putting html files in a sites folder under your user…When I try to access html from my Sites folder, I get this: Forbidden You don’t have permission to access /~TheOne on this server. Do I need to modify the permissions on this folder from the command line or is there a config I need to run to give the httpd access to my Sites folder? Thank you!
Paul
The default should pretty much work assuming TheOne is your Mac userid
Yes, that’s my Mac userid. I ended up having to create a username.conf in etc/apache2/users:
sudo nano TheOne.conf
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
sudo apachectl restart
And that did the trick!
I’m think the ability for the httpd to serve up content from my Sites folder got wacked back when I inplace upgraded from Mountain Lion to Mavericks. It’s working great now that I have my username.conf set up. Thanks again, Cheers!
So any reason as to why Apple would make it harder for us to use and take away the pref pane option? Its sad to see so many things that use to work great go backwords in terms of useability. lame.
Thanks for the Tip guys, it worked and did what i was looking for,
Madscientest.
Hey Gerry,
thanks for the tutorial.. I just want to ask you a certain question: I installed apache in my mac osx 10.9.5. and it’s possible to reach the localhost. But I don’t have the folder “WebServer” in my library… do you know where the problem may be at?
Cheers,
Paul