Bash Script to allow create or delete apache virtual hosts on Ubuntu on a quick way.
This script also supports SSL, it means HTTPS is available.
- Download the script
- Edit variables in the script (such as target directory for ssl certificates)
- Apply permission to execute:
$ chmod +x /path/to/virtualhost.sh
- Optional: if you want to use the script globally, then you need to copy the file to your /usr/local/bin directory, is better if you copy it without the .sh extension:
$ sudo cp /path/to/virtualhost.sh /usr/local/bin/virtualhost
$ cd /usr/local/bin
$ wget -O virtualhost https://raw.githubusercontent.com/petrfilip/virtualhost/master/virtualhost.sh
$ chmod +x virtualhost
Basic command line syntax:
$ sudo sh /path/to/virtualhost.sh [create | delete | list] [domain]
With script installed on /usr/local/bin
$ sudo virtualhost [create | delete | list] [domain]
to create a new virtual host:
$ sudo virtualhost create mysite.dev
to delete a virtual host
$ sudo virtualhost delete mysite.dev