Setting up WordPress Multisite on Debian 5.0 (lenny)

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 πŸ˜€

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 πŸ™‚

Comments Posted in English posts, Informatica, Linux
Tagged , , , , , , , ,

Comments

  1. Amado says:

    Very descriptive blog, I liked that bit.
    Will there be a part 2?

    Also visit mmy weblog – female weight loss; Amado,

  2. In fact no matter if someone doesn’t be aware of then its up to other viewers that they will help, so here it takes
    place.

  3. Keesha says:

    These are truly great ideas in oon the topic of blogging.
    You hafe touched some fastidious things here. Any way keep up wrinting.

  4. Hi there very nice site!! Man .. Beautiful .. Wonderful ..
    I’ll bookmark your site and take the feeds also? I am satisfied to find a lot of helpful
    information here within the put up, we’d like develop extra strategies on this regard, thanks for sharing.
    . . . . .

  5. Excellent, what a website it is! This website gives useful data to us, keep it up.

  6. Santo says:

    Using the proper toothbrush is critical to good brushing.
    – Beware of the words caution, warning, and danger.
    This will help give the area a good soak for easier cleanup and also sop up any water that pools there as you clean.

  7. I must express some thanks to this writer just for bailing me out of such
    a issue. Right after browsing throughout the search
    engines and obtaining ideas which are not helpful,
    I figured my life was over. Living minus the strategies to the problems you’ve fixed through your site
    is a critical case, as well as the kind that
    might have adversely affected my entire career if I hadn’t discovered your blog.

    Your own personal know-how and kindness in controlling a lot of
    stuff was very useful. I’m not sure what I would have done if I had not discovered
    such a stuff like this. I can also at this time look
    forward to my future. Thanks so much for the professional and sensible guide.
    I won’t think twice to suggest your web site to anybody
    who wants and needs care about this topic.

    My webpage: bruce lee workouts (everydaypeoplestories.com)

  8. BalΓ‘zs says:

    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

  9. pallotron says:

    πŸ˜€ You’re welcome.

  10. TopGun says:

    @pallotron
    No, I’m not a perfectionist at all, it was just a noob curiosity. πŸ˜€
    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.

  11. pallotron says:

    How perfectionist are you πŸ˜›
    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.

  12. TopGun says:

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