How to Easily Edit Httpd.conf on Mac Lion or Snow Leopard

Httpd.conf is normally protected from editing by Mac OS X. This article shows the easiest way to overcome this security and edit httpd.conf.

Theses editing methods have been tested on Mac OS X 10.6 Snow Leopard (10.6.7, 10.6.8) and Mac OS X Lion 10.7.

Edit Httpd.conf on Mac OS X 10.6 Snow Leopard

If you’re running Snow Leopard, you’ve got it easy! You can edit httpd.conf using the TextEdit app. This method does not work for Lion. If you’re using Lion, go on to the next section.

If you open the httpd.conf file with TextEdit normally, you won’t be able to save. You can’t save httpd.conf because Mac OS X protects httpd.conf, so that people don’t accidentally damage or delete their web server config, or open up security holes.

To edit httpd.conf, you will need superuser or root privileges.

To edit httpd.conf:

  1. Open the Terminal application.
    It’s in the Utilities folder, inside the Applications folder.
  2. Type in the command below.
    It will prompt you with “Password:” on the next line.
  3. Enter your Mac password.
    The TextEdit application will start with httpd.conf loaded.
  4. Edit httpd.conf.
  5. Save httpd.conf.

The command to enter is:

sudo open /Applications/ \ 
--args /etc/apache2/httpd.conf

This method doesn’t work on Lion. Lion has increased security over Snow Leopard. On Lion, opening TextEdit with sudo doesn’t confer enough privileges to TextEdit to open httpd.conf. If I find a workaround to edit httpd.conf in TextEdit on Lion, I’ll post it here. If you know a workaround for Lion, please comment below.

Edit Httpd.conf on Mac OS X 10.7 Lion

Since we can’t edit httpd.conf with TextEdit or other apps on Lion due to tighter security, our next best bet is the simple terminal-based text editor that ships with OS X, pico.

Here’s how to edit httpd.conf with pico:

sudo pico /etc/apache2/httpd.conf

To make life easy, Pico displays a list of keyboard commands at the bottom of the screen, such as ^X Exit. It’s important to know that the hat character “^” means the control key. So ^X is the same as Control-X, which means hold down the control key and press and release the X key.

If your familiar with the vi text editor, you could use that instead.

Let me know how you go!

Tagged , , . Bookmark the permalink.

18 Responses to How to Easily Edit Httpd.conf on Mac Lion or Snow Leopard

  1. Nancy Rodger says:

    I followed the above TextEdit command, using 10.6.7 OS. Not working. Do you have an update on this solution?


    • Tasman Hayes says:

      Nancy, firstly – wow! Love your art! And a New Yorker cover? Wow again!

      Thanks for commenting – I want to make sure this works for you.

      I retested the TextEdit solution above on my MacBook Pro 15″ and MacBook Air 11″ – both running 10.6.7 (soon to be 10.7 Lion), and it works great on both.

      Couple of questions:

      It’s easy to leave off a bit of the command, because it’s in its own little window with a scrollbar, and you need to scroll to see the entire command. Did you copy and paste the entire terminal command above? When you copy, double click sudo and then drag all the way to the right until everything up to httpd.conf is highlighted.

      When pasting the command (and pressing return), the sudo command should have prompted you for your Mac user password with the text “Password:” on the next line. Did you see the password prompt?

      Note that when you type your password with sudo, there’s no indication that the Mac is receiving your password – not even little asterisks for each character.

      Did the Mac accept your password? If you enter an incorrect password and press return, “Sorry, try again.” will be printed in the Terminal. If it accepted your password, TextEdit should have at least started.

      After you entered your password, did you get a Text Edit window? If so, was the TextEdit window empty, or did TextEdit put up an error message?

      Let me know how you go with this. If these finer points don’t help you, please let me know what happens instead of the expected result. For example the TextEdit window doesn’t come up, an error window pops up, it won’t accept the password, or there’s an error message in the Terminal.

      Happy to give you a call or Skype and use screen sharing to get it working. If it’s not working for you, chances are this is happening for lots of other people too.

      • Andrew Wells says:

        I’m having difficulties as well. I got the password prompt, but then when text edit loaded I just got a blank window.


        • Tasman Hayes says:


          Thanks for your question!

          The first command was a bit difficult to copy and paste because it extends beyond the page width.

          I’ve made it easier to copy by having the command run over two lines.

          Please try it Andrew and see if that works for you.

          Let me know how you go!


  2. Luciana says:

    Thanks for the clear instructions.
    I have this site booked marked.


  3. Ryders says:

    sudo open -a TextEdit /etc/apache2/httpd.conf

  4. JohnF says:

    I have no trouble opening httpd and editing it (only removing # to activate php) however no matter what I try, including changing permissions at file and folder level I still get the message ” .. you do not have permission..” even after fulfilling the request “..go to Get Info..”. This on Snow Leopard 10.6.8

    Any thoughts on where to next?

    • Tasman Hayes says:


      Try this command to edit http.conf instead. Run it from the Terminal app:

      sudo open -e /etc/apache2/httpd.conf

      Let me know how you go.


    • JohnF says:

      Many thanks Taz, that did the trick.


      • Paul says:

        When I use sudo open -e /etc/apache2/httpd.conf, I still cannot save the changed file.
        OS 10.6.8

        When I use sudo pico /etc/apache2/httpd.conf, I do not know how to “save” the change in Terminal. Can you help? Thanks.

        • delliottg says:

          If you use:
          sudo pico /etc/apache2/httpd.conf to open the file, there are commands along the bottom of the screen. Make your changes and then just do ctrl-x to exit the file, you’ll be prompted to save, enter “y” and then hit the enter key. You’re done.

          • Colin says:

            I am using 10.7 and confirmed I was unable to use TextEdit. When I try to use Pico and ^o for Writeout or ^x and then yes, I always get a message “Permission Denied”. Has anyone else solved this problem>

  5. Con says:

    Cheers for the succinct instructions. Just what I needed!

  6. EkHo_Roger_That! says:

    Works great!!
    Thanks for the hint.

  7. Glen says:

    I was able to edit the httpd.conf in 10.7 file by dragging it onto my desktop, which created a duplicate that was editable in TextEdit. When done, dragged the edited copy back and replaced the original with authorization. I haven’t succeeded in my attempts to add ssl certificates, and the result created a new file called httpd.conf.prev which appears to be the default .conf file. Is the computer over protecting me from myself, or are my edits being taken?

    • Glen says:

      I’ve established that I am able to modify the .conf file. I’ve messed it up so that it can’t find any certificates. But that’s for another post. One odd thing is that I have two .conf files in the Apache2 file. One in the file itself and another in an /apache2/original file. I’ve been modifying both.

Leave a Reply

Your email address will not be published. Required fields are marked *