Code Monkey home page Code Monkey logo

vhm's Introduction

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.

vhm's People

Contributors

alxndrhi avatar displayn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.