Setting up WordPress Multisite on Debian 5.0 (lenny)

in English posts, Informatica, Linux

This post explains how to install WordPress 3.x on a Debian lenny and to set up a multisite installation on your Debian server.

All the blogs will log into the same file /var/log/apache2/access.log; the first column will be the blog host and port (see the LogFormat configured below).

This chapter is based on information collected at http://codex.wordpress.org/Create_A_Network and in /usr/share/doc/wordpress/README.Debian.

All WordPress blogs will use the same shared PHP code in /usr/share/wordpress.

Assumptions

  • Main website will be http://domain.com
  • Blogs will be under http://${blogname}.domain.com

File uploaded into the main blog (www.domain.com) will be stored in /srv/www/wp-uploads/domain.com/%year/%month/

Files uploaded into the *.domain.com blogs will be stored in /usr/share/wordpress/wp-content/blogs.dir/${blog_id}/files/%year/%month/, where ${blog_id} is the numeric id of the blog, as managed by the Multisite feature.

Configuration of Debian lenny-backports repository and installation

WordPress 3.x is not in lenny so we have to use the backport repository.
Excute this as root:

echo "deb http://backports.debian.org/debian-backports lenny-backports main" >> /etc/apt/sources.list
 
cat <<EOF > /etc/apt/preferences
Package: *
Pin: release a=lenny-backports
Pin-Priority: 200
EOF
 
apt-get update
apt-get -t lenny-backports install wordpress

Installation of non free swf plugin

As stated in /usr/share/doc/wordpress/README.Debian WordPress originally comes with a Flash-based tool that allows to upload files. However, that tool violates the Debian Policy, as stated in the
bug #591195. That is why this tool is not shipped with the Debian package anymore. If you want to enable this feature, you need to install the Flash file yourself with the following command:

wget -O /usr/share/wordpress/wp-includes/js/swfupload/swfupload.swf http://core.svn.wordpress.org/branches/3.0/wp-includes/js/swfupload/swfupload.swf

Configure your DNS server

Add the following records in your zone (I suppose you know how to deal with your DNS zone):

; wp multisite
$ORIGIN        IN A       ${IP}
www            IN A       ${IP}
*.domain.com.  IN CNAME   www

Apache configuration

Configure the vhost_combined log format in /etc/apache2/apache2.conf modifying the default one:

LogFormat "%{Host}i:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined

Configure apache in /etc/apache2/sites-available/wordpress-multisite :

<VirtualHost *:80>
UseCanonicalName    Off
 
ServerAlias *.domain.com domain.com
ServerName www.domain.com
DocumentRoot /srv/www/domain.com/
 
Options All
ServerAdmin you@domain.com
 
# Store uploads of www.domain.com in /srv/www/wp-uploads/$0
RewriteEngine On
RewriteRule ^/wp-uploads/(.*)$ /srv/www/wp-uploads/%{HTTP_HOST}/$1
 
<Directory />
        Options FollowSymLinks
        AllowOverride All
</Directory>
 
CustomLog /var/log/apache2/access.log vhost_combined
 
# 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
 
</VirtualHost>

Configure /etc/wordpress/htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
## uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
## real files dealt directly
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
## other go through index.php
RewriteRule . index.php [L]
</IfModule>

Enable the config executing this as root:

a2ensite wordpress-multisite
a2enmod rewrite && a2enmod vhost_alias
/etc/init.d/apache2 restart

Setting some permissions

# required to allow the main site to upload content
chown www-data /srv/
chown www-data /srv/www/
 
# required to allow subdomains site to upload content
chgrp www-data /usr/share/wordpress/wp-content/blogs.dir/
chmod g+w /usr/share/wordpress/wp-content/blogs.dir/
 
# required in order to be able to install/update themes/plugins 
# from the webgui (only on the main site)
chown -R www-data:www-data /usr/share/wordpress/wp-content/
chown -R www-data:www-data /usr/share/wordpress/wp-admin/

Creating main site

At this stage we can create the main site using this bash script:

bash /usr/share/doc/wordpress/examples/setup-mysql -n main domain.com

This script creates the DB & tables and it also creates a file called /etc/wordpress/config-domain.com.php.

You should end up with the following files:

  • /etc/wordpress/config-domain.com.php
  • /srv/www/domain.com symlink to -> /usr/share/wordpress
  • /srv/www/wp-uploads/domain.com/

Activating Network (aka multisite)

At this stage you should log into http://domain.com and follow the on screen instructions.
Once you are in the backend you can than click into the “Tools -> Network” link and enable the mulsite, this will create some tables in your db and it will ask you to copy&paste some lines into /etc/wordpress/config-domain.com.php:

define( 'SUBDOMAIN_INSTALL', true );
$base = '/';
define( 'DOMAIN_CURRENT_SITE', 'domain.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
 
define( 'AUTH_KEY', 'blabla' );
define( 'SECURE_AUTH_KEY', 'blabla' );
define( 'LOGGED_IN_KEY', 'blabla' );
define( 'NONCE_KEY', 'blabla' );
define( 'AUTH_SALT', 'blabla' );
define( 'SECURE_AUTH_SALT', 'blabla' );
define( 'LOGGED_IN_SALT', 'blabla' );
define( 'NONCE_SALT', 'blabla' );
 
define( 'MULTISITE', true );
 
# for debugging purposes only
# define('WP_DEBUG', true);

After that you’re ready to go :D

Logging as super admin and going into the SuperAdmin webgui area you can create new subdomains (blogs), and users, when you can create blogs an email is sent to the owner, you can personalize templates, decide how much storage space you want to assign to every single blog, etc, etc.

At this point you should be able to also install/upgrade plugins and themes straight from the web gui.
Note that define('WP_CORE_UPDATE', false); in your config file will disable the auto update, your wordpress update cycle will be managed using Debian apt tool.

That’s it folks, any question please comment :)

Popularity: 4% [?]

Share
5 Comments

5 Comments

  1. Just a question.
    Why do you prefer apt-get to aptitude?
    What it gives you that aptitude cannot?

  2. How perfectionist are you :P
    No i do prefer aptitude, in fact most of the time I use aptitude in place of apt-get.
    They say it deals better with dependencies, and, in fact, it does.
    But for this instruction there should be no difference between apt-get install wordpress and aptitude install wordpress.
    apt-get just installed all the dependencies I needed.

  3. @pallotron
    No, I’m not a perfectionist at all, it was just a noob curiosity. :D
    As usual I’m just a little bit off topic (just a little…:P) and reading about this tutorial I well out to ask you about this.
    Googling I read about apt-get vs aptitude but having a sys admin that said “any question pleas comment” I profited to ask.

    The matter it is more clear now, thank you for your explanation.

  4. :D You’re welcome.

  5. Hi Pallotron,

    EXCELLENT walk-through!!! I managed to set up and my multisite WordPress installation in 10 minutes. One small comment: the setup-mysql script must be run BEFORE the permission are gonna be set, because the script will write the /srv/www directory.

    Anyway, very good job and thanks a lot again!

    Cheers

Leave a Reply

*

Using Gravatars in the comments - get your own and be recognized!

XHTML: These are some of the tags you can use: <a href=""> <b> <blockquote> <code> <em> <i> <strike> <strong>

  • Tags

  • Meta