Script to create or delete Apache virtualhosts with corresponding public and log directories on Debian and Ubuntu.
$ cd /usr/local/bin
$ sudo wget -O virtualhost https://raw.githubusercontent.com/NocedaMediaLab/virtualhost/master/virtualhost.sh
$ sudo chmod +x virtualhostThe website is owned by a non-root user, and user has been added to the Apache group www-data
$ sudo adduser ${USER} www-dataBasic command line syntax:
$ sudo virtualhost [create | delete] [domain] [optional custom_dir]To create a new virtualhost:
$ sudo virtualhost create example.comTo create a new virtualhost with custom directory name:
$ sudo virtualhost create example.com custom_dirTo delete a virtualhost
$ sudo virtualhost delete example.comTo delete a virtual host with custom directory name:
$ sudo virtualhost delete example.com custom_dir
New virtualhost:
- The virtualhost will be created at
/var/www/webapps/example.com - Access and log files will be at
/var/www/webapps/example.com/logs - Public directory is at
/var/www/webapps/example.com/web
New virtualhost with custom directory name:
- The virtualhost will be created at
custom_dir - Access and log files will be at
custom_dir/logs - Public directory is at
custom_dir/web