Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.
/ vhm Public archive

command line script to manage VirtualHosts on Mac OS X or other unix like systems

License

Notifications You must be signed in to change notification settings

alxndrhi/vhm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VirtualHostManager (vhm)

A script that helps to manage virtual hosts on Mac OS X (it may also run on other unix based systems with some or no changes).

The Idea is to keep the changes on the existing config as little as possible.

Install

Homebrew (recommended)

  1. Install: brew tap alxndrhi/miscbrew && brew install vhm
  2. Tell apache where to find the configuration: sudo echo "Include /usr/local/etc/vhm/httpd-vhosts.conf" >> /etc/apache2/extra/httpd-vhosts.conf
  3. Check the vhm Configuration in: /usr/local/etc/vhm/vhm.cfg

Manual

  1. create sites-available folder: mkdir -p /usr/local/etc/vhm/sites-available
  2. create sites-enabled folder: mkdir -p /usr/local/etc/vhm/sites-enabled
  3. create templates folder: mkdir -p /usr/local/etc/vhm/templates
  4. Download Release from releases page untar / unzip it
  5. symlink vhm: ln -s WHEREVER-YOU-PUT-THE-FILES/vhm /usr/local/bin/vhm
  6. copy config: cp WHEREVER-YOU-PUT-THE-FILES/vhm.cfg /usr/local/etc/vhm/vhm.cfg (don't forget to edit the config)
  7. copy template cp WHEREVER-YOU-PUT-THE-FILES/VirtualHost.conf /usr/local/etc/vhm/templates/
  8. copy apache config file cp WHEREVER-YOU-PUT-THE-FILES/httpd-vhosts.conf /usr/local/etc/vhm/
  9. Tell apache where to find the configuration: sudo echo "Include /usr/local/etc/vhm/httpd-vhosts.conf >> /etc/apache2/extra/httpd-vhosts.conf

Using vhm

To create a host, you have to go into the root folder of the new host and run vhm -d domain-name cr.

examples

Ok, lets say we want to create the development domain testing.dev with the "DocumentRoot" in ~/Sites/testing.dev/, and as we are already here, we also want to enable it and restart apache.

mkdir -p ~/Sites/testing.dev
cd ~/Sites/testing.dev
vhm -d testing.dev cr en --apache-restart

You can use your custom template file or an alternative template file by using the --template parameter.

mkdir -p ~/Sites/testing.dev
cd ~/Sites/testing.dev
vhm -d testing.dev cr en --template MyTemplateFileName.conf --apache-restart

To delete, disable or enable an existing VirtualHost you dont have to cd into the "DocumentRoot". Just use the --domain parameter:

vhm -d testing.dev --enable
vhm -d testing.dev --disable
vhm -d testing.dev --delete

See a list of Domains including Status:

vhm -l

For a full list of parameters see vhm --help

Template files

You can create your own template files. Just put them in /usr/local/etc/vhm/templates.

Info

  • After creating a new VirtualHost you have to enable it.
  • Remember to restart apache after every change to the configuration.
  • If apache don't start just run apachectl without any parameter to see the error message.
  • Delete will remove the VirtualHost config file and the symlink from /etc/apache2/sites-enabled and /etc/apache2/sites-available. This will not remove any of your project files.

About

command line script to manage VirtualHosts on Mac OS X or other unix like systems

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages