DEV Community

Morodolu Oluwafikunayomi
Morodolu Oluwafikunayomi

Posted on

The Fastest Way to Deploy Any Website Template on CentOS (After SSH)

This is part 2 to my previous post, you know that feeling when you finally SSH into your VirtualBox or Vagrant box, and now you have to set up a whole website manually?
Install this, unzip that, copy files, restart Apache, fix permissions… rinse and repeat.
Yeah, we’re not doing that today.
Instead, I’ll show you how to automate the entire process

What You’ll Need

Before we dive in, make sure you’ve got the basics ready:

  • You’ve already SSH’d into your CentOS box, for example:
 vagrant ssh

Enter fullscreen mode Exit fullscreen mode
  • You’re inside your working directory (I’ll use /home/vagrant/server for this tutorial).

  • Apache is installed and running. If not, quickly do:

sudo yum install httpd -y
 sudo systemctl enable httpd
sudo systemctl start httpd

Enter fullscreen mode Exit fullscreen mode

That’s it let’s automate the rest.
Step 1: Create the Script
Once you’re inside your SSH terminal, move into your server folder and create a script file:

cd ~/server
touch scripting.sh
chmod +x scripting.sh
vi scripting.sh
Enter fullscreen mode Exit fullscreen mode

If vi doesn’t work, you can use nano or even cat > scripting.sh.

Step 2: The Automation Script

#!/bin/bash

echo "Installing wget and unzip..."
sudo yum install wget unzip -y

# Ask the user for a template URL
read -p "Enter the URL of your website template (.zip): " TEMPLATE_URL

echo "Downloading your template..."
wget $TEMPLATE_URL -O website_template.zip

echo "Extracting website files..."
unzip -o website_template.zip -d ~/server/

# Automatically detect extracted folder
EXTRACTED_DIR=$(find ~/server -maxdepth 1 -type d -name "templatemo*" -o -name "html*" | head -n 1)

if [ -z "$EXTRACTED_DIR" ]; then
  echo "❌ Could not find extracted folder. Please check manually."
  exit 1
fi

echo "Deploying files to /var/www/html..."
sudo cp -r $EXTRACTED_DIR/* /var/www/html/

echo "Restarting Apache..."
sudo systemctl restart httpd
sudo systemctl enable httpd

IP=$(hostname -I | awk '{print $1}')
echo "✅ Done! Visit your site at: http://$IP/"
Enter fullscreen mode Exit fullscreen mode

Save and exit (in vi, that’s ESC + :wq).

Step 3: Run It
Now run your shiny new automation script:

./scripting.sh
Enter fullscreen mode Exit fullscreen mode

It’ll ask you for a template URL — just paste in one of these:

Example Template URLs

  • Templatemo 3D Coverflow
  • BootstrapMade Arsha Template
  • HTML5UP Phantom Template
  • Or grab any .zip link from your favorite site:
  • https://templatemo.com
  • https://bootstrapmade.com
  • https://html5up.net
  • Once the script runs, it’ll:
  • Install missing tools
  • Download your zip file
  • Unzip it into your server folder
  • Copy everything into /var/www/html/
  • Restart Apache
  • And show your local IP

In short — it does all the boring stuff for you.

After it finishes, you’ll see something like this:
Done! Visit your site at: http://192.168.33.10/

Top comments (0)