Apache Virtual Host configuration for a Networked WordPress Installation

Direct any URL request that Apache receives to the WordPress installation. You need to do it if you are setting up a WordPress Network multi-site installation that has sites with their own unique domain names. e.g. site1.org, site2.com, someothersite.co.uk etc.

/etc/apache2/sites-enabled$ ls -al
total 8
drwxr-xr-x 2 root root 4096 Jul 25 13:18 .
drwxr-xr-x 7 root root 4096 Jul 24 12:28 ..
lrwxrwxrwx 1 root root 40 Jul 24 12:06 000-wordpress-network-ssl -> ../sites-available/wordpress-network-ssl
lrwxrwxrwx 1 root root 36 Jul 24 12:02 010-wordpress-network -> ../sites-available/wordpress-network

Order of the files is very important. wordpress-network contents below:

<VirtualHost *:80>
UseCanonicalName Off

ServerAlias *.examplehost.com examplehost.com
ServerName examplehost.com
DocumentRoot /var/www

Options All
ServerAdmin myname@examplehost.com

# Store uploads of www.domain.com in /srv/www/wp-uploads/$0
RewriteEngine On
RewriteRule ^/wp-uploads/(.*)$ /var/www/wp-uploads/%{HTTP_HOST}/$1

# try and make server-status return server status
#RewriteRule ^/server-status - [L]
RewriteCond %{REQUEST_URI} !=/server-status
<Location /server-status>
SetHandler server-status

Order Deny,Allow
# Deny from all
# Allow from localhost
Allow from all
<Directory />
Options FollowSymLinks
AllowOverride All
CustomLog /var/log/apache2/access.log vhost_combined
ErrorLog /var/log/apache2/error.log

# this is needed when activating multisite, WP needs to to a
# fopen("http://randomname.domain.com") to verify
# that apache is correctly configured
php_admin_flag allow_url_fopen on


Join the Conversation


Leave a comment

Your email address will not be published. Required fields are marked *