Off late, I’ve been working a lot with Apache configration files. And since I use BBEdit for most of my text file editing, I invariably use BBEdit for editing Apache configuration files. My workflow for working with these files is now quite settled. I thought I’d share it here.
Syntax Color Coding
BBEdit has very nice third-party language module for Apache Configuration files. The module automagically provides syntax coloring for all the Apache keywords, making it really easy to read configuration files. If you have ever had to work with Apache configuration files, you will see the utility in something like this. Obviously if you make any error in spelling out a directive or any other keyword, it does not get color-coded, so one ends up making fewer errors.
Editing All Files at One Go
BBEdit has a very feature where one can open up a whole folder for editing. All files in the folder being edited become available on one side of the screen.
This comes in quite handy if you have a lot of include files in your main Apache conf. I have my enviornment setup so that I issue the following on Terminal and BBEdit loads up the folder view for Apache configuration files:
bbedit /private/etc/apache2
Testing Configuration
After making any change to configuration files, I normally test if the changes are ok or not. I’ve created a simple shell script that does the needful.
#!/bin/sh sudo apachectl -t
Using BBEdit you can run this script from within BBEdit, without having to open Terminal. You need to click on the top menu option which looks like #! to bring up the menu to run the script.
Restarting Apache
If the test is ok, you can restart Apache. I have another simply shell script that does the needful:
#!/bin/sh sudo apachectl restart
Again, I run it using the BBEdit option to run scripts in Terminal.
All in all, with the plugin and these simply scripts, my Apache webserver configuration tasks have become much simpler and more streamlined.
I just switched from a PC to a Mac and I needed a text editor so I downloaded TextMate. It has a built-in bundle for Apache that allows you to open various configuration files as well as start, stop, restart and test your config file all from either a menu or using keyboard shortcuts. Just thought I’d mention it as I had no idea that feature would be built-in.
Yes, TextMate is good with some things, and BBEdit is good with some other things.
These days I’m trying out Coda. Really enjoying it till now. I end up using both BBEdit and Coda.
In fact I just posted another blog on update Language Module for Apache in Coda (http://nagpals.com/blog/post.cfm/apache-configuration-language-module-for-coda)