Peter Hinchley

Installing a Standalone Instance of StatusNet as an Enterprise Microblogging Solution

Tagged: microblogging, apache, mysql

I was recently asked to deploy an enterprise microblogging service. There were two primary requirements: it needed to support typical "twitter-like" capabilities, such as direct messages, @ replies, hash tags, and search; and secondly, it needed to be free. I initially looked at JaikuEngine, an open-source microblogging platform hosted on Google App Engine. It's a great offering, easily configurable, and ships with a stylish web interface, but unfortunately it does not support search, and had to be discounted. After investigating other alternatives, I decided to use another open source solution named StatusNet (formerly known as Laconica). The product is developed in PHP and implements the OpenMicroBlogging standard.

In this article I will describe the steps you can follow to implement a self-hosted instance of StatusNet.

Let's assume you are hosting StatusNet on Windows 7 (the steps in this article apply equally well to Windows Vista, or even Windows Server 2003/2008) using WampServer, an integrated installation of Apache, MySQL and PHP, that is packaged for deployment under Windows. The first step is to download WampServer 2.0i (approx 15MB - includes Apache 2.2.11, MySQL 5.1.36 and PHP 5.3.0) and then work through the simple installation wizard. You will be prompted to enter an install location (C:\wamp), a default web browser (C:\Program Files\Internet Explorer\iexplore.exe), and PHP mail parameters (which you can either configure appropriately for your environment, or leave unchanged/unconfigured).

WampServer will start automatically at the completion of the installation, and be accessible via an icon in the system tray. You can test the installation, by opening a web browser and navigating to http://localhost/. You should see the WampServer home page.

The next step is to download PHP 5.2.3 as a WampServer add-on (approx 9MB). This is required because StatusNet is not fully compatible with PHP 5.3.0 (it does not correctly handle session state). Accept all default installation options, and when complete, to switch to the newly installed version, click the WampServer icon in the system tray, then select PHP, Version, and 5.2.10. Simple, eh? Well, not quite. You may then need to open php.ini (accessed again via the system tray icon), search for extension_dir, and if not set correctly (strangely, in my case, the PHP version was listed as 5.1.6), change it to:

extension_dir = "c:/wamp/bin/php/php5.2.3/ext/"

As it currently stands, the root password to MySQL is blank. To set the password, open a command prompt, change into C:\wamp\bin\mysql\mysql5.1.36\bin, and run the following command (replacing Passw0rd1 with an appropriately complex password of your choice):

mysqladmin -u root password Passw0rd1

We now need to inform phpMyAdmin (the web-based MySQL admin console) that we have changed the root password. We do this by opening C:\wamp\apps\phpmyadmin3.2.0.1\config.inc.php and changing the password property as shown below:

$cfg['Servers'][$i]['password'] = 'Passw0rd1';

Returning to our command prompt, enter the following command to create the MySQL database that will be used as the data store for StatusNet:

mysqladmin -u root --password=Passw0rd1 create statusnet

With the command command prompt still open, use the following command to open a MySQL session:

mysql --user=root --password=Passw0rd1

Now use the following command to create an account named statusnet with a password of Passw0rd1 that will be used to access the new statusnet database:

GRANT ALL on statusnet.* TO 'statusnet'@'localhost' IDENTIFIED BY 'Passw0rd1';

We are now ready to download and install StatusNet version 0.8.2 (approx 3.5MB). The download is in the form of a gzipped tar archive, which you can extract using a product like 7-Zip. Copy the extracted content (a folder name statusnet-0.8.2 to C:\wamp\wwww). Rename the copied folder to statusnet (i.e. C:\wamp\www\statusnet).

To ensure users of StatusNet can upload files and configure personal avatars, right click on the avatar, folder under C:\wamp\www\statusnet, select the Security tab, and grant the Users group Modify permissions. Repeat for the background and file folders.

Before we proceed any further, it's important to consider the URL that will be used to access StatusNet. I recommend creating an internal DNS entry that points to the computer on which you are installing the software. Let's assume you've decided to use a name of status.network, and hence will access the site as http://status.network/. Note: For the purposes of local testing, you can simply modify your hosts file instead of creating a DNS entry: edit C:\Windows\System32\drivers\etc\hosts and add the following to the bottom of the file:

