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

Vengala Vinay

Having 12+ 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 12+ Years of Experience in Software Development, Vinay is a principal software architect, senior systems engineer, and elite technical consultant. He specializes in bespoke PHP/WordPress development, high-performance Magento 2 & Shopify architectures, custom plugin/theme development from scratch, and legacy code modernization (including VB6, VB.NET, PyQt, and Crystal Reports). Known for solving complex database bottlenecks, speed optimization (Core Web Vitals), and advanced security code auditing, Vinay engineers production-ready systems designed to scale under heavy concurrent load conditions.



Chat on WhatsApp

Recent Posts

  • Install PHP 5.6 , Mysql , phpMyAdmin, Apache Server using XAMPP 5.6.40
  • Creating your first plugin
  • Implementing automated compliance reporting for custom member profile directories ledgers using native PHP ZipArchive streams
  • Performance Optimization: Tuning PHP-FPM and opcache pools for high-concurrency Twilio SMS Gateway handlers
  • Advanced Diagnostics: Locating slow Active Record Wrapper query bottlenecks in WooCommerce custom checkout pipelines

Categories

  • apache (1)
  • Business & Monetization (390)
  • Centos (4)
  • Comparisons & Decision Making (55)
  • Debian (2)
  • Debugging & Troubleshooting (663)
  • Desktop Applications (14)
  • DevOps (7)
  • DevOps & Cloud Scaling (962)
  • Django (1)
  • Laravel (4)
  • Migration & Architecture (192)
  • Mobile Applications (24)
  • MySQL (1)
  • Performance & Optimization (873)
  • PHP (5)
  • PHP Development (49)
  • Plugins & Themes (244)
  • Programming Languages (10)
  • Python (20)
  • Ruby on Rails (1)
  • Security & Compliance (650)
  • SEO & Growth (492)
  • Server (118)
  • Softwares (1)
  • Ubuntu (9)
  • VB6 & VB.NET (8)
  • Web Applications & Frontend (19)
  • Web Assembly (Wasm) (2)
  • WordPress (22)
  • WordPress Plugin Development (728)
  • WordPress Theme Development (357)

Recent Posts

  • Install PHP 5.6 , Mysql , phpMyAdmin, Apache Server using XAMPP 5.6.40
  • Creating your first plugin
  • Implementing automated compliance reporting for custom member profile directories ledgers using native PHP ZipArchive streams

Top Categories

  • DevOps & Cloud Scaling (962)
  • Performance & Optimization (873)
  • WordPress Plugin Development (728)
  • Debugging & Troubleshooting (663)
  • Security & Compliance (650)
  • SEO & Growth (492)

Our Products

  • ERP & LMS Systems (4)
  • Directories & Marketplaces (4)
  • Healthcare Portals (3)
  • Point of Sale (POS) (2)
  • E-Commerce Engines (2)

Our Services

  • E-Commerce Development (10)
  • WordPress Development (8)
  • Python & Desktop GUI (7)
  • General Consulting (7)
  • Legacy Modernization (5)
  • Mobile App Development (4)

Copyright © 2026 · Vinay Vengala