CSUF LogoCSUF Site Navigation
optics.csufresno.edu

F9 Apache/MySQL/PHP Services & Applications phpBB

Department of Electrical and Computer Engineering
Assistant Professor Gregory R. Kriehn
Forums
Wiki
F9 phpBB

phpBB is a "high powered, fully scalable, and highly customizable Open Source bulletin board package. phpBB has a user-friendly interface, simple and straightforward administration panel, and helpful FAQ. Based on the powerful PHP server language and your choice of MySQL, MS-SQL, PostgreSQL or Access/ODBC database servers, phpBB is the ideal free community solution for all web sites."

phpBB recently upgraded from Version 2 to Version 3, so this page is going to concentrate on the process of upgrading the board from V2 to V3.

Installation of the Bulletin Board requires first heading over to their website:

http://www.phpbb.com/

Click on the Download Latest Release link halfway down the page. At the time of this writing, the current version of phpBB is phpBB 3.0.1. Scroll down to the Full Package
section, choose the phpBB-3.0.1.tar.bz2 link, and download the compressed phpBB-3.0.1.tar.bz2 file. Once it downloads, move the file to /var/www/html:
~> sudo mv ~/Download/phpBB-3.0.1.tar.bz2 /var/www/html/.
Then decompress the source:
~> sudo tar vfjx phpBB-3.0.1.tar.bz2
Once the package has been decompressed, delete the source file, make a backup of your old directory, and move the new directory to forums:
~> sudo rm phpBB-3.0.1.tar.bz2
~> sudo mv forums forums-bak
~> sudo mv phpBB3 forums
Next change the permissions so that Apache maintains ownership using chown:
~> sudo chown -R apache.apache forums
Now, before you can install phpBB, you need to create a new database. This can be done a couple of ways. Choose either Option 1, or Option 2, but not both.

Option 1 - MySQL

Login to MySQL using root:
~> mysql -u root -p
Type in the MySQL super user password, and hit Enter.

Next, create a database called phpbb3:

mysql> create database phpbb3;
and verify its existence:
mysql> show databases;
You should now see a database called phpbb3. With the database created, exit:
mysql> exit;
Option 2 - phpMyAdmin

Login to your phpMyAdmin account. Under Create new database, enter "phpbb3". Then click on the Create button. After clicking the button, you should see a statement that says:  "Database phpbb3 has been created". Once finished, click on the green Exit icon to exit phpMyAdmin.

Run the Install Script

To run the installation script, open Firefox and go to the following address:
http://[host].[domain].[name]/forums/install/index.php
This will launch the phpBB3 Installation Page.  

Under OVERVIEW, look over the Introduction, License, and Support links.  When you are satisfied, click on the INSTALL tab, followed by Proceed to next step.

Verify that you PHP version and settings, and the mbstring extension check are all green.  If not, start Googling. Also verify that you have MySQL installed, and that the Files and Directories permissions are set correctly.  Do not worry if config.php is currently unwritable.  Click Start Install when you are satisfied with the installation compatibility settings.

Under Database type: click on MySQL from the drop down menu.  The Database server hostname or DSN: should be "localhost".  Leave the Database server port: blank, and under Database name:, type "phpbb3". For the Database username:, type "root", and for the Database password: type in the MySQL super use rpassword. Verify that "phpbb_" is being used for the Prefix for tables in database". Click Proceed to next step.

You should see Successful connection under the Database connection page. If not, did you remember to create your phpbb3 database first? Then click on Proceed to next step.

Under Administrator configuration, leave the Default board language:as is, and choose an Administrator username: and Administrator password: (ideally it should be the same one you are using for phpBB2). Confirm the password and type in your e-mail address under Contact e-mail address: and confirm it. Then click on Proceed to next step.

Under Administrator details, you should see Tests passed.  Then click on Proceed to next step.

Under Download config, click on the Download link to download the config.php file. From there, copy it over to the forums directory:

~> sudo cp ~/Download/config.php /var/www/html/forums/config.php
Then click on Done, followed by Proceed to next step.

Set your options under the E-mail settings (I left mine on default), as well as the Server URL settings (again, I used the default ones provided). When finished, click on Proceed to next step, followed by Proceed to next step once again.

Since I am converting an old phpBB 2.0.x board, make sure you click on the proceed on to the convertor link. Then click on the Convert link on the far right.

Under the Specify conversion options page, most of the options should already be in place. However, you will probably have to change the Database name:, which in my case, is "phpbb" (the database of my old board). Type in the MySQL super user password under Database password: and since we changed the old board to forums-bak, under Board path: type in "../forums-bak". Then click on Begin conversion.

Once the information has been verified, click on Begin conversion, Continue conversion. Do not worry if some of your old smilies did not overwrite themselves into the new board (they are already there).

ensure both the install/ and contrib/ directories are deleted". Let's do so now:

~> cd /var/www/html/forums
~> sudo rm -r install/
~> sudo rm -r contrib/
Likewise, let's change the permissions on config.php so that it is no longer world writable:
~> sudo chmod go-w config.php
If you now point yourself to http://[host].[domain].[name]/forums, you will be taken to the phpBB page. If you click on the Log in link, you can login with your administration username and password. Do so now to verify that you can log into your board, and then exit.

Customization of phpBB

At this point, I like to install the RedSilver style, as it fits more closely to Fresno State's (and my web site's) color scheme. If you go to the phpBB website, perform a search for RedSilver, or you can go directly to the forum announcement here. Scroll down and click on the RedSilver1.03.zip link. Once it downloads, move it over to the /var/www/html/forums/templates directory:
~> sudo mv ~/Desktop/RedSilver1.03.zip /var/www/html/forums/templates/.
Change to the templates directory:
~> cd /var/www/html/forums/templates
and unzip the file:
~> sudo unzip RedSilver1.03.zip
Once the package has been unzipped, delete the source file, and change the permissions of the directory. From there, change into the RedSilver directory:
~> sudo rm RedSilver1.03.zip
~> sudo chmod go+rx RedSilver
~> cd RedSilver
The permissions are not set correctly in the subdirectory either, so let's fix those as well:
~> sudo chmod go+r *.*
~> sudo chmod go+rx admin
~> sudo chmod go+rx images
~> sudo chmod go+r ./*/*.*
~> sudo chmod go+rx images/lang_english
~> sudo chmod go+r ./*/*/*.*
The next thing that I like to do is change the overall header for the theme. If you open up the overall_header.tpl file using sudo, perform a search for the following code:
<table width="100%" height="100" background="templates/RedSilver/images/top.jpg"">
  <tr valign="top">
    <td>
      <center><span class="maintitle">{SITENAME}</span><span class="gen"><br /><br />{SITE_DESCRIPTION}</center>
      </td>
    </tr>
</table>
Instead of having a table with just one column, I like to create a table with three columns. In the left column, I have an image that, when clicked on, will take you back to my homepage; in the center column, the name of my forum; and in the right column, a few links that act as shortcuts to various points on my web pages. As a result, the code now looks like:
<table width="100%" height="100" background="templates/RedSilver/images/top.jpg"">
  <tr valign="top">
    <td valign="middle" style="width: 94px"><font size="-1">
      <center><a href="http://optics.csufresno.edu/">
        <img src="templates/RedSilver/images/laserlight_88x88.png"
           alt="Professor Kriehn's Home Page" title="Professor Kriehn's Home
           Page"/>
        </a></center></font>
    </td>
    <td valign="middle">
      <center><span class="maintitle">{SITENAME}</span>
        <span class="gen"><br />{SITE_DESCRIPTION}</center>
    </td>
    <td valign="middle" style="width: 94px"><font size="-1"><center>
      <a href="http://optics.csufresno.edu/">
        Home</a><br />
      <a href="http://optics.csufresno.edu/~kriehn/teaching/teaching.html">
        Teaching</a><br />
      <a href="http://optics.csufresno.edu/~kriehn/optical/research.html">
        Research</a><br />
      <a href="http://optics.csufresno.edu/~kriehn/fedora/fedora.html">
        Fedora Linux</a>
      </center></font>
    </td>
  </tr>
</table>
Obviously, you will want to change several of the parameters, but this works for me. Notice, that if you use a picture, I have placed it in the ./templates/RedSilver/images/ subdirectory.

I also like to change minimum age requirement for registering on the board from 13 to 18, since I am at a University, and do not want to have to hassle with underage kids. To do this, there are several files that need to be edited. First, open up the /var/www/html/forums/language/lang_english/lang_faq.php file. Perform a search for 13, and replace it with 18. Save and exit.

Next, open up the /var/www/html/forums/language/lang_english/lang_main.php file. Perform a search for Agree_under_13 and Agree_over_13 (the lines are right next to each other). The should be changed so that they look like the following:

$lang['Agree_under_18'] = 'I Agree to these terms and am <b>under</b> 18 years of age';
$lang['Agree_over_18'] = 'I Agree to these terms and am <b>over</b> or <b>exactly</b> 18 years of age';
Save and exit. Open the /var/www/html/forums/includes/usercp_register.php file. Search for the AGREE_OVER_13 and AGREE_UNDER_13 variables. Change the lines to:
"AGREE_OVER_18" => $lang['Agree_over_18'],
"AGREE_UNDER_18" => $lang['Agree_under_18'],
Scroll down a couple of lines to the U_AGREE_OVER13 and U_AGREE_UNDER13 variables. Change them to U_AGREE_OVER18 and U_AGREE_UNDER18, respectively. Save and exit.

Finally, open the /var/www/html/forums/templates/RedSilver/agreement.tpl file. Search for the number 13. Every time it comes up, replace it with the number 18. You will change four variables (U_AGREE_OVER13, AGREE_OVER_13, U_AGREE_UNDER13, and AGREE_UNDER_13 to
U_AGREE_OVER18, AGREE_OVER_18, U_AGREE_UNDER18, and AGREE_UNDER_18). Save and exit.

With that done, go back to http://[host].[domain].[name]/forums, and login. Click on the bottom link that says Go to Administration Panel and type in your password once again. Then click on Add, under Styles Admin, and click on Install under RedSilver. The selected theme should install successfully.

Then click on Configuration, under General Admin, and type in your Site name, the Site description, and work through the general settings for your board. Under Default Style, change it to RedSilver, and click on Yes for the Override user style option. When finished, click Submit.

You are now using the RedSilver theme, have changed the header for the forum board, and raised the minimum registration age to 18.

Security and Admin Changes

There are several other mods that I like to add to phpBB in order to improve the security of the forum. This is primarily because spammers have figured out how to use bots to automatically register and post spam web site addresses on phpBB (in spite of the captcha image present on the registration page). After hunting around on the phpBB boards, I found a couple of decent articles relating to my problem:

Preventing SPAM - Bots and Humans
http://www.phpbb.com/phpBB/viewtopic.php?t=427852

Anti-Spam Thread!
http://www.phpbb.com/phpBB/viewtopic.php?t=393503

Based upon the discussion, I have installed several mods, which have stopped the spammers cold. Just click on the links, and follow the directions. The first two mods listed here stop spammers for registering, and the last two are very useful administration tools.

NOTE:  Since I am using the RedSilver theme, whenever you have to change a templates/subSilver file, change the templates/RedSilver file instead.

1.  Easy BotStopper - V 1.0.0

Description:
This MOD works by making website field invisible during registration. Spam bot that uses auto-registration script which provides an website URL will be detected and stopped.

http://www.phpbb.com/phpBB/viewtopic.php?t=375262



2.  The Humanizer - V 1.1.0

Description:
This MOD adds an additional question to your registration form — 'Yes' must be selected in order for the registration to go through successfully.

http://www.phpbb.com/phpBB/viewtopic.php?t=383788
http://www.underhill.de/downloads/phpbb2mods/thehumanizertips.txt

For this mod, I use Tip #2, which allows the changing the radio buttons to a text field box. Instead of asking the simple question, "Are you human?", I have decided to ask another question. If you wish to do the same you will have to change $lang['Are_u_human'] and $humanizer_answers fields. I've also changed the
$lang['Are_u_human_explain'] field by removing the word "stupid" in the text.



3.  Admin Userlist

Description:
This MOD lets you view all of your members and various information about them in the Admin Control Panel. From the list, you can perform various actions on multiple users. Delete, Ban, Unban, Add to Usergroup, etc...

http://www.phpbb.com/phpBB/viewtopic.php?t=117359



4.  DB Maintenance

Description:
This is a powerful hack to check the phpBB database for errors and inconsistencies. Some additional features are provided, e.g. to rebuild the search index. With an emergency platform access to the configuration is also possible when phpBB itself will not start.

http://www.phpbbhacks.com/download/4372

This last mod I found to be useful because I had accidentally messed up some of my tables as a result of using phpMyAdmin to delete spammers. At the time, in order to delete a user, I was only deleting an entry from the phpbb_user_group table, not realizing that I needed to delete a corresponding entry from the phpbb_groups and phpbb_user_group tables as well. The DB Maintenance mod fixed the tables, and because I still only had a few users that had registered, I re-ordered the user_id and group_id numbers by hand. In order to reset the auto increment counters in each of the tables, I logged into MySQL as root and ran the following commands:

mysql> use phpbb;
mysql> ALTER TABLE phpbb_groups AUTO_INCREMENT=[number];
mysql> ALTER TABLE phpbb_users AUTO_INCREMENT=[number];
mysql> ALTER TABLE phpbb_user_group AUTO_INCREMENT=[number];
where [number] is the number that I wanted to set the auto increment number to. In this case, I had 13 valid users, so I set the number to 14.



ModSecurity Restrictions

PHP injection attacks seem to be on the rise, so Fedora 9 comes bundled with ModSecurity, which is an Open Source Web Application Firewall.  Unfortunately, it is a bit too restrictive for phpBB, and tends to prevent you from doing some legitimate things, especially when posting. To circumvent this, edit the /etc/httpd/modsecurity.d/modsecurity_localrules.conf file and add the following:
<LocationMatch '^/forums/posting.php'>
SecRuleRemoveById 950005
</LocationMatch>
Save and exit, and restart your httpd server:
~> sudo service httpd restart
You should see httpd successfully restart:
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]
If you want to learn more about ModSecurity, go to their website:

http://www.modsecurity.org/

and start reading. Additional information and references can also be found on my Joomla page.

Additional Help

If you need additional help, I suggest heading over to the phpBB website and clicking on either the Support or Community links. You should be able to get most of your questions answered there.

Upgrading phpBB

The easiest way to update your phpBB installation is to follow the appropriate directions in the Knowledge base:

http://www.neothermic.com/kb/article271.html

Since I have MODs installed, I upgrade using the .patch files.