127.0.0.1 status.network

At this point, the Apache web server you've configured has a document root of C:\wamp\wwww, and we've copied statusnet to C:\wamp\wwww\statusnet. This means the URL used to access StatusNet will be http://status.network/statusnet. To remove the statusnet folder from the URL it will be necessary to create an .htaccess file under C:\wamp\www that forces the web server to internally direct any requests for / to /statusnet/. Unfortunately it is not possible to create a file that begins with a period using Windows Explorer. To work around this limitation, open a command prompt, navigate to C:\wamp\www and enter the command copy con .htaccess and then press Enter. Anything you type from this point forward will be added to a file named .htaccess. Paste the following into the console window, then press Control-Z, and then Enter, to save and close the file:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^api statusnet/index.php%{REQUEST_URI} [L]
RewriteRule !^statusnet/ statusnet%{REQUEST_URI}
</IfModule>

The RewriteRules listed above require some explanation. The first rule tells Apache to rewrite any request for /api to /statusnet/index.php/api. This is necessary for two reasons. Firstly, most client applications designed to communicate with StatusNet expect to do so via the API, which they invariably expect to be available under /api. Unfortunately this URL does not work with a standalone installation of StatusNet, and instead, any requests for /api must be redirected to /statusnet/index.php/api. The second rule, as previously discussed, removes the statusnet folder from the URL, allowing users to access the site as http://status.network/.

While the command prompt is open, change to C:\wamp\www\statusnet and run the following command to activate the .htaccess file in the statusnet folder that is required to enable "fancy" (i.e. clean) URLs:

move htaccess.sample .htaccess

The mod_rerwite code shown above is dependent on the rewrite module being enabled in Apache. To enable the module, click on the WampServer icon in the system tray, select Apache, and then httpd.conf. The Apache configuration file will open. Search for #LoadModule rewrite_module modules/mod_rewrite.so and remove the # from the beginning of the line. Save and close the file. Returning to the icon in the system tray, select PHP, PHP Extensions, and then enable php_tidy, and php_curl from the list of extensions. The first is a core application dependency, whilst the second is required to enable the posting of URLs via StatusNet. Enabling the extensions will force an automatic restart of Apache, which is also required to allow Apache to load the mod_rewrite module.

Two final pieces of house keeping are necessary. First, delete the WampServer index file from the document root: C:\wamp\www\index.php. Secondly, to avoid setlocale warning messages when accessing StatusNet, edit C:\wamp\www\statusnet\extlib\php-gettext\gettext.inc and immediately under // Variables add the following line:

if (!defined('LC_MESSAGES')) define('LC_MESSAGES', 5);

We have completed the prerequisites for installing StatusNet. Open a web browser and navigate to http://status.network/statusnet/install.php. Note: We will include the statusnet folder in the URL until we have completed the installation process. Enter an appropriate Site Name (e.g. Company XYZ), ensure Fancy URLs is set to enabled, set Database Hostname to localhost, the Type to MySQL, the Database Name to statusnet, the Database Username to statusnet, the Database Password to Passw0rd1, and click Submit. With any luck, you should be informed that StatusNet has been installed successfully.

Before accessing the site, open C:\wamp\www\statusnet\config.php and remove statusnet from the path variable, and then save and close the file:

$config['site']['path'] = '';

You are now ready to navigate to your site: http://status.network/

Click the link to register a new account, enter a Nickname, Password, and Full Name, accept the Creative Commons Attribution and click Register. Navigate to your Account Settings, upload an avatar, and then enter your first status update.

Congratulations. You've successfully deployed StatusNet as a standalone microblogging service. Spread the news amongst your work colleagues, ask them to register accounts, and start building a community.

In the next couple of days I'll write a follow-up article describing the steps required to configure the desktop client Twhirl to talk with your StatusNet installation. Stay tuned.

The Mob Hath Spoken

john:

I have done an install of the statusnet software via following the guide that you have posted (awesome post!). I am having some difficulty and I was wondering, would you would be willing to answer some questions of mine?

Hinch:

Sure. Fire away.

Your Say