How to install and Configure phpBB on Ubuntu 18.04

Post Reply
User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

How to install and Configure phpBB on Ubuntu 18.04

Post: # 796Post LHammonds
Tue Dec 17, 2019 4:22 pm

------------- WORK-IN-PROGRESS -------------

Overview

phpBB is a free PHP-based bulletin board forum software. This documentation will describe the steps to manually install the software onto a dedicated web server and tie it into a separate dedicated database server which is typical of a production environment rather than having an entire LAMP stack on the same machine which is assumed if you try to use the "apt install phpbb3" command.

Software Used in this Article
  1. Ubuntu Server 18.04.3 LTS
  2. Apache Web Server 2.4.29
  3. MariaDB 10.4.8
  4. PHP 7.2.24
  5. phpBB 3.2.8
  6. PuTTY 0.73
This article will assume you have an Ubuntu Server setup similar to this tutorial.

It will also be assumed you have a separate dedicated MariaDB / MySQL database server.

Wherever you see RED in this document, you need to substitute it for what your company uses. Use the list below as a template you need to have answered before you continue.
  • Website FQDN (Fully-Qualified Domain Name): forum.mydomain.com
  • Ubuntu Server name: srv-php
  • Ubuntu Server IP address: 192.168.107.55
  • Ubuntu Admin ID: administrator
  • Ubuntu Admin Password: myadminpass
  • MySQL Server (remote): srv-database (192.168.107.20)
  • MySQL phpbb user: phpbbuser
  • MySQL phpbb Password: phpbbuserpassword
  • Mail server name: srv-mail
  • Mail server IP address: 192.168.107.25
  • Mail server port: 25
  • phpBB Admin ID: phpbbadmin
  • phpBB Admin password: phpbbadminpassword
  • phpBB Admin email: phpbbadmin@mydomain.com
I also assume the reader knows how to use the VI editor. If not, you will need to beef up your skill set or use a different editor in place of it.

User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Server Preparation

Post: # 797Post LHammonds
Tue Dec 17, 2019 4:23 pm

Create Ubuntu Web Server

Click here for detailed instructions on setting up a production-quality Ubuntu Server.

Once you have the base operating system installed, proceed to follow these instructions to install Apache web server. When it talks about setting up your web root, be sure to substitute your value such as "forum.mydomain.com" and "/var/www/forum.mydomain.com"

Dedicated MariaDB Server

This document assumes the database will be located on a separate server for housing databases only.

Click here for detailed instructions on how to setup MariaDB on a dedicated server.

Server Name Resolution

You might need to edit your local host file so you can use friendly names for servers if you don't add them to your internal DNS servers or you do not have your domain on external DNS servers resolving the new IP during development.

Edit the local host file and add your servers to the end of the file as needed.

Example:

Code: Select all

sudo vi /etc/hosts

Code: Select all

192.168.107.20      srv-database
192.168.107.25      srv-mail
192.168.107.55      forum.mydomain.com
If this is a public-facing site accessible from the Internet, you will need to edit your public DNS servers and make sure your DNS records are directing the domain name to your firewall's IP address. You will then need to add a rule to your firewall to redirect traffic on port 80 and/or 443 to your web server's internal IP address (192.168.107.55 in this example)

User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Configure Database

Post: # 798Post LHammonds
Tue Dec 17, 2019 4:24 pm

Configure MariaDB / MySQL

In this scenario, a dedicated and general-purpose database server already exists and it will be used to hold the application's database.
  1. Connect to the MariaDB/MySQL server using PuTTY.
  2. At the login prompt, login with your administrator account (administrator / myadminpass) and then temporarily grant yourself super user privileges by typing sudo su
  3. Type the following commands:
    mysql -u root -p Enter password: rootpass
    CREATE DATABASE phpbb CHARACTER SET utf8 COLLATE utf8_bin; CREATE USER 'phpbbuser'@'%' IDENTIFIED BY 'phpbbuserpass'; GRANT ALL ON phpbb.* TO 'phpbbuser'@'%'; FLUSH PRIVILEGES; exit
    The above commands will allow the database account to connect from any machine from anywhere in the world. This might be OK if your database is not accessible outsite your local network or if your machine name changes or you have multiple servers that connect to the same database that use the same ID. You can make this more secure by specifying your application server when granting access. Make sure the database server will recognize the server name (via hosts file or DNS) or just use the IP address:
    CREATE USER 'phpbbuser'@'srv-php' IDENTIFIED BY 'phpbbuserpass'; GRANT ALL ON phpbb.* TO 'phpbbuser'@'srv-php';
    or
    CREATE USER 'phpbbuser'@'192.168.107.55' IDENTIFIED BY 'phpbbuserpass'; GRANT ALL ON phpbb.* TO 'phpbbuser'@'192.168.107.55';
    This will prevent anyone knowing the credentials from logging into the database from any other remote machine not specified in the grant command.

    If your application is running on the database server (typical on a developer machine / non-production scenario), create the user like this:
    CREATE USER 'phpbbuser'@'localhost' IDENTIFIED BY 'phpbbuserpass'; GRANT ALL ON phpbb.* TO 'phpbbuser'@'localhost';
    This will prevent anyone knowing the credentials from logging into the database from any other remote machine.

    If you mess anything up, you can remove the database and user by issuing these commands:
    DROP USER phpbbuser; FLUSH PRIVILEGES; DROP DATABASE phpbb;

