I’ve noticed a lack of tutorials demonstrating how to host a forum on a Raspberry Pi so I wrote up this tutorial to show everyone how to do this using Simple Machines Forum (SMF). Maybe this lack is due to the misconception that it requires a lot of overhead but as you’ll see in the end, the performance is actually quite fast.
Nginx and PHP Setup
To start off you’ll need to have Nginx and PHP already setup on your Pi. I’m not going to go into the specifics of that with this tutorial. If you require instruction on how to do this, please see this post.
With any forum software on Raspberry Pi my first choice would be to use SQLite. SMF does support SQLite but they don’t support 3.x, which is the default version that is now included with all the modern distributions. phpBB, another forum software, suffers from the same problem. So until SMF officially adds support for SQLite 3.x we’ll just have to go with MySQL (the overhead from this isn’t too terrible).
So the first thing we need to do is install mysql-server and also php5-mysql. Obviously the former is MySQL itself and the latter is the necessary extension that allows PHP to use MySQL.
sudo apt-get install mysql-server php5-mysql
After a minute you’ll see this screen and you’ll want to come up with a strong password for the root user.
Just another dialog confirming the password you entered.
You’ll need to be patient as this takes a little while to install. Once it’s done though MySQL will be up and running and the PHP extension will already be loaded and ready to go. Now what we need to do is to actually create the SMF database and user in MySQL. Run the following command and enter your MySQL root password when prompted.
mysql -u root -p
Now that we have a MySQL command-line let’s create the database, the user, and grant permission. Note that pass123 is the user’s password, I kept it simple for the example but you should make it strong if you’re actually planning on hosting a forum.
CREATE SCHEMA smf; CREATE USER 'smf'@'localhost' IDENTIFIED BY 'pass123'; GRANT ALL PRIVILEGES ON smf.* TO 'smf'@'localhost'; FLUSH PRIVILEGES; QUIT;
Now everything is all set with MySQL so we’ll move onto actually installing Simple Machines now.
Installing Simple Machines Forum
To install SMF you’ll first need to go out to their download section and get the latest tar.gz (2.0.5 at the time of writing this).
Once you’ve got it downloaded to your Pi we need to untar it to /var/www. Make sure that /var/www is cleaned out completely before you do this.
sudo rm -rf /var/www/* cd /var/www sudo tar xzf /home/pi/smf_x-x-x_install.tar.gz
Now in a web browser navigate to http://x.x.x.x/install.php, where x.x.x.x is your Pi’s IP address. You should see the following the screen.
Click Continue and proceed to the next screen. The installer will indicate that there are certain files/folders that need to writable. To address this we’ll give www-data ownership of those files/folders.
sudo chown -R www-data:www-data attachments avatars cache Packages Smileys Themes agreement.txt Settings.php Settings_bak.php
After that click the link at the bottom of the page to re-run the test to make sure that everything is writable now. Once that checks out you should be presented with the Database Server Settings. Just enter smf as the username and pass123 (or whatever you made the user’s password) as the password and leave the rest to their default values.
Click Continue and it should go to the Forum Settings page. Here you don’t have to change anything. You can change the name to be whatever you want it to be for your forum and if you were going to use this with a domain name then you’d want to indicate the URL. Hit Continue and it will start populating the database.
As long as everything was successful you’ll see the following screen. Hit Continue.
At the next screen it’ll ask you to enter information for your forum administrator account and also enter the database password at the bottom (this is the password for the smf user). Once you’ve got that all filled in hit Continue.
As long as you got the completion page, the forum is setup and installed now. Before you begin using it, you should remove theinstall.php file in /var/www as this poses a security risk.
sudo rm -rf /var/www/install.php
After that head to http://x.x.x.x/index.php (where x.x.x.x is your Pi’s IP) in a browser and you should already be logged in. Have fun with your new forum!
Hungry for more Pi?
For more project ideas be sure to check out our other Raspberry Pi Guides.