WordPress debian multisite

Before I forget, or kill some one next time I have to do this, I had better write it down.

WordPress supports multisite out of the box these days, but Debian supported it long ago and to be honest I would rather use a Debian security team version of wordpress to get my automatic updates and security fixes along with the rest of the server security rather than having to manually mess about unpacking multiple tarballs to update multiple wordpress sites

to install wordpress on a clean system

apt-get install wordpress mysql-server

Yep wordpress only recommends mysql-server so you need to add mysql-server too.

By default the Debian magic scripts will work with data in /srv/www, I did not want this. I wanted my data under /var/www/wordpress/

The two files

/usr/share/doc/wordpress/examples/apache.conf
/usr/share/doc/wordpress/examples/setup-mysql.gz

are your friends here, the first one are some example apache confs to make the multisite magic work the second is a quick way to setup an empty wordpress site and to create the mysql user, the config and the folder structure needed.

Before you do that, enable some apache modules to let the magic work, you need vhost_alias and rewrite as a minimum

a2enmod vhost_alias rewrite

Next copy the setup-mysql script, unpack it and mod it to the required folder structure :-

cd ~
cp /usr/share/doc/wordpress/examples/setup-mysql.gz ~/
gzip -d setup-mysql.gz
sed -i 's/\/srv\/www\//\/var\/www\/wordpress\//g' setup-mysql
chmod +x setup-mysql
./setup-mysql -n databaseuser name.of.site.com

where databaseuser is the name you want to use for mysql access (account will be created and all set up) and name.of.site.com will be the the physical name used in the /var/www/wordpress/ folder to keep the sites separate.

Now the final thing to do is to configure apache

What you probably want to do is create a new default virtual host that will grab any requests and handle them BUT do this as a lower priority to any static sites you may have. So create a new file in /etc/apache2/sites-available/50-wordpress with the following content :-

## Virtual host VirtualDocumentRoot

        NameVirtualHost *:80

        
        UseCanonicalName Off
        VirtualDocumentRoot /usr/share/wordpress
        Options All

        # wp-content in /srv/www/wp-content/$0
        RewriteEngine On
        RewriteRule ^/wp-content/(.*)$ /var/www/wordpress/%{HTTP_HOST}/$1
        

Which is pretty much the first example in /usr/share/doc/wordpress/examples/apache.conf with my folder locations tweaked as I like them.

then enable the site

a2ensite 50-wordpress

You will with this setup also want to remove the default

 a2dissite default 

Then if you need to add any static sites in the future add them as regular vhosts with site names starting with numbers less that 50- then they will take priority. If no static matches are found it will try to dynamicly match via the wordpress configuration. If this fails you will get a ungraceful message from the debian wp-config.php file but I’m not really bothered about that at this stage.

and finally don’t forget to restart the web server

service apache2 restart

Only 1 comment left Go To Comment

  1. Pingback: VPS / (Personnal) Virtual Server mini HowTo | HomePage Emmanuel /

Leave a Reply