Created
April 18, 2013 10:50
-
-
Save foreignfilm/5411853 to your computer and use it in GitHub Desktop.
Some handy bash aliases for controlling Apache on Mac.
Tested on OS X 10.8.3.
Add the below code to your ~/.bash_profile and run `source ~/.bash_profile`.
Install terminal-notifier (`sudo gem install terminal-notifier`) for Notification Center alerts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias apache-start="sudo apachectl start" | |
alias apache-stop="sudo apachectl stop" | |
alias apache-restart="sudo apachectl restart" | |
alias apache-config="subl /etc/apache2/httpd.conf /etc/apache2/extra/httpd-vhosts.conf /etc/hosts -n" | |
apache-toggle-vhost() { | |
apache_httpd_conf_file="/etc/apache2/httpd.conf" | |
commented_out=$(sudo perl -pi -e 'END { print($prefix)} s/(#?)Include (.*?-vhosts.conf$)/if($1){$prefix=""}else{$prefix="#"}$prefix."Include ".$2/e' $apache_httpd_conf_file) | |
if [ -n "$commented_out" ]; then | |
terminal-notifier -message "Virtual Hosts are disabled. Apache restarted" -title "Virtual Hosts Off" | |
else | |
terminal-notifier -message "Virtual Hosts are enabled. Apache restarted" -title "Virtual Hosts On" | |
fi | |
apache-restart | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment