Skip to content

A collection of bash scripts to manage Apache virtual hosts and SSL certificates for local development environments in Ubuntu.

Notifications You must be signed in to change notification settings

shakilahmed0369/local-apache-host-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Local Apache Host Manager

A collection of bash scripts to manage Apache virtual hosts and SSL certificates for local development environments in Ubuntu.

Author Shakil Ahmed   Website: shakilahmeed.com

Overview

This toolkit includes three main scripts:

  1. createhost.sh - Creates new virtual hosts with SSL certificates
  2. removehost.sh - Removes existing virtual hosts and their configurations
  3. sitelist.sh - Lists all configured virtual hosts with their status

Prerequisites

  • Ubuntu/Debian-based system
  • Apache2 installed
  • Root/sudo privileges

Installation

  1. Clone the repository:

    git clone https://github.com/shakilahmed0369/local-apache-host-manager.git
  2. Make the scripts executable:

    cd local-apache-host-manager
    chmod +x createhost.sh removehost.sh sitelist.sh

Usage

Creating a New Virtual Host

sudo ./createhost.sh

You will be prompted to enter:

  • Domain name (e.g., myproject.local)
  • Project folder name (must exist in /var/www/html)

The script will:

  • Add the domain to /etc/hosts
  • Create Apache virtual host configuration
  • Generate and configure SSL certificates
  • Enable the site in Apache

Removing a Virtual Host

sudo ./removehost.sh

You will be prompted to enter:

  • Domain name to remove

The script will:

  • Remove the domain from /etc/hosts
  • Remove SSL certificates
  • Remove Apache configuration
  • Disable the site
  • Clean up all related files

Listing Virtual Hosts

sudo ./sitelist.sh

This will display a table showing:

  • Domain names
  • SSL status (✓ or ✗)
  • Project paths
  • Enabled status (green = enabled, red = disabled)

Directory Structure

Your projects should follow this structure:

/var/www/html/
├── project1/
│   └── public/
└── project2/
    └── public/

SSL Certificates

  • The scripts generate self-signed SSL certificates for local development
  • Browsers will show a security warning (this is normal for local development)
  • Certificates are valid for 365 days

Common Issues

  1. SSL Warning in Browser

    • This is normal for self-signed certificates
    • Click "Advanced" → "Proceed to site" (Chrome)
    • Click "Advanced" → "Accept Risk" (Firefox)
  2. Project Directory Not Found

    • Ensure your project exists in /var/www/html
    • Ensure the public directory exists in your project folder
  3. Permission Issues

    • All scripts must be run with sudo privileges
    • Check Apache log files for detailed errors

File Locations

  • Apache configs: /etc/apache2/sites-available/
  • SSL certificates: /etc/ssl/[domain]/
  • Host entries: /etc/hosts
  • Project files: /var/www/html/[project]/public

Contributing

Feel free to open issues or submit pull requests for improvements.

License

MIT License - feel free to use and modify for your needs.

About

A collection of bash scripts to manage Apache virtual hosts and SSL certificates for local development environments in Ubuntu.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages