Automate Virtual Hosts creation
Archived
Written in March 2013. Kept as it was, so versions, links and details may be out of date.
These tools will help in never having to manually add virtual hosts to your Apache server. Well, maybe not ever, but they will be able to create your virtual hosts in most cases.
These tools need to be run on the server you are trying to setup the vhosts on. It will autodetective your Linux distribution and work accordingly.
bash <( curl -H 'x-docroot: /var/www/vhosts/example.com' -H 'x-port: 80' -H 'host: example.com' justcurl.com )You can set the DocumentRoot, port and ServerName in the options. You can also use this to automagically install Wordpress, but it’s still in testing so use with caution.
bash <( curl -H 'x-docroot: /var/www/vhosts/example.com' -H 'x-port: 80' -H 'x-install: wordpress' -H 'host: example.com' justcurl.com )This is basically the same tool but executed a little differently. There is an excellent post on community.rackspace.com that covers usage. First run this to include all .conf files and create the vhost.d directory in CentOS/RHEL.
echo "Include vhost.d/*.conf" >> /etc/httpd/conf/httpd.conf && mkdir /etc/httpd/vhost.dCentOS/RHEL
curl $DOMAIN.c.jonsjava.com | bashDebian/Ubuntu
curl $DOMAIN.u.jonsjava.com | bashWhere $DOMAIN is your virtual host you’re trying to create.
curl example.com.c.jonsjava.com | bash