<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Shuvo</title>
    <description>The latest articles on DEV Community by Shuvo (@shuvo_h).</description>
    <link>https://dev.to/shuvo_h</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3913629%2F7822843a-d866-4088-8d8e-5cfd5f89895f.png</url>
      <title>DEV Community: Shuvo</title>
      <link>https://dev.to/shuvo_h</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shuvo_h"/>
    <language>en</language>
    <item>
      <title>Automate Apache/Nginx Virtual Server host in Seconds.</title>
      <dc:creator>Shuvo</dc:creator>
      <pubDate>Tue, 05 May 2026 09:56:12 +0000</pubDate>
      <link>https://dev.to/shuvo_h/automate-apachenginx-virtual-server-host-in-seconds-1iak</link>
      <guid>https://dev.to/shuvo_h/automate-apachenginx-virtual-server-host-in-seconds-1iak</guid>
      <description>&lt;p&gt;🚀 Automate Apache/Nginx Virtual Hosts in Seconds (No More Manual Setup!)&lt;/p&gt;

&lt;p&gt;If you're a System engineer/Administrator working with local/production servers, you already know the pain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create project folder&lt;/li&gt;
&lt;li&gt;Write Apache/Nginx config&lt;/li&gt;
&lt;li&gt;Edit &lt;code&gt;/etc/hosts&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Enable site&lt;/li&gt;
&lt;li&gt;Restart server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Repeat. Again. And again.&lt;/p&gt;

&lt;p&gt;It’s boring, error-prone, and honestly… a waste of time.&lt;/p&gt;

&lt;p&gt;That’s exactly why I built &lt;strong&gt;VirtualHost Automation&lt;/strong&gt; — a simple script to automate the entire workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡ Why Automate Virtual Hosts?
&lt;/h2&gt;

&lt;p&gt;Setting up virtual hosts manually involves multiple steps like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating directories under &lt;code&gt;/var/www&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Writing &lt;code&gt;.conf&lt;/code&gt; files inside &lt;code&gt;/etc/apache2/sites-available&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Editing system host files&lt;/li&gt;
&lt;li&gt;Reloading Apache&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These steps are repetitive and can easily break if you miss something. Many developers solve this with shell scripts that handle everything in one go. ([DEV Community][1])&lt;/p&gt;

&lt;p&gt;⚡ The goal: &lt;strong&gt;one command = fully working virtual host&lt;/strong&gt;&lt;br&gt;
I created this:&lt;/p&gt;
&lt;h2&gt;
  
  
  👉 &lt;a href="https://github.com/shuvo-halder/virtualhost-automation" rel="noopener noreferrer"&gt;https://github.com/shuvo-halder/virtualhost-automation&lt;/a&gt;
&lt;/h2&gt;
&lt;h2&gt;
  
  
  🧠 What This Project Does
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/shuvo-halder/virtualhost-automation" rel="noopener noreferrer"&gt;virtualhost-automation&lt;/a&gt; script automates:&lt;/p&gt;

&lt;p&gt;✅ Virtual host creation&lt;br&gt;
✅ Apache configuration setup&lt;br&gt;
✅ Host file entry&lt;br&gt;
✅ Directory initialization&lt;br&gt;
✅ Server reload&lt;/p&gt;

&lt;p&gt;Instead of doing 6–7 manual steps, you just run one command.&lt;/p&gt;


&lt;h2&gt;
  
  
  🛠️ How It Works (Apache server behind the Scenes)
&lt;/h2&gt;

&lt;p&gt;At a high level, the script follows a typical automation flow:&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Take Input
&lt;/h3&gt;

&lt;p&gt;You provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Site name (e.g. &lt;code&gt;project.dev&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;IP or host mapping&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  2. Create Project Structure
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Generates &lt;code&gt;/var/www/project.dev&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Adds a default index file (optional)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  3. Generate Apache Config
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Copies template config&lt;/li&gt;
&lt;li&gt;Replaces variables dynamically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is usually done using tools like &lt;code&gt;sed&lt;/code&gt; for string replacement. ([DEV Community][1])&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Update &lt;code&gt;/etc/hosts&lt;/code&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Maps domain → local IP&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  5. Enable Site + Reload Apache
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Runs &lt;code&gt;a2ensite&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reloads Apache instantly&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🔥 Example Workflow
&lt;/h2&gt;

&lt;p&gt;Instead of doing all this manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; /var/www/project.dev
nano /etc/apache2/sites-available/project.dev.conf
nano /etc/hosts
a2ensite project.dev.conf
systemctl reload apache2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You just run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./virtualhost.sh project.dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boom. Done. 🎯&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Why This Matters
&lt;/h2&gt;

&lt;p&gt;Automation isn’t just about saving time — it improves consistency and reduces mistakes.&lt;/p&gt;

&lt;p&gt;Many modern dev environments rely on automation tools because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manual setup doesn’t scale&lt;/li&gt;
&lt;li&gt;DevOps workflows demand speed&lt;/li&gt;
&lt;li&gt;Reproducibility is critical&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even popular tools and scripts in the ecosystem aim to solve the same problem — simplifying virtual host creation with a single command. ([Libraries.io][2])&lt;/p&gt;




&lt;h2&gt;
  
  
  🧪 Use Cases
&lt;/h2&gt;

&lt;p&gt;This project is especially useful if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Build multiple local projects&lt;/li&gt;
&lt;li&gt;Work with Laravel / PHP / Node apps&lt;/li&gt;
&lt;li&gt;Frequently test domains locally&lt;/li&gt;
&lt;li&gt;Manage multiple dev/prod environments&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🧾 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Virtual host setup shouldn’t slow you down.&lt;/p&gt;

&lt;p&gt;With tools like virtualhost-automation, you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Save time&lt;/li&gt;
&lt;li&gt;Reduce errors&lt;/li&gt;
&lt;li&gt;Focus on actual development&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Automation is not optional anymore — it’s a necessity.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⭐ Check Out the Repo
&lt;/h2&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/shuvo-halder/virtualhost-automation" rel="noopener noreferrer"&gt;https://github.com/shuvo-halder/virtualhost-automation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this helps your workflow, give it a star ⭐&lt;br&gt;
and feel free to contribute or customize it for your setup.&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>automation</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
