Shell script that will create unlimited virtual website on one single ip on Red Hat , CentOs and Fedora. (There will be another for Ubuntu)
#!/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 HTTPD is installed in your system or not...";sleep 2
rpm -q httpd 1>/dev/null
if [ $? -eq 0 ]
then
echo "HTTPD 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/httpd/conf/httpd.conf
semanage port -m -t http_port_t -p tcp $q
iptables -I INPUT -p tcp --dport $q -j ACCEPT
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 "HTTPD is not installed here on your machine . type "yum insatall httpd" 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 HTTPD is installed in your system or not...";sleep 2
rpm -q httpd 1>/dev/null
if [ $? -eq 0 ]
then
echo "HTTPD 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/httpd/conf/httpd.conf
semanage port -m -t http_port_t -p tcp $q
iptables -I INPUT -p tcp --dport $q -j ACCEPT
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 "HTTPD is not installed here on your machine . type "yum insatall httpd" to install."
fi
else
echo "You are not root . Try login as root and do $0"
fi
No comments:
Post a Comment