Virtualhost
Bash Script to easy create or delete apache virtual hosts on ubuntu
Install / Use
/learn @RoverWire/VirtualhostREADME
Virtualhost Manager Script
Bash Script to allow create or delete apache/nginx virtual hosts on Ubuntu on a easy way.
Installation
- Download the script
- Apply permission to execute:
$ chmod +x /path/to/virtualhost.sh
- Optional: To use the script globally, copy it to the /usr/local/bin directory. It is recommended to remove the .sh extension.
$ sudo cp /path/to/virtualhost.sh /usr/local/bin/virtualhost
For Global Shortcut
$ cd /usr/local/bin
$ wget -O virtualhost https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost.sh
$ chmod +x virtualhost
$ wget -O virtualhost-nginx https://raw.githubusercontent.com/RoverWire/virtualhost/master/virtualhost-nginx.sh
$ chmod +x virtualhost-nginx
Usage
Basic command line syntax:
$ sudo sh /path/to/virtualhost.sh [create | delete] [domain] [optional root_dir] [optional is_subdomain] [optional canonical]
With script installed on /usr/local/bin
$ sudo virtualhost [create | delete] [domain] [optional root_dir] [optional is_subdomain] [optional canonical]
Parameters:
domainis the domain name for the virtualhost (myhomepage.com, test.local, etc)root_diris the path where your want to serv as domain root for your host files. If not specified it will create a new one under /var/www folder.is_subdomainis a boolean true/false to flag when a host is subdomain.canonicalcan have two possible values: www or empty, this is to add another entry in the hosts files preppending the www.
Examples
to create a new virtual host:
$ sudo virtualhost create mysite.dev
to create a new virtual host with custom directory name:
$ sudo virtualhost create anothersite.dev my_dir
to delete a virtual host
$ sudo virtualhost delete mysite.dev
to delete a virtual host with custom directory name:
$ sudo virtualhost delete anothersite.dev my_dir
Localization
WARNING: Localizations are outdated, any help to contribute to fix this is welcome.
For Apache:
$ sudo cp /path/to/locale/<language>/virtualhost.mo /usr/share/locale/<language>/LC_MESSAGES/
For NGINX:
$ sudo cp /path/to/locale/<language>/virtualhost-nginx.mo /usr/share/locale/<language>/LC_MESSAGES/
Contributions
Contributions are welcome. You can also report any issues.
Thank you to everyone who has contributed over the years.
Related Skills
node-connect
347.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
107.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
347.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
347.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
