Use this BASH script to quickly enable all Apache virtual host configurations.
THis can be handy if for example you are setting up a new development environment.
Background: Enabling Virtual Hosts in Apache 2.4
To set up Apache 2.4 virtual host configurations under Debian/Ubuntu you add a configuration file with a
<VirtualHost> block in the
Such config files must have the
.conf file extension.
To enable the site, you need to run the
a2ensite script, passing the config filename as an argument. This creates a symlink to the config file in the
/etc/apache2/sites-enabled directory. You then need to reload Apache.
The following script loops through all config files in
/etc/apache2/sites-available and runs
a2ensite. There’s no problem if any site is already enabled, since this does not result in an error.
Copy across the contents of
/etc/apache2/sites-available from the old environment to the new (e.g. with rsync).
Download and run the above script:
/etc/hosts from the old environment to the new.
comments powered by Disqus