Shell script that will create unlimited virtual website on one single ip
on Debian/Ubuntu (There is another for Red Hat , CentOs and Fedora.)
#!/bin/bash
clear
echo "THIS SCRIPT IS FOR PORT BASED APACHE VIRTUAL WEBSITES. MAKE UNLIMITED ON ONE SINGLE IP"
read -p "We will run this script as root . press Enter to proceed..."
if [ $UID -eq 0 ]
then
echo "Lets see Apache is installed in your system or not...";sleep 2
apt-get install rpm
rpm -q apache 1>/dev/null
if [ $? -eq 0 ]
then
echo "Apache present . Now give me the port no you want to run your website on "; read q
echo "Setting up port for you...."; sleep 2
echo "Listen $q" >> /etc/apache2/port.conf
echo "Creating $q root file..." sleep 2
echo "<VirtualHost *:$q>
ServerAdmin webmaster@local
DocumentRoot /var/www/html/$q
</VirtualHost>" > /etc/httpd/conf.d/"$q"
echo "Creating Document ... " ; sleep 2
mkdir -p /var/www/html/$q
cd /var/www/html/$q
echo "Its $q, welcome to my website" > index.html
clear
echo "Your first website just built . If you want to make more website just do $0\nNow we will try to visit your wesite usig firefox" ;sleep 4
rpm -q firefox && firefox 127.0.0.1:$q || echo "firefox is not installed"
else
echo "Apache is not installed here on your machine . type "apt-get install apache" to install."
fi
else
echo "You are not root . Try login as root and do $0"
fi
#!/bin/bash
clear
echo "THIS SCRIPT IS FOR PORT BASED APACHE VIRTUAL WEBSITES. MAKE UNLIMITED ON ONE SINGLE IP"
read -p "We will run this script as root . press Enter to proceed..."
if [ $UID -eq 0 ]
then
echo "Lets see Apache is installed in your system or not...";sleep 2
apt-get install rpm
rpm -q apache 1>/dev/null
if [ $? -eq 0 ]
then
echo "Apache present . Now give me the port no you want to run your website on "; read q
echo "Setting up port for you...."; sleep 2
echo "Listen $q" >> /etc/apache2/port.conf
echo "Creating $q root file..." sleep 2
echo "<VirtualHost *:$q>
ServerAdmin webmaster@local
DocumentRoot /var/www/html/$q
</VirtualHost>" > /etc/httpd/conf.d/"$q"
echo "Creating Document ... " ; sleep 2
mkdir -p /var/www/html/$q
cd /var/www/html/$q
echo "Its $q, welcome to my website" > index.html
clear
echo "Your first website just built . If you want to make more website just do $0\nNow we will try to visit your wesite usig firefox" ;sleep 4
rpm -q firefox && firefox 127.0.0.1:$q || echo "firefox is not installed"
else
echo "Apache is not installed here on your machine . type "apt-get install apache" to install."
fi
else
echo "You are not root . Try login as root and do $0"
fi