Register
It is currently Fri Oct 24, 2014 1:47 am

automatic vhosts


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Feb 17, 2012 2:48 am   

Joined: Fri Feb 17, 2012 2:37 am
Posts: 1
hi... i'm trying to learn how to make a webhosting server on a virtual machine with ftpd, httpd, dns, vhosts and etc...

i want somehow to make a script to automaticaly make a new virtual host in apache and to add a new line in the dns.zone
i'm thinking to read some users from a data base, or some directories from /var/www, save them to a variable and play with it...
i don;t know how to make that reading and save it to a variable...and use only the new entry...
I somebody understand what i'm willing to do and has an answer. thank you!


Top
 Profile  
 PostPosted: Tue Feb 21, 2012 3:46 pm   

Joined: Tue Feb 21, 2012 3:07 pm
Posts: 2
I'm not exactly sure if this is what you're looking for, or exactly what all you're trying to attempt. The best bet I think is to have a vhost template somewhere that you can use sed against. Use blah.com as the ServerName in the vhost template and wherever it would be specific to a new host, and the datestring if you wanted the date it was created. This isn't tested, but should get you going in the right direction if you truly only want to create a vhost.

Code:
#!/bin/bash

CREATEDATE=`date +%F`
# Prompt user URL
echo ""
printf "Enter the URL: "
read prod
SITENAME=$prod


                echo ""
                echo "Setting up Apache VHOST..."
               
                VHOSTNAME="/etc/httpd/conf.d/vhost/$SITENAME"   
                if [ -e "$VHOSTNAME" ]; then
                        echo ""
                        echo "VHOST file already exists"
                else   
                        echo "Setting up VHOST for $SITENAME"
                        cp /var/www/vhost/vhosttemplate /etc/httpd/conf.d/vhost/$SITENAME.conf
                        sed -i "s/blah.com/$SITENAME/g" /etc/httpd/conf.d/vhost/$SITENAME.conf
                        sed -i "s/datestring/$CREATEDATE/g" /etc/httpd/conf.d/vhost/$SITENAME.conf
                        HTTPDRESTART=1
                fi

               if [ "$HTTPDRESTART" = 1 ]; then
                        echo "Reloading Apache"
                        /etc/init.d/httpd reload
               fi



Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP