March 24, 2013 · LAMP

Automate Virtual Hosts creation

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/' -H 'x-port: 80' -H 'host:' )

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/' -H 'x-port: 80' -H 'x-install: wordpress' -H 'host:' )

This is basically the same tool but executed a little differently. There is an excellent post on 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.d


curl $ | bash


curl $ | bash

Where $DOMAIN is your virtual host you're trying to create.

curl | bash

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pinterest
  • Pocket
Comments powered by Disqus