User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Required and Optional Libraries

Post: # 799Post LHammonds
Tue Dec 17, 2019 4:59 pm

Install Required phpBB Libraries
  1. Type the following to install the required libraries:

    Code: Select all

    apt -y install php7.2-json
    
Install Optional phpBB Libraries
  1. Type the following to install the optional libraries:

    Code: Select all

    apt -y install php7.2-gd php7.2-xml php-imagick
    
PHP Module Verification

Make sure the modules you need are loaded in the web server. Here is how you can double-check but make sure to restart the web service before checking so any recent changes are in effect.

Code: Select all

systemctl restart apache2
  1. Check the phpBB requirements documentation
  2. On the root of your web server, create a temporary file to help you examine what is enabled:

    Code: Select all

    echo "<?php phpinfo(); ?>" > /var/www/forum.mydomain.com/phpinfo.php
    chown www-data:www-data /var/www/forum.mydomain.com/phpinfo.php
  3. Now open a browser and look at that page: http://192.168.107.55/phpinfo.php
  4. Check each of the required modules and verify you see it on the phpinfo page as being enabled.
  5. Once done checking, remove the temporary info file since leaving it there would present a security risk due to exposing sensitive information about your server to the entire world:

    Code: Select all

    rm /var/www/forum.mydomain.com/phpinfo.php

User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Install phpBB

Post: # 800Post LHammonds
Tue Dec 17, 2019 5:03 pm

