• Skip to secondary menu
  • Skip to main content
  • Skip to primary sidebar
  • Home
  • Projects
  • Products
  • Themes
  • Tools
  • Request for Quote

Vengala Vinay

Having 9+ Years of Experience in Software Development

  • Home
  • WordPress
  • PHP
    • Codeigniter
  • Django
  • Magento
  • Selenium
  • Server
Home » Automating Apache Domain Management on Ubuntu: A Guide to Provisioning & Security

Automating Apache Domain Management on Ubuntu: A Guide to Provisioning & Security

Managing multiple domains on an Ubuntu server can quickly become a repetitive and error-prone task. From creating system users to configuring Apache VirtualHosts and securing MySQL databases, the manual overhead is significant. This suite of professional Bash utilities simplifies and automates the entire process, ensuring every new site is fast, isolated, and secure by default.

 

1. Zero-Touch Domain Provisioning

The core of this suite is add_domain.sh. It doesn’t just create an Apache config; it provisions a complete environment:

  • System Isolation: Every domain gets a dedicated system user and a public_html directory with 750 permissions.
  • Multi-PHP Support: Built-in PHP-FPM integration with automatic version discovery (7.4 to 8.3+).
  • Secure Credentials: Random 16-character passwords generated via OpenSSL for both system and database users.
  • Automated SSL-Ready Configs: Generates VirtualHost files tailored for PHP, WordPress, Python (WSGI), Ruby (Passenger), and even Docker proxies.
# Provision a new WordPress site with PHP 8.2
sudo ./add_domain.sh my-new-site.com --type=wordpress --php=8.2

2. Advanced Site Cloning & Duplication

Ever needed to create a staging environment in seconds? clone_domain.sh is a massive time-saver. It performs a “Deep Clone” of an existing site:

  • Copies the filesystem and synchronizes the MySQL database.
  • Recursive Find-Replace: Automatically updates the domain name and credentials across all files and database dumps.
  • Integrated Setup: Leverages the primary provisioning logic to ensure the clone is just as secure as the original.

3. Security & DevOps Features

Beyond setup, these scripts prioritize long-term server health and security:

  • Security Headers: Every site is automatically hardened with X-Content-Type-Options: nosniff, X-Frame-Options: SAMEORIGIN, and restricted access to sensitive files (.git, .env).
  • Git Sync & Webhooks: Set up automated deployments with GitHub/GitLab webhooks. Trigger pulls automatically on push without manual SSH intervention.
  • Credential Rotation: Use rotate_passwords.sh to instantly update system and DB credentials for any domain in the system.
  • Centralized Audit Logging: Every event is logged to /var/log/apache_setup_audit.log, providing a clear trail of all server modifications.

Getting Started

You can find the full source code and documentation for these utilities on GitHub. Feel free to contribute or fork the project to fit your specific server architecture.

Requirements: Ubuntu/Debian, Apache2, MySQL/MariaDB, and OpenSSL.

Optimize your workflow and secure your server today.

Primary Sidebar

A little about the Author

Having 9+ Years of Experience in Software Development.
Expertised in Php Development, WordPress Custom Theme Development (From scratch using underscores or Genesis Framework or using any blank theme or Premium Theme), Custom Plugin Development. Hands on Experience on 3rd Party Php Extension like Chilkat, nSoftware.

Recent Posts

  • Automating Apache Domain Management on Ubuntu: A Guide to Provisioning & Security
  • Debugging a 150k-Request 404 Storm: How I Saved My WordPress Server from High Load
  • How to Host 40+ Sites on a Single 32GB RAM Server (Without the “Lag”)
  • Enforcing Search Engine De-Indexing in WordPress Using an Application-Level Plugin
  • How to Migrate Users Between Sites in WordPress Multisite (One-Time Task)

Copyright © 2026 · Vinay Vengala