Dec 14, '09 07:30:00AM • Contributed by: jweber
If you work with the built-in web server a lot, it's helpful to write some simple AppleScripts to open the files in your text editor, and to restart the server. Use AppleScript Editor to create the following scripts in your user's Library/Scripts folder.
A script to edit your httpd.conf file:
tell application "TextWrangler" open "/private/etc/apache2/httpd.conf" activate end tellA script to edit your user-specific httpd.conf file (if you use one):
tell application "TextWrangler" open "/private/etc/apache2/users/username.conf" activate end tellA script to edit your php.ini file (if you use PHP):
tell application "TextWrangler" open "/etc/php.ini" activate end tell
A script to restart Apache:
try do shell script "/usr/sbin/apachectl configtest && /usr/sbin/apachectl restart" with administrator privileges on error errorMsg number errorNum display alert "Error " & errorNum message errorMsg buttons "OK" default button 1 end try
If you use TextEdit instead of TextWrangler, you'll need to modify the scripts to launch TextEditor, which must be done differently. Replace each editing script above with one command, like this:
do shell script "/Applications/TextEdit.app/Contents/MacOS/TextEdit /private/etc/apache2/httpd.conf &> /dev/null &" with administrator privileges