Install phpBB
  1. At the login prompt, login with your administrator account (administrator / myadminpass) and then temporarily grant yourself super user privileges by typing sudo su
  2. Type the following commands:

    Code: Select all

    mkdir /var/www/forum.mydomain.com
    cd /tmp
    wget https://www.phpbb.com/files/release/phpBB-3.2.8.zip -O /tmp/phpbb.zip
    unzip /tmp/phpbb.zip
    mv /tmp/phpBB*/* /var/www/forum.mydomain.com/.
    chown www-data:www-data /var/www/forum.mydomain.com -R
    chmod 660 /var/www/forum.mydomain.com/config.php
    chmod 770 /var/www/forum.mydomain.com/cache
    chmod 770 /var/www/forum.mydomain.com/files
    chmod 770 /var/www/forum.mydomain.com/store
    chmod 770 /var/www/forum.mydomain.com/images/avatars/upload
    
  3. Open a browser and go to http://192.168.107.55/install/app.php
  4. Click on the Install tab, then click the Install button.
  5. Administrator configuration - Set the following and click the Submit button:
    • Administrator username: phpbbadmin
    • Contact email address: phpbbadmin@mydomain.com
    • Administrator password: phpbbadminpassword
    • Confirm administrator password: phpbbadminpassword
  6. Database configuration - Set the following and click the Submit button:
    • Database type: MySQL with MySQLi Extention
    • Database server hostname or DSN: srv-database
    • Database server port:
    • Database username: phpbbuser
    • Database password: phpbbuserpassword
    • Database name: phpbb
    • Prefix for tables in database: phpbb_
  7. Server configuration - Set the following and click the Submit button:
    • Cookie secure: No
    • Force server URL settings: No
    • Server protocol: http://
    • Domain name: 192.168.107.55
    • Server port: 80
    • Script path: /
  8. Email configuration - Set the following and click the Submit button:
    • Enable board-wide emails: Enable
    • Use SMTP server for email: Yes
    • SMTP server address: srv-mail
    • SMTP server port: 25
    • Authentication method for SMTP: PLAIN
    • SMTP username:
    • SMTP password:
  9. Bulletin board configuration - Set the following and click the Submit button:
    • Default language: British English
    • Title of the board: mydomain.com
    • Short description of the board: A short text to describe your forum
  10. Once install is complete, type the following commands at the server console:

    Code: Select all

    chown root:www-data /var/www/forum.mydomain.com/config.php
    chmod 640 /var/www/forum.mydomain.com/config.php
    rm -rf /var/www/forum.mydomain.com/install
    
  11. Now you can visit http://192.168.107.55/ and see the newly created forum.

User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Styles

Post: # 801Post LHammonds
Tue Dec 17, 2019 5:07 pm

>> NOT STARTED <<

User avatar
LHammonds
Site Admin
Site Admin
Posts: 793
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Upgrading phpBB

Post: # 802Post LHammonds
Tue Dec 17, 2019 5:18 pm

Upgrading phpBB

The download page for phpbb does a pretty-good job of telling you how to upgrade phpBB. It can get a bit confusing if you are upgrading very old versions of phpBB so here is what I did to upgrade 3.0.8 to 3.2.0 which required (for me) upgrading to specific versions in between.

Pre-Upgrade Notes
  • Make sure you have a good backup of your database and your website files before you begin.
  • Make sure default style is set to prosilver and deactivate all other styles.
  • If the custom styles are not compatible and have no upgrades available, remove them.
  • Make sure to migrate/upgrade the old styles to the new forum.
  • If the used mods/extensions are not compatible and have no upgrades available, remove them.
  • If going from an ancient OS with PHP 5 or lower, you can copy the forum to a new OS with PHP 7 but the forum may not work as is. You can just go through the upgrade steps and once on the latest version, you should have PHP 7-compatible forum that will work.
  • If your database was made several database versions ago, you might need to run mysql_upgrade to bring your database(s) up to current standards.
phpBB 3.0.8 to 3.0.14

Code: Select all

cd /tmp
wget https://download.phpbb.com/pub/release/3.0/3.0.14/phpBB-3.0.14.zip
mkdir /tmp/t
unzip /tmp/phpBB-3.0.14.zip -d /tmp/t
mv /tmp/t/phpBB3 /var/www/forum-new.mydomain.com
rm -rf /var/www/forum-new.mydomain.com/config.php
rm -rf /var/www/forum-new.mydomain.com/images
rm -rf /var/www/forum-new.mydomain.com/files
rm -rf /var/www/forum-new.mydomain.com/store
mv /var/www/forum.mydomain.com/config.php /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/images /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/files /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/store /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com /var/forum-old.mydomain.com
mv /var/www/forum-new.mydomain.com /var/www/forum.mydomain.com
cd /var/www/forum.mydomain.com
php ./bin/phpbbcli.php db:migrate --safe-mode
rm -rf /var/www/forum.mydomain.com/install
chown www-data:www-data /var/www/forum.mydomain.com/* -R
phpBB 3.0.14 to 3.1.10

Code: Select all

cd /tmp
wget https://download.phpbb.com/pub/release/3.1/3.1.10/phpBB-3.1.10.zip
mkdir /tmp/t
unzip /tmp/phpBB-3.1.10.zip -d /tmp/t
mv /tmp/t/phpBB3 /var/www/forum-new.mydomain.com
rm -rf /var/www/forum-new.mydomain.com/config.php
rm -rf /var/www/forum-new.mydomain.com/images
rm -rf /var/www/forum-new.mydomain.com/files
rm -rf /var/www/forum-new.mydomain.com/store
mv /var/www/forum.mydomain.com/config.php /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/images /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/files /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/store /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com /var/www/forum-old.mydomain.com
mv /var/www/forum-new.mydomain.com /var/www/forum.mydomain.com
cd /var/www/forum.mydomain.com
php ./bin/phpbbcli.php db:migrate --safe-mode
rm -rf /var/www/forum.mydomain.com/install
chown www-data:www-data /var/www/forum.mydomain.com/* -R
phpBB 3.1.10 to 3.2.0

Code: Select all

cd /tmp
wget https://download.phpbb.com/pub/release/3.2/3.2.0/phpBB-3.2.0.zip
mkdir /tmp/t
unzip /tmp/phpBB-3.2.0.zip -d /tmp/t
mv /tmp/t/phpBB3 /var/www/forum-new.mydomain.com
rm -rf /var/www/forum-new.mydomain.com/config.php
rm -rf /var/www/forum-new.mydomain.com/images
rm -rf /var/www/forum-new.mydomain.com/files
rm -rf /var/www/forum-new.mydomain.com/store
mv /var/www/forum.mydomain.com/config.php /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/images /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/files /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com/store /var/www/forum-new.mydomain.com/.
mv /var/www/forum.mydomain.com /var/www/forum-old.mydomain.com
mv /var/www/forum-new.mydomain.com /var/www/forum.mydomain.com
cd /var/www/forum.mydomain.com
php ./bin/phpbbcli.php db:migrate --safe-mode
rm -rf /var/www/forum.mydomain.com/install
chown www-data:www-data /var/www/forum.mydomain.com/* -R

Post Reply