How to edit httpd.conf on MacOS

On January 19, 2009, in Mac, by Anuj Gakhar

I know this is an easy one for most of you out there but not so easy for me! I am a relatively new Mac user and everytime I want to make some changes to my Apache configuration file, I open Finder and go to /etc/apache2/httpd.conf , open it with TextEdit or TextWrangler and make changes and thats when I get the message “httpd.conf cant be saved as you dont have access” . Damn!

I keep forgetting how to do it and everytime I have to google it , so I decided to blog it this time.

The proper way to do this is:-

1) Open Terminal

2) Type “sudo pico /etc/apache2/httpd.conf” , enter your password and the file opens up in the Terminal window.

3) Make your changes and save.

Maybe this little tip helps some Mac newbies out there .

Tagged with:  

21 Responses to How to edit httpd.conf on MacOS

  1. Although I don’t necessarily recommend it, it’s easy enough to alter the permissions/ownership of the file so that you could edit it in another editor.

    • Anuj Gakhar says:

      You are probably right Rob. But I tried doing the same thing (right cick ->Get info ->change permissions) and then opening the file in TextEdit etc and it didnt work. Maybe I missed something.

  2. Howard Fore says:

    If you installed the command line proxies for TextMate or TextWrangler (mate and edit, respectively) you could stay in your GUI. Jsut type in “sudo edit /etc/apache2/httpd.conf”, supply your password when asked, and then the file will popup in the editor.

  3. Anuj Gakhar says:

    @Howard, I think I tried those commands but I didnt know you had to install the command line proxies. Thanks for the tip.

  4. Howard Fore says:

    No problem, welcome to the Mac!

  5. dave says:

    Personally I use path finder, which is a great mac app.. I bought it mostly for this EXACT reason. One of the great features it has is that you can turn on “show hidden folders” when you use it so you see them in path finder but not in reg finder which is SUPER nice. Next it has it’s own built in editors so when you edit the httpd file it will just ask you to put in pw and it’s done.

    I also use which does this very nicely and quickly. Just be sure to find and read my comments on it in the support section since the default install location changed.

    There is another app like this called headdress but the guys site is gone it looks like.

    I am actually learning some cocoa right now so I can make a lil mac app that will do this plus control cfm, railo, openbd, mysql.

    Don’t forget you could make a handy lil automator script for this as well. If you haven’t checked out automator you should! The built inmac tools are amazing… you could even write a quick little applescript for this.

  6. Anuj Gakhar says:

    @dave, thanks for the links, I will check them out. they look pretty useful to me.

  7. Arun says:

    Just what I was looking for, thanks!

  8. […] How to edit httpd.conf on MacOS (Anuj Gakhar). […]

  9. Babak says:

    Was great, thanks

  10. Federico says:

    I got a mistake, and I can’t recover the httpd.conf now…
    How I can do?

  11. Anuj Gakhar says:

    @Federico, what do you mean, you cant recover? Have you deleted the file by mistake? There must be a http.conf file under your “conf/original” folder.

  12. Neo says:

    Awesome! Sounds trivial, but really hard to figure out.. even with Google by my side. Thanks for the tip!

  13. Thank you for doing this. Super helpful, otherwise wouldn’t have been able to set up my phone.

    Great job!


  14. friv says:

    right cick this file ->Get info ->change permissions and then opening the file in TextEdit

  15. MacEnemy says:

    This is the best reference I have ever found to getting work done on the Mac

  16. pravin says:

    Thanks lol….
    Below mentioned url is very easy to understand,

  17. poorna says:

    Thank you, this was a grate help.

  18. Ram says:

    Hi Anuj, thanks for the post. I started of by opening in vi editor but I see a blank page but then I came across your post and I could see the contents in pico editor.. Not sure if I am doing something wrong with the vi editor

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar