Apache Virtual Hosts allows multiple sites to be hosted on a single server/VPS.
These guidelines are for configuration of virtual hosts on Apache 2.4.
Create Directory Structure
The -p flag creates intermediate directories as required.
Note WordPress is going to need the www-data to have ownership of the public_html subdirectories to allow file upload etc. - for the time being, give ownership to the current user - pass ownership to www-data later.
Set Permissions to 755 for directories:
Add index.html demo pages if necessary.
Create Config Files
Create a config file for each site:
Use this as a template:
This config block sets the correct server name, alias and document root. Directory browsing is disallowed, and .htaccess files are allowed.
Site specific error reporting is added - log files are located here:
Enable the site using
a2ensiteand restart Apache:
Enable Apache Rewrites
Enabling the Apache rewrite module will be essential it you’re using pretty permalinks. Enable the module & restart Apache:
Set Up Permanent Redirect
Configure a new Virtual Host on the server to intercept requests for the old domain, and permanently redirect them to the new domain:
comments powered by Disqus