After looking at Gregarius last month, this time it's b2evolution's turn to be in the spotlight. b2evolution is blogging software (and more), written in PHP and MySQL, released under the GNU GPL, and it's what I use for my personal blog. It's definitely one of the few applications worth considering if you want to host and maintain your own blog. It has a comprehensive feature set, including multilingualism (the main developer, Francois Planque, is French, and non-English speaking developers tend to consider the issue right from the start), multiple blogs with different access levels, antispam tools, trackbacks and pingbacks, timezone handling, RSS and ATOM feeds and image uploads. The online documentation is pretty poor for an Open Source project, with somewhat outdated information, nor does it have the friendliest of forums, but the application itself is good, so hopefully this tutorial will be helpful to some.

History

b2evolution is an offshoot of an earlier blogging tool called b2\cafelog. François Planque installed b2 (as it's usually known) in December 2002. However, the b2 maintainer took some time off from the project, and development stalled. As of April 2003, nothing had happened for 6 months, and François had been wanting to add new features. Thanks to b2 being an Open Source project, he of course had access to the source code and could easily make additions. Shortly after, the b2 maintainer announced that Wordpress was to be the official successor to b2, but by that time b2evolution was underway, and François decided to keep it going as a separate product.

Requirements and Installation

b2evolution requires PHP 4.1 or above (and works with PHP 5 from version 1.6), and MySQL 3.23 or later. Installing it is simple. Simply download it, place the file in your webtree and unzip it (there's no tarred version available). This creates a folder called b2evolution. From your browser, open the file called b2evolution/index.html, and follow the instructions there. View screenshot 1 to see what the page looks like.
You'll notice that there's a list of translations available. If the default English (EU), doesn't appeal to you, choose one of the others. For the purposes of this tutorial, we'll choose English (UK) (see screenshot 2). Then, click on "installing from scratch." This tutorial won't guide you step-by-step if you're moving from another blog application, although the basics are the same.
Next, you'll be asked for details pertaining to your database, and will need to set it up (screenshot 3). Hopefully you have access and permission to do so yourself. If not, you'll need to ask your service provider to run the following commands to create the database, and assign permission to access it. We'll create a database called phpbuilder_b2evolution, a user called phpbuilder_b2evo and a password phpbuilder_pword.
CREATE DATABASE `phpbuilder_b2evolution` ;
GRANT ALL ON phpbuilder_b2evolution . * TO phpbuilder_b2evo@localhost 
IDENTIFIED BY 'phpbuilder_pword'
Enter the details above on the page (screenshot 4) and submit. If you haven't created your database, user or password correctly, you'll see an error such as the one displayed on screenshot 5. However, there's still most likely to be one thing outstanding. Even if your database has been set up correctly, it's likely that your file permissions are not set up properly, and b2evolution cannot properly edit the config file (screenshot 6). Here are the commands you'll need to run on a Unix-like system:
cd /var/www/impi/b2evolution/blogs/conf/
chmod 666 _config.php
Reload the page, and you should see a page asking (again) whether you want to do a new install, or an upgrade (screenshot 7). Again select New Install and b2evolution will create the tables in your database (screenshot 8). Once this has been completed, b2evolution automatically creates a user called admin and assigns a random password to it (screenshot 9). Use these to log into (screenshot 10)the admin pages (screenshot 11), and b2evolution is now installed--you're almost ready to blog.

Administration

There're a few more things you need to do before you're quite ready to unleash your Pulitzer Prize winning-prose onto the world. Firstly, I suggest changing the admin password. To do this, click on Users (screenshot 12), edit the admin user (the hands and envelope icon) and change your password (screenshot 13). You can also customize it in other ways, adding firstname and surname details, email, locale, URL etc. Don't worry too much about the level - b2evolution has been moving to a more sophisticated permissioning system, and the user level is not very important anymore. I suggest also keeping the notifications checkbox checked, as this will alert you every time someone comments on, or tracks back to, one of your posts. Since comment spam is an ongoing problem, you'll probably want to be able to react quickly to this.
At this point you can also add other users if you wish, and you can even allow new users to register themselves (an option from the Settings tab.
Next, click on the Blogs tab (screenshot 15). There you'll see four blogs that have been created for you. Until you actually choose one as default, anyone visiting your blog will see a standard error page. Blog A and Blog B are ordinary blogs. Click on the one titled Blog A to edit its features. Give it a name (I call it PHP Blog), set it as the default, and set the skin, tagline and notes (screenshot 16). If you're not sure what these are, leave them as the default. Once you've viewed your blog you'll soon see what you want to change.
Now, click on Exit to blogs on the top right, and you'll see what your blog currently looks like to the rest of the world. Take note of the URL - by default it's WEB_ROOT/b2evolution/blogs. That's the URL you'll be submitting to the Nobel literary committee for consideration, as well as any friends.

Skins

The first thing most people want to do is change their default skin. Have a look at the skins that are supplied by default. You can click on each of them (they're in the right-hand bar in the default skin, though they move around on the others) to see which you prefer. Here are some screenshots of basic, bluesky, guadelope, natural pink, originalb2, wpc_aubmach and wpc_default. You can also download more from the skins repository.

Posting to your blog

If you've managed to look past the pictures, you'll have noticed that there are already some sample posts in your blog. Editing these is meant to familiarise yourself with some of the techniques. Let's edit the first post, Important Information (screenshot 25). Adding formatting is simple. For example, to add the HTML <strong> tag (which usually makes bold whatever appears between the tags), simply highlight the text, and click the str tab. I'll assume you know HTML, and if not there's more than enough other resources, so this tutorial won't explain what all the HTML tags do. The last four tags you won't be familiar with yet, but we'll see what they do in the next examples. Edit the first post, and add a few tags (screenshot 28). Here's what I added:
<strong>Strong</strong>
<em>emphasis</em>
<del>deleted</del>
<ins>inserted</ins> 
<code>code
code
code</code>
<ul>
  <li>unordered list 1</li>
  <li>unordered list 2</li>
</ul>
<ol>
  <li>ordered list 1</li>
  <li>ordered list 2</li>
</ol>
<blockquote>block</blockquote>
<a href="http://phpbuilder.com">link to phpbuilder.com</a>
Also note the status (the default is for posts to be publicly visible), which you can change in various ways - making it visible to members only, to yourself only, or only in the admin tool. Remember as well that although you're the admin user right now, and can do what you want, b2evolution is designed for multiple users, and multiple blogs. You can also select from one or more categories into which to post. After installation there are a number of default categories. You can change these from the Categories tab, which we won't specifically look at as it shouldn't present any problems to anyone. You can also decide whether to allow comments, whether to close comments (no more comments will be allowed - this doesn't make sense in a new post), or disable them altogether.
Once you're ready, click to preview the post (screenshot 29). It allows you to see what the post will actually look like, and give you a chance to correct anything before making it visible. I always preview my posts, but then I have a particular dislike of showing my own errors to the world. The preview opens in a new window. Close it, make any changes, and finally submit when you're happy with it.

Cross-posting to multiple blogs

You'll notice an oddity (at least with what's currently the latest stable version, 0.9.11). The initial entries that are supplied upon installation have been cross-posted across multiple blogs (our newly-named PHP Blog, as well as Blog B). However, when you edit them, you'll see that cross-posting has been turned off, and they can now only be posted into Blog B. So the changes we made effectively removed the post from PHP Blog. There's a setting to change this, but you'll need to dive into the code. In the b2evolution/blogs/conf directory, edit the _admin.php file, and change the line $allow_cross_posting = 1 to $allow_cross_posting = 2. The possible values for this (which are commented in the code) are:
0Post to a single category only
1Post across multiple categories (the default)
2Post across multiple blogs/categories
3Change main category among blogs, effectively moving from one blog to another. Caution is recommended!
Once you've done this, you can go back to the post we just edited, and restore it to PHP Blog. You'll see that the sets of categories for both blogs are visible. If for some reason you can't edit this file, just bear in mind that your edits will appear in Blog B only, and you'll need to view them there.

Extended text

Take a look at the other posts in PHP Blog, called Extended Post, Extended post with no teaser and This is a multipage post. Read them fully, clicking on the Read More and page numbers. The text inside them is fairly self-explanatory. Let's edit Extended post with no teaser. (screenshot 30). Notice the <!--more--> and <!--noteaser--> tags. These are the first of the mysterious !M and !NT tags we saw next the other HTML tabs earlier. Clicking !M inserts <!--more--> in the text, and anything after that is not visible on the front page, only after clicking Read more. !NT inserts <!--noteaser--> in the text, and this means that anything above is not repeated after clicking Read more. Essentially b2evolution overlaps between being simply a blogging tool, and also a reasonable content management system (CMS). It's just this control that CMS's require to ensure that people read the short blurbs, which don't give away too much, and are enticed deeper down to read the full article (and another advertising impression).

Trackbacks

Trackbacks are a great feature, and I fail to understand why not all blogging software and services offer them. If you come across a post that you want to respond to, trackbacks allow you to notify that post that your new post is a response. Trackbacks are usually displayed amongst the comments, or just below or above. Let's try one out. Have a look at PHP Blog, and the post I've renamed Not so important anymore (you can choose any other post). From PHP Blog's front page, beneath the post you'll see three options: Leave a comment, Trackback (0) and Edit. If you click on trackback, it'll take you to the full post, as well as display a trackback address (this will be something like WEB_ROOT/b2evolution/blogs/htsrv/trackback.php?tb_id=21). Copy this text, and, back on the admin pages, click on the Write tab, and Blog B. Everything is just the same as it was when we edited a post, except of course, being a new post, it's all blank. Write your new post, and add the trackback URL in the appropriate area below. (screenshot 31). When you submit, the server then contacts that URL, which in turn registers the URL from which the trackback is being sent, and adds it. Reload Blog B's front page. You'll see your new post, and beneath Not so important anymore (remember it was cross-posted across both blogs). It now reads Trackback (1). Click here, and you'll see the trackback has been recorded, along with the blog title (still the default Blog B title and a link to the post. If you've set up your email correctly, and left the notifications checkbox checked, you'll receive an email informing you of the trackback. Trackbacks are a simple and powerful way of getting people to link back to your blog. The abuse of which of course brings us to the next topic.

Antispam

b2evolution has some quite sophisticated tools to ward off spam, even if anonymous comments are enabled. It relies upon users to report spam, and the offending sources are stored in a central blacklist. Click on the antispam tab (screenshot 26). You'll see a list of keywords that are already blacklisted. Any posts containing these keywords (or referring, commentary or trackback URL's) will be banned. The first thing to do on a new blog is to download the latest blacklist, which will be quite lengthy the first time. (screenshot 27).
You can help by reporting all spam to the central server. Whenever you view a comment, trackback or a referer (from the stats tab), you'll see the URL, and next to it a circle with a red line through it. By clicking on this, you'll ban that URL from submitting anything else to your installation, and you'll report it to the blacklist. If enough people report it, it'll be added to the central blacklist. Hopefully your new installation hasn't yet been inundated with spam, but here's an example of removing referer spam from my personal blog. Screenshot 34 lists the recent referers to my blog. Spammers persist in spamming the referer logs, even though these are no longer displayed to the public by default (it used to be), so it provides them no benefit unless you, the administrator click on it to see what it is (which is hardly worth the trouble for them). See how many of my referers are obvious spam. If I click on beastsex-movies.com, b2evolution will find all instances of that URL (screenshot 35), and I can delete and report them all with a single click (screenshot 36).
Alone, this won't be enough to stop the spam. Just like email spam, there's an ongoing struggle between the developers and the spammers. The latest version of b2evolution added all sorts of new antispam techniques, and for a month or so after launch everything was quiet. However, the spammers eventually caught up. I advise you to check the forums for the latest - there's a forum entitled Got spam, and another called Fighting spam that should be able to help. One of the techniques that seems to have worked for me is to rename the /htsrv directory, which is used for comments and trackbacks. Rename it to any valid directory name, and then edit the conf/_advanced.php file to reflect this new name, as follows:
* Location of the HTml SeRVices folder.
* @global string $htsrv_subdir
*/
$htsrv_subdir = 'new_htsrv'; // Place the new name here. 
Unfortunately this technique has become quite widespread, and is not particularly difficult to break for a determined spammer, so has become less effective recently. It does though distinguish you from the majority of b2evolution installations, which simply use the default.
Other techniques to reduce spam include server modifications so that comments can only be called locally (such as by using an .htaccess file), and using captcha (manual verification of image letters). Implementing these are beyond the scope of this article, but the forums will help you on your way.

Statistics

Accessible from within the admin section from the Stats tab, b2evolution provides some interesting data. I'll use my blog as a sample, as you're unlikely to have any stats yet on your newly-created blog. Firstly, there's the referers (screenshot 37). Everytime someone clicks on a link to your blog from another web page, this is recorded here. Summary is perhaps the most useful, as it provides statistics on the total number of accesses to your blog, and the sources (referer, direct access, syndication, search engine or a robot - screenshot 38). The Refering Searches tab returns the search terms people use to end up on your blog (usually worth a laugh - screenshot 40). You can also get a list of RSS aggregators accessing your blog (Syndication), User agents, and the most recent URL's for direct accesses.
Unfortunately b2evolution does not offer a feature that tells how many times each post has been accessed.

Syndication

b2evolution of course supports syndication. It automatically creates feeds in RSS 0.92, RSS 1.0, RSS 2.0 and Atom. Feeds for both posts and comments will automatically be created without you needing to do anything. RSS finally lives up to its Really Simple moniker.

Editing Templates

Even if you've found a skin that you like, at some point you'll probably still want to make other changes. My own blog, for example, also contains an include I've created listing the most recent books I've read. These changes are quite easy to make and you don't even need to manually edit the files. By clicking on the Admin/Templates tab, you'll be able to edit any of the template files. You're likely though to first have to make them writeable in most Unix-like servers - chmod 766 filename will do the trick. By experimenting you'll soon find the appropriate file to edit depending on what you want to do.

Linkblog and Blogall

Earlier on we mentioned that of the four blogs created by default, only Blog A (which we renamed PHP Blog) and Blog B were normal blogs. The other two are slightly different. Blogall simply aggregates all posts to all blogs. If you don't want it to appear, you can simply uncheck the Include in public blog list option under Admin/Blogs/Blogall.
The Linkblog is a special kind of blog, one that contains a list of other sites you'd like to link to. Usually you'll just want to add a title and URL. The list then usually appears in your other blogs. Try it by editing the first linkblog post, which contains text explaining how it all works. Remove the text and add a URL. Once you've submitted, view PHP Blog, and you'll see the links from the Linkblog in the right bar. (screenshot 39)

Conclusion

Hopefully you're up and running with your own b2evolution installation. There's of course lots more we haven't covered, and new versions coming out will be bound to add new features. Happy exploring, and happy blogging!