Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active January 11, 2017 23:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ziadoz/862bfc6fa4b579843219306b7a66fa19 to your computer and use it in GitHub Desktop.
Save ziadoz/862bfc6fa4b579843219306b7a66fa19 to your computer and use it in GitHub Desktop.
Automatically Symlink Virtualhosts
# Symlink web server virtualhost configutions into the sites-enabled directory.
# Usage: reloadvhosts /path/to/websites
# reloadvhosts /path/to/websites *-live.conf
# reloadvhosts /path/to/websites apache2
reloadvhosts() {
local vhost_dir=${1:-/var/www/vhosts}
local conf_name=${2:-*dev.conf}
local web_server=${3:-nginx}
sudo find /etc/$web_server/sites-enabled/ -type l -exec rm {} \;
sudo find $vhost_dir -name $conf_name -exec ln -sf {} /etc/$web_server/sites-enabled/ \;
sudo service $web_server restart
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment