Skip to content

Script to create or delete Apache virtualhosts on Debian and Ubuntu

License

Notifications You must be signed in to change notification settings

NocedaMediaLab/virtualhost

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Virtualhost script

Script to create or delete Apache virtualhosts with corresponding public and log directories on Debian and Ubuntu.

Installation

$ cd /usr/local/bin
$ sudo wget -O virtualhost https://raw.githubusercontent.com/NocedaMediaLab/virtualhost/master/virtualhost.sh
$ sudo chmod +x virtualhost

Assumption

The website is owned by a non-root user, and user has been added to the Apache group www-data

$ sudo adduser ${USER} www-data

Usage

Basic command line syntax:

$ sudo virtualhost [create | delete] [domain] [optional custom_dir]

Examples

To create a new virtualhost:

$ sudo virtualhost create example.com

To create a new virtualhost with custom directory name:

$ sudo virtualhost create example.com custom_dir

To delete a virtualhost

$ sudo virtualhost delete example.com

To delete a virtual host with custom directory name:

$ sudo virtualhost delete example.com custom_dir

Default configuration

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

About

Script to create or delete Apache virtualhosts on Debian and Ubuntu

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages