{"id":20692649,"url":"https://github.com/kevingimbel/vhost","last_synced_at":"2026-02-27T13:34:21.317Z","repository":{"id":68322959,"uuid":"43564311","full_name":"KevinGimbel/vhost","owner":"KevinGimbel","description":":computer: Create new Apache Virtual Hosts with one bash command.","archived":false,"fork":false,"pushed_at":"2016-10-19T12:58:59.000Z","size":29,"stargazers_count":4,"open_issues_count":3,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T17:22:19.390Z","etag":null,"topics":["apache","bash","config","generator","webserver"],"latest_commit_sha":null,"homepage":"https://kevingimbel.com/projects/bash-vhost/","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KevinGimbel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-10-02T16:39:05.000Z","updated_at":"2024-04-02T13:32:04.000Z","dependencies_parsed_at":"2023-02-22T23:01:36.103Z","dependency_job_id":null,"html_url":"https://github.com/KevinGimbel/vhost","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinGimbel%2Fvhost","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinGimbel%2Fvhost/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinGimbel%2Fvhost/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KevinGimbel%2Fvhost/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KevinGimbel","download_url":"https://codeload.github.com/KevinGimbel/vhost/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250289071,"owners_count":21405908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apache","bash","config","generator","webserver"],"created_at":"2024-11-16T23:23:24.773Z","updated_at":"2026-02-27T13:34:16.276Z","avatar_url":"https://github.com/KevinGimbel.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vhost\n\n[![Join the chat at https://gitter.im/kevingimbel/vhost](https://badges.gitter.im/kevingimbel/vhost.svg)](https://gitter.im/kevingimbel/vhost?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge)\n\n`vhost` is a command line utility for creating new Virtual Hosts for the Apache Server. It was build out of laziness. Currently the script supports creating files for the Apache Web Server. Nginx support is on the roadmap but due to my lack of Nginx knowledge currently far away.\n\n**NOTE:** `vhost` has only been tested on Ubuntu 14.04 running Apache 2.4.7! On other Linux Distributions most used programms (`rm`, `cp`, `sed`, `sudo`) should be available. It could happen that things go bad and you break your local Server. Be warned!\n\nWith a Linux Distribution similar to Ubuntu (such as Kubuntu, Lubuntu, etc.) you should be good to go. Other Linux Distributions as well as OS X most likely need to adjust the script as needed.\n\n**This script is not intended to, and will never, run on Windows**\n\n### vhost - installation\n\nClone this repository to some place on your computer.\n\n```sh\n$ cd ~/workspace/github\n$ git clone git@github.com:kevingimbel/vhost.git\n```\n\nNext symlink the `template.conf` to `/etc/apache2/sites-available` - this file is\nthe template for all future Virtual Hosts. You'll also need to make vhost\nexecutable and then symlink the vhost executable to some place that's in\nyour `$PATH`.\n\nSo, inside the Repository do the following\n```sh\n$ (sudo) ln -s /full/path/to/template.conf /etc/apache2/sites-available\n$ chmod +x vhost\n$ ln -s /full/path/to/vhost /usr/local/bin/vhost\n```\n\nNow you should be able to run `vhost -h` to get a help and usage message.\n\nAt this point you should perform a quick system check. Run `vhost --test` and\n`vhost` will do a basic check for functions, folders and directories.\n\n### vhost - usage\n\nCreating a new Virtual Host is now as easy as calling `vhost test` - this will\ngenerate a Virtual Host configuration file named `test.local.conf` inside\n`/etc/apache2/sites-available/`, add a Document Root to `/var/www/html/` named\n`test`, generate a index.html inside the new Document Root and add a new Host\nentry to the `/etc/hosts` file. The script also reloads Apache to activate the\nnew configuration.\n\nThat's it, you can now visit [http://test.local](http://test.local/) and see\nyour shiny new Virtual Host in action.\n\nYou can also do a test run with `vhost -t`. This creates the configuration for http://test.local/ and tries to reload your Apache Server.\nTo remove this host type `vhost -r test`.\n### vhost - configuration\n\nYou can modify the `template.conf` file as you wish by changing default Document\nRoots, Server Names or whatsoever. Inside the file is a variable names\n`{{CUSTOM}}`. This variable is replaced by whatever you pass as an argument to\n`vhost`.\n\nSo let's say you want to publish your sites at `.dev` instead of\n`.local` and your default Document Root should be on `~/workspace`. Your\ntemplate file would then look like this.\n\n```\n\u003cVirtualHost *:80\u003e\n  \tServerAdmin webmaster@localhost\n  \tServerName {{CUSTOM}}.local\n\n  \tDocumentRoot /var/www/html/{{CUSTOM}}\n\n    ErrorLog /var/log/apache2/{{CUSTOM}}.local/error.log\n    CustomLog /var/log/apache2/{{CUSTOM}}.local/access.log combined\n\n   \u003cDirectory \"/var/www/html/{{CUSTOM}}/\"\u003e\n     AllowOverride all\n     Require all granted\n   \u003c/Directory\u003e\n\u003c/VirtualHost\u003e\n\n# \u003cVirtualHost *:443\u003e\n#     ServerAdmin webmaster@localhost\n#     ServerName {{CUSTOM}}.local\n#\n#     SSLEngine on\n#     SSLCertificateFile /etc/ssl/certs/{{CUSTOM}}.crt\n#     SSLCertificateKeyFile /etc/ssl/private/{{CUSTOM}}.key\n#\n#     DocumentRoot /var/www/html/{{CUSTOM}}\n#     \n#     ErrorLog /var/log/apache2/{{CUSTOM}}.local/error.log\n#     CustomLog /var/log/apache2/{{CUSTOM}}.local/access.log combined\n#\n#    \u003cDirectory \"/var/www/html/{{CUSTOM}}/\"\u003e\n#      AllowOverride all\n#      Require all granted\n#    \u003c/Directory\u003e\n# \u003c/VirtualHost\u003e\n```\n\n# vhost-ssl\n\n### vhost-ssl - install\n\nLike installing `vhost` you just need to make the file executable and link it somewhere in your path. Then run `vhost-ssl -v` to verify it worked.\n\n```sh\n$ (sudo) ln -s /full/path/to/vhost-ssl /usr/local/bin/vhost-ssl\n$  vhost-ssl -v\n\n```\n\n### vhost-ssl - configuration\n\n`vhost-ssl` is a utility tool to create SSL keys and certificates for self-signed SSL certificates to use in local development. To run `vhost-ssl` you will need to create a `.vhostrc` in your home directory (`~/`). Inside configure a default key file used to sign certificates and a default output directory.\n\n```txt\n# .vhostrc\nvhost_ssl_cert_dir=\"/etc/ssl/certs\"\nvhost_ssl_key_file=\"/etc/ssl/private/apache.key\"\n```\n\nThe `.vhostrc` file is read in when the command runs.\n\n### vhost-ssl - usage\n\nSee `vhost --usage` for a usage overview. \n\n```txt\nUsage: vhost-ssl [options [arg]]\nScript to create SSL keys and certificates.\n\nOptions:\n    -u,--usage            Show usage message\n    -h,--help             Show help message for command, e.g. vhost-ssl -c --help\n    -v,--version          Show version and author info\n    -i,--info             Show info about root privileges\n    -c,--cert [str]       Name of the certificate to be created\n    -o,--out [str]        Output directory for key file\n    -k,--key [str]        Create a key file, pass name as argument\n\nRun 'vhost-ssl COMMAND --help' for more information on a command.\nFor example 'vhost-ssl -c --help'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevingimbel%2Fvhost","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevingimbel%2Fvhost","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevingimbel%2Fvhost/lists"}