OS X Mavericks and Apache

Web Development with Apache, PHP and ColdFusion on OS X Mavericks

Getting your web development environment set up on OS X Mavericks is very similar to setting it up on Mountain Lion, or other previous releases of Apple’s OS. If you already had your environment set up previously, and upgraded to OS X 10.9 (Mavericks), then you will notice that your httpd.conf configuration has been replaced. But, don’t fret. You can find your old configuration located at: /private/etc/apache2/httpd.conf.pre-update. Let’s go ahead and get started!


OS X comes with Apache already installed, so it’s as simple as starting up the server. Previously, you could start this using the System Preferences > Sharing panel, but it has been removed from there in 10.9. To start the server, first start up Terminal app via Utilities > Terminal, and then enter the command below. You can read the full documentation on the apachectl command.

Start Apache:

$ sudo apachectl start

Stop Apache:

$ sudo apachectl stop

Restart Apache:

$ sudo apachectl restart

Another useful command is to verify your httpd.conf configuration via the -t test switch.

$ sudo apachectl -t

Once you have started the Apache server, open your favorite browser to: http://localhost and you should see the screen below.


Customizing Apache

After getting the initial localhost working, you may want to make some changes. I suggest:

  • Create a /www directory
  • Put all your web sites in this directory
  • Add virtual hosts for each web site you are working on
  • Add an entry to your hosts file to point a local domain name to your local Apache server

First, let’s create the /www directory:

$ cd /
$ mkdir www

Second, let’s create our local web site local.example.com (replace with your own web site):

$ mkdir local.example.com

Open up the httpd.conf file located in /private/etc/acpache2. I am using TextMate, so I will use the “mate” command.

$ mate /private/etc/apache2/httpd.conf

Make the following changes to the httdp.conf file.

  • On line 170, change the DocumentRoot:
    DocumentRoot “/www”
  • On line 197, change the Directory location:
    <Directory “/www”>
  • On line 217 (within the Directory location we just updated), change the AllowOverride to “All” so that we can use .htaccess to modify any settings for our local sites:
    AllowOverride All
  • On line 429, uncomment the Include of the httpd-vhosts.conf file:
    Include /private/etc/apache2/extra/httpd-vhosts.conf

We will also add a new virtual hosts to the httpd-vhosts.conf file (located at /private/etc/apache2/extra/httpd-vhosts.conf). If you open this file, you will notice that there is already some dummy-host.example.com entries. You can just modify these as necessary for your web site. My virtual host entry looks like this:

<VirtualHost *:80>
	DocumentRoot "/www/local.example.com"
	ServerName local.example.com
	ErrorLog "/private/var/log/apache2/local.example.com-error_log"
	CustomLog "/private/var/log/apache2/local.example.com-access_log" common

The last thing we need to do is modify our hosts file so that when we type in “local.example.com” into our browser we use the local Apache web server, rather than trying to go out find this fictitious domain on the Internet. So, let’s open up the hosts file for editing in TextMate.

$ mate /private/etc/hosts

Add a new entry for your web site:   local.example.com


PHP is already installed for you in OS X 10.9 Mavericks. It’s as simple as modifying the httpd.conf file again.

  • On line 118, uncomment the LoadModule for PHP:
    LoadModule php5_module libexec/apache2/libphp5.so
  • On line 231, add index.php as a default document if a directory is requested:
    DirectoryIndex index.html index.php

Lastly, we need to tell Apache to use the PHP handler when requesting files that end in .php or .phps. Append the following code to the end of your httpd.conf file.

#PHP Settings
<IfModule php5_module>
	AddType application/x-httpd-php .php
	AddType application/x-httpd-php-source .phps

Don’t forget to restart the Apache server after making any changes to your httpd.conf file.


