Introduction
phpBB is one of the oldest open source forum software that is still actively developed today. This guide explains how to install phpBB with Apache, MariaDB, and PHP on Ubuntu 20.04 and set up HTTPS with a free Let's Encrypt TLS certificate.
Prerequisites
- Deploy an Ubuntu 20.04 server with the LAMP stack.
- Follow Rcs's best practices guides to create a sudo user and update the Ubuntu server.
- (Optional) Configure the Ubuntu firewall with ports 80, 443, and 22 open.
Make sure to replace phpbb.example.com in the code examples with your server's fully qualified domain name or IP address.
1. Install Software Packages
phpBB requires the following software:
- A web server such as Apache.
- A SQL database system such as MariaDB.
- PHP 7.1.3 up to and including PHP 7.4.
- The following PHP modules:
json,mbstring, andxml- (optional)
gd
Your LAMP server comes with Apache 2.4, MariaDB 10.3, and PHP 7.4 pre-installed, so you only need to install the necessary PHP modules.
Log in to the server as a non-root sudo user via SSH.
Install the required modules.
$ sudo apt -y install php7.4-gd php7.4-json php7.4-mbstring php7.4-xml
For production use, you should disable the pre-installed Xdebug module, as it reduces PHP performance.
Open the Xdebug module configuration file.
$ sudo nano /etc/php/7.4/mods-available/xdebug.iniPut
;before thezend_extension=xdebug.sodirective, as shown.;zend_extension=xdebug.soSave the file and exit.
2. Configure Time Zone
Your LAMP server is pre-configured with the UTC timezone. If you want to use a different timezone, follow these instructions.
List all the time zones that the operating system supports. Use the Up / Down keys to move through the list, and press Q to exit.
$ timedatectl list-timezonesCopy an appropriate time zone from the list, for example, America/New_York. Then update the system with that time zone.
$ sudo timedatectl set-timezone America/New_YorkEdit the PHP-FPM configuration file to tell PHP to use the new time zone.
$ sudo nano /etc/php/7.4/fpm/pool.d/www.confFind the
date.timezonedirective, then change its value fromUTCto your time zone, as shown.php_admin_value[date.timezone] = America/New_YorkSave the configuration file and exit.
Check the new configuration.
$ sudo php-fpm7.4 -t
3. Create a Database
Connect to the MariaDB command line as the MariaDB
rootuser.$ sudo mariadbCreate a new
dbnamedatabase for phpBB.MariaDB [(none)]> CREATE DATABASE dbname;Create a MariaDB user named
dbuserand grant it all privileges to thedbnamedatabase. Replacedbpasswordwith a strong password.MariaDB [(none)]> GRANT ALL PRIVILEGES on dbname.* to 'dbuser'@'localhost' IDENTIFIED BY 'dbpassword'; MariaDB [(none)]> FLUSH PRIVILEGES;Exit the MariaDB command line.
MariaDB [(none)]> exit
4. Install phpBB
Download the source code archive from GitHub to the home directory.
$ cd ~ $ wget https://github.com/phpbb/phpbb/archive/refs/tags/release-3.3.4.tar.gzAt the time of writing, the latest stable version of phpBB is 3.3.4. But, of course, you can always visit the phpBB releases page to get the latest version.
Extract the archive.
$ tar xzf release-3.3.4.tar.gzChange the working directory to the public code directory.
$ cd phpbb-release-3.3.4/phpBBThe extracted directory already has the
composer.pharprogram. Use it to install dependencies.$ ../composer.phar install --no-dev -oSync the public code directory to the
/var/www/htmldocument root directory and delete all existing files there.$ sudo rsync -a --delete ./ /var/www/htmlMake
www-datathe owner of/var/www/htmlso that Apache and PHP can access the directory.$ sudo chown -R www-data:www-data /var/www/htmlDelete the downloaded archive and the extracted directory.
$ cd ~ $ rm -fr phpbb-release-3.3.4/ release-3.3.4.tar.gz
5. Configure Apache
Open the default virtual host configuration file.
$ sudo nano /etc/apache2/sites-enabled/http.confAny string that begins with
#is a comment.Paste the following directives below the
<VirtualHost *:80>line.<Directory /var/www/html/cache/*> Require all denied </Directory> <Directory /var/www/html/cache> Require all denied </Directory> <Directory /var/www/html/files/*> Require all denied </Directory> <Directory /var/www/html/files> Require all denied </Directory> <Directory /var/www/html/includes/*> Require all denied </Directory> <Directory /var/www/html/includes> Require all denied </Directory> <Directory /var/www/html/phpbb/*> Require all denied </Directory> <Directory /var/www/html/phpbb> Require all denied </Directory> <Directory /var/www/html/store/*> Require all denied </Directory> <Directory /var/www/html/store> Require all denied </Directory> <Directory /var/www/html/vendor/*> Require all denied </Directory> <Directory /var/www/html/vendor> Require all denied </Directory>These directives prevent users from accessing sensitive files.
Find the
ServerNamedirective, remove the leading#character, and change its value to your server's fully qualified domain name or IP address, as shown.ServerName phpbb.example.comSave the configuration file and exit.
Check the new configuration. Make sure you see
Syntax OKin the output.$ sudo apache2ctl configtestDisable the default HTTPS configuration.
$ sudo a2dissite https.confReload Apache to activate the new configuration.
$ sudo systemctl reload apache2.service
6. (Optional) Configure HTTPS
If you own a valid domain name, you can set up HTTPS for your phpBB website at no cost. You can get a free TLS certificate from Let's Encrypt with their Certbot program.
Follow the Install Certbot section of this Rcs guide to install Certbot with Snap.
Run Certbot to get and install a Let's Encrypt certificate for Apache. Replace admin@phpbb.example.com with your email if needed.
$ sudo certbot --apache --redirect -d phpbb.example.com -m admin@phpbb.example.com --agree-tos --no-eff-emailCertbot has also set up a systemd timer to renew this certificate automatically. Run the following command to verify the timer is active.
$ systemctl list-timers | grep 'certbot\|ACTIVATES'
Now your phpBB website can get an "A" rating on the SSL Labs test.
7. Complete the Setup
Restart the server.
$ sudo rebootWait a moment for the operating system to boot.
Open your browser and type in the
http://phpbb.example.comURL.The phpBB installation page appears. Click the INSTALL tab, then click the Install button.
The Administrator configuration form appears. Enter the administrator username, email, and password of your choice, then click the Submit button.
The Database configuration form appears.
- For the Database type option, select MySQL with MySQLi Extension.
- For the Database server hostname or DSN option, enter
localhost. - For the Database server port option, leave it empty.
- For the Database username, Database password, and Database name options, enter the corresponding values you created in Section 3.
- For the Prefix for tables in database option, accept the default value.
Then click the Submit button.
Accept all the default values for the remaining forms, and click the Submit button.
Once completed, click the ACP link to access Administration Control Panel (ACP). ACP provides all kinds of settings for you to customize most of your phpBB features. For more details, read the phpBB Administration Guide.
Log in to the server as a non-root sudo user via SSH again.
Delete the unnecessary
docsdirectory.$ sudo rm -fr /var/www/html/docsPrevent unintended changes to the
config.phpfile.$ sudo chmod 644 /var/www/html/config.php $ sudo chown root:root /var/www/html/config.phpDelete the
installdirectory to activate phpBB.$ sudo rm -fr /var/www/html/install
You have successfully installed phpBB. Now your forum is ready to serve visitors.
References
To learn more about phpBB, please see these resources: