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 .
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.
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.
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.
@Howard, I think I tried those commands but I didnt know you had to install the command line proxies. Thanks for the tip.
No problem, welcome to the Mac!
Personally I use path finder http://cocoatech.com/, 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 http://clickontyler.com/virtualhostx/ 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.
oops forgot 1
http://code.google.com/p/gmask/
@dave, thanks for the links, I will check them out. they look pretty useful to me.
Just what I was looking for, thanks!
[…] How to edit httpd.conf on MacOS (Anuj Gakhar). […]
Was great, thanks
Hi…
I got a mistake, and I can’t recover the httpd.conf now…
How I can do?
@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.
Awesome! Sounds trivial, but really hard to figure out.. even with Google by my side. Thanks for the tip!
Thank you for doing this. Super helpful, otherwise wouldn’t have been able to set up my phone.
Great job!
Hamilton
right cick this file ->Get info ->change permissions and then opening the file in TextEdit
This is the best reference I have ever found to getting work done on the Mac
Thanks lol….
Below mentioned url is very easy to understand,
http://www.redhatlinux.info/2011/11/different-types-of-configure-httpd.html
But the URL is no longer active, alas
Thank you, this was a grate help.
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