ColdFusion is not shipped with OS X 10.9 Mavericks (bummer), but it’s pretty simple to install. During the installation you can provide the web server connection utility with the necessary information about your Apache server, which will automatically add the necessary configuration parameters to your httpd.conf file for you. If you have already installed ColdFusion previously, you can copy the code out of the httpd.conf.pre-update file, or use the web server connection utility again.

ColdFusion9 web server configuration utility
ColdFusion9 web server configuration utility



This is an update to the original blog article, as I ran into some issues with my MySQL connection after posting this article.

Upgrading also replaces your php.ini file (located at /private/etc/php.ini), with a new php.ini.default (located at /private/etc/php.ini.default). To get MySQL working (along with error reporting), I needed to update some settings:

  • One line 478, display errors (this is only for development, not a production environment):
    display_errors = On
  • One line 986, add the location to the MySQL socket file:

If you are running into the same issue, you probably need to enable the pdo_mysql extension by uncommenting the line:extension=php_pdo_mysql.dll.

That’s it. Happy web developing!

65 thoughts on “OS X Mavericks and Apache

  • October 23, 2013 at 10:38 am

    I had trouble with my local sites working after updating to Mavericks too and I noticed that what I had to do was go into /private/etc/apache2 and delete httpd.conf and then rename httpd.conf.pre-update back to httpd.conf and also had to go into /private/etc and delete php.ini and then rename php.ini.5.2-previous back to php.ini

  • October 23, 2013 at 11:59 am

    Thanks Pete! Simply restoring my original files worked for me.

  • October 23, 2013 at 12:03 pm

    Thank you, that helped me !!
    I meet a new issue, my database connection seems to be impossible.
    Error message:
    Link to database cannot be established: SQLSTATE[HY000] [2002] No such file or directory

    Any idea how to solve it ? It worked well before upgrading to Mavericks.

    Thanks !!

  • October 23, 2013 at 2:35 pm

    Thanks a million for your article, was exactly what I was looking for! You have a typo in the command line under ‘Stop Apache’: it says ‘$ sudo apachectl start’ but you probably mean ‘$ sudo apachectl stop’.

  • October 23, 2013 at 3:41 pm

    Thanks! This really helped! I ran into one more issue after uncommenting the PHP module, and vhost line. The timezone needed to be set again.

  • October 23, 2013 at 3:59 pm

    @Pete, yes, you can do that also. I did notice that there were some other changes in the httpd.conf and php.ini.default files that ship with OS X Mavericks. I wanted to preserve those new changes (just in case), so I manually copied over my necessary changes. However, you’re method of copying them over will also work.

  • October 23, 2013 at 4:02 pm

    @Lo, I just made an update to the article. I also ran into an issue with my MySQL database connection. I had to also update the pdo_mysql.default_socket setting in php.ini to point to the MySQL socket file located at /tmp/mysql.sock. I hope that helps and gets you back up and running!

  • October 23, 2013 at 4:30 pm


  • October 23, 2013 at 5:25 pm

    Unfortunately CF 10 is not working on Mavericks .. I am at CFSummit and hopefully I can find someone who can help.

  • October 23, 2013 at 6:54 pm

    Thanks for the heads up! This helped me out. Just for those coming across this page, I had done a homebrew install of PHP and I wound up looking into a file named httpd.conf~previous to get the changes I need.

  • October 23, 2013 at 10:37 pm

    I am ripping my hair out. I cannot get things to work properly since I installed Mavericks. On Mountain Lion I had it set up that I could type local.mysite.com in my browser and be served files from /Users/Me/Sites/mysite.

    When I change the Document Root to /Users/Me/Sites, the browser won’t connect to the server. When I change the Document Root to /Library/WebServer/Documents, and still have the virtual hosts pointed to their respective folders in Sites, I get Access Forbidden. Even if I open up the permissions wide.

    Incredibly frustrating.

  • October 24, 2013 at 2:05 am

    Thank you!!! Just upgraded to Mavericks and was figuring out how to get my environment working again. Such a time saver!

  • October 24, 2013 at 3:38 am


    Thank you, that helped a lot !!
    Thanks for this article !!!

  • Pingback: php | Annotary

  • October 25, 2013 at 4:42 am

    Thanks a lot. This is a VERY useful post. Save me a lot of frustration. Do you know why the move from /etc to / private/etc?

  • October 26, 2013 at 3:58 am

    @Gerard, I’m glad that this post was useful for you. It didn’t really move from /etc to /private/etc. You can still use /etc/apache2, as /etc is just a symlink to /private/etc. If you open terminal:

    $ cd /
    $ ls -al

    You will see that /etc is a symlink to /private/etc:

    lrwxr-xr-x@ 1 root wheel 11 Oct 23 12:17 etc -> private/etc

  • October 28, 2013 at 5:06 pm

    Thanks Peter! Worked for me! Quick and easy fix

  • October 28, 2013 at 6:41 pm

    During the mavericks upgrade several configuration files were saved as previous and replaced by the install including:


  • October 29, 2013 at 1:05 pm

    Hey, guys.

    Nice hint! However, I can’t put PDO to work. For some unknown reason, my Mavericks just don’t have the pdo_mysql extension installed. I’m stuck since I just can’t put it to work. I have tried to install it using pecl, but compilation fails since it can’t find the mysql_config, even knowning that this fellow is installed and accessible through PATH variables. Anyone?

  • October 29, 2013 at 2:07 pm

    Thanks @Pete! Saved my life

  • October 30, 2013 at 1:02 pm

    If you were using a version of Apache that was not the Mac OS built-in version (such as a version installed using MacPorts,) you need to disable the built-in Apache (the one that came with Mavericks) using this command:

    sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

    Then you can simply start up your existing/previous copy of Apache using the appropriate ‘apachectl start’ command.

  • November 1, 2013 at 5:02 am

    I’m running into same issue #2002 Error. Made all the changes suggested in the article, and still having the same problem.

    Did anyone solved this problem in a different way?

  • November 1, 2013 at 1:11 pm

    Solved the #2002 MySQL Error with:

    mysql.default_socket = /tmp/mysql.sock
    mysqli.default_socket = /tmp/mysql.sock

  • November 1, 2013 at 1:57 pm

    Thank you! I also had to reset my timezone in the [Date] section.

  • Pingback: Apache2 Problem on Update to Mavericks | tediscript.wordpress.com

  • November 3, 2013 at 2:53 am

    Apache works, but it doesn’t start on systeem boot.. I want it to start automatically but I can’t get it to work. Anyone?

  • November 3, 2013 at 11:23 am

    Does anyone encounter error in iTunes store after installing mySQL on Maverick? I got an iTunes error 12002. Can’t connect to “Music/Movies/App Store” with the same error, but no issues in connecting to “Books/Podcast/iTunes U”. I’m using Macbook Air 13″ mid-2011, and installed mySQL from this site: http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg and downloaded “Mac OS X 10.6 (x86, 64-bit), DMG Archive”. iTunes works fine on my other user accounts in which mySQL was not installed. Any feedback/ideas are welcome.

  • November 3, 2013 at 8:05 pm

    Thanks very much, this helped me get everything up and running again after upgrading in-place from 10.7 Lion to 10.9 Mavericks. My vhosts weren’t working anymore, and now they are. Thanks again!

  • November 9, 2013 at 4:40 pm

    Thanks a bucket! This article saved another live. Was just wondering why I couldn’t use a folder created within my user profile folder. Always got a 403 error. I tried to change the permissions on the folder without success…

  • November 14, 2013 at 1:46 pm

    Thanks a bunch for this ..worked well for me. I used Pete’s comment, except I saved the maverick files to another name just in case I needed to look at it later.

  • November 15, 2013 at 1:58 am

    For the beginners, you should mention that the files in /etc/apache2 are owned by root, so modifying them requires sudo.

  • November 15, 2013 at 1:59 am

    sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

  • November 15, 2013 at 2:50 pm

    Brilliant – thanks a bunch!

  • November 16, 2013 at 10:27 pm

    I got the following error message:

    You don’t have permission to access / on this server.

  • November 20, 2013 at 11:56 am

    Thanks Pete, saved me a lot of potential pain!

    Reverting the php.ini solved my issue of apache reminding me on any page load that ‘it works’.

  • November 20, 2013 at 7:54 pm

    Thank you sir!

  • Pingback: — Setting up Apache+Virtual Hosts on Mavericks

  • November 28, 2013 at 4:10 pm

    Followed the steps but get no results. New to macs, created the /www/dev.local.com folder and put an index.html file inside. Amended the httpd file as suggested and the extra/http-vhosts. Check the server has started and it is. In chrome is get It Works! first load then refresh i get connection issue, FF doesnt connect and IE neither, am I doing something wrong? Help greatly appreciated

  • Pingback: » Apache and MySQL problems after upgrading to OSX 10.9 Mavericks | Daniel Sellergren

  • December 19, 2013 at 4:13 pm

    I had a problem.. i’v got 403 forbidden after updating from Lion to Mavericks..
    i’v tried to change rules for directories in filesystem by CHMOD 777… but it’s not working

    Finally a found here ( http://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/ ) simple thing in /private/etc/apache2/extra/httpd-vhosts.conf that i’ve forgotten:

    AllowOverride All
    Order allow,deny
    Allow from all

    becouce and if you look in /private/etc/apache2/httpd.conf

    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all

    p.s. sorry for my english (not mach practice last years), but i hope my post help you to fix this very little mistake that take a lot of time to me.

  • December 26, 2013 at 10:22 pm

    Help out a newb, here, I cannot FIND the /etc directory.
    Where is it?

  • December 26, 2013 at 11:25 pm

    For those suffering from 403 Forbidden Errors, the following site had the solution for me (near the end, in the Losing Localhost section): http://www.coolestguidesontheplanet.com/downtown/how-set-virtual-hosts-apache-mac-osx-109-mavericks-and-osx-108-mountain-lion

    In the article, the author uses “DocumentRoot /Library/WebServer/Documents/” in his VirtualHost record. I changed it to “DocumentRoot /Users/username/Sites/” as it was changing the DocumentRoot that triggered the 403 error in the first place.

  • December 31, 2013 at 12:41 pm

    Hi Brian

    Your post is very useful, but do you know how the web server can be started automatically at system startup ? (That’s what the “web sharing” entry in previous versions of System Preferences did) It’s a pain to have to manually turn it on every time I start my Mac… There must be a way, but I don’t know how service launching works in nowadays’ macs…

  • January 2, 2014 at 9:18 am

    I’ve followed all the instructions, including replacing httpd.conf and php.ini.default with the previous versions – nothing doing, still getting “Oops! Google Chrome could not connect to localhost”.
    What could the cause be? What do you need to know from me? Any help would be appreciated.

  • January 2, 2014 at 1:56 pm

    I hop this helps someone… httpd-vhosts.conf include statement was on line number 478 on my machine

  • January 2, 2014 at 7:49 pm

    Very nice!


  • January 6, 2014 at 5:15 pm

    I have tried to configure, PHP and Apache according to given above., but if I try to open phpinfo.php file says unable to open.

  • January 7, 2014 at 6:37 pm

    Do yourself a favour and get VirtualHostX app (free 1 host, paid multiple). It does everything for you through a gui.

  • January 15, 2014 at 3:35 am

    Hey there,
    Just reinstalling my iMac and stubbled across a little notice for the tutorial.

    in mavericks the line 429
    On line 429, uncomment the Include of the httpd-vhosts.conf file:
    Include /private/etc/apache2/extra/httpd-vhosts.conf

    this has been changed to 478.

  • January 16, 2014 at 9:09 am

    Hi guys, I recently switch to Mac and after 10 days of agony I finally managed to setup everything. I just had to tell you one thing, it’s 3 times easier to setup CF 9 or 10 under JBoss 7 than to setup all these little thingies for JRun. Performance boost is side effect in this case :)

  • January 16, 2014 at 1:36 pm

    Does anyone know what permissions should be on the /www and /www/local.example.com directories? I had to “sudo mkdir” as “mkdir” did not have permission to create the directory, but now my text editor cannot write to that location.

  • January 16, 2014 at 5:13 pm

    I accidentally deleted the built-in apache, how can I re-install it?

  • January 18, 2014 at 1:32 pm

    Your step involving adding the PHP handler appears to not be necessary, at least in my version of Mavericks. At the end of the httpd.conf file, there’s a line:

    Include /private/etc/apache2/other/*.conf

    And if you look in the `other/` directory, there’s a php5.conf already there and configured. It just checks if the php5 module’s been turned on (vis-a-vis uncommenting the module line). As it turns out, moving the php5 handler code out into another config file is probably a better approach, anyway, from an organizational standpoint.

  • January 18, 2014 at 1:45 pm

    I had the same problem – eventually solved it by changing the owner of the /www folder from root to me:

    sudo chown $USER /www

    I always feel a bit out of my comfort zone mucking about with this stuff though – if this is a bad idea someone please tell me!

  • February 3, 2014 at 11:45 am

    The only modifications I made to your instructions were to substitute your instructions of making a “www” directory in root and the subdirectory of “local.example.com” in that www directory. I have a Sites directory at /Users/dave/Sites, which I believe carried over from previous installations of Mac OS X. I used that Sites directory and substituted all of the conf instructions accordingly.

    When I go into the Sites directory, I can double-click an html file and it will load in my browser. However, it will not run a php script. The result from a called php script is to display the raw php code. However, when I load the URL “localhost” or “local.dave.com” the browser displays “Index of /“, and all of the files and directories of my “Sites” directory, which is located at /Users/dave/Sites. If I click on any html or php file listed on the localhost browser page, it executes the html and php script correctly. So, is this a correct installation of Apache and php? For the purposes of simply creating a local development environment, it appears to be doing everything I need it to do.

    Now I need to install MySql. I have checked my /usr/local directory and there is no mysql directory. I also need to install phpMyAdmin.

    Can you point me to a link (preferably one that you wrote) that provides instructions on installing MySql and PhpMyAdmin so it will all work together with my current Apache and PHP configurations? Or, if I download MySql and phpMyAdmin, will they install correctly and automagically work with the configuration I have?

    Thanks very much Brian.


  • February 5, 2014 at 5:31 pm

    I linked my ip to a host name, but I’m still required to append the port number in order to load the site. Anything that I can do to just type the host name sans port number?

  • February 14, 2014 at 3:02 am

    thx for the nice tutorial. Helped me getting started with apache and mac os x.

  • February 20, 2014 at 12:24 pm

    Thanks for the nice tutorial. Helped me getting started with apache and mac os x.

  • February 23, 2014 at 5:10 pm

    Thanks! 😀

    Worked for me!

  • Pingback: OS X MAVERICKS WEB SHARING | uguryavuz

  • March 18, 2014 at 7:19 pm

    i need to run apache+php in my macbook and mysql in a flash drive … it is possible?

  • April 5, 2014 at 5:14 pm

    Hi! Would you mind if I share your blog with my
    facebook group? There’s a lot of folks that I think would really enjoy your content.
    Please let me know. Cheers

  • April 25, 2014 at 7:43 am

    Thanks for this. Apparently, on my install (I have a sites-enabled folder set up on my mac instead of one single vhost file for ease of scalability) I needed to copy over httpd.conf~previous rather than httpd.conf.pre-update, and everything went back to normal.

    Thanks to you and all the other commenters here who saved me a hell of a lot of trouble :)

Comments are closed.