It is currently Wed May 23, 2018 2:20 pm

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
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!

 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 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.


# Prompt user URL
echo ""
printf "Enter the URL: "
read prod

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

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

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: No registered users and 11 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:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group