Author: Tung NguyenLast Updated: Mon, Oct 4, 2021
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.
Deploy an Ubuntu 20.04 server with the LAMP stack.
(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.
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:
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.ini
; before the
zend_extension=xdebug.so directive, as shown.
Save the file and exit.
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-timezones
Copy 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_York
Edit the PHP-FPM configuration file to tell PHP to use the new time zone.
$ sudo nano /etc/php/7.4/fpm/pool.d/www.conf
date.timezone directive, then change its value from
UTC to your time zone, as shown.
php_admin_value[date.timezone] = America/New_York
Save the configuration file and exit.
Check the new configuration.
$ sudo php-fpm7.4 -t
Connect to the MariaDB command line as the MariaDB
$ sudo mariadb
Create a new
dbname database for phpBB.
MariaDB [(none)]> CREATE DATABASE dbname;
Create a MariaDB user named
dbuser and grant it all privileges to the
dbname database. Replace
dbpassword with 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
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.gz
At 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.gz
Change the working directory to the public code directory.
$ cd phpbb-release-3.3.4/phpBB
The extracted directory already has the
composer.phar program. Use it to install dependencies.
$ ../composer.phar install --no-dev -o
Sync the public code directory to the
/var/www/html document root directory and delete all existing files there.
$ sudo rsync -a --delete ./ /var/www/html
www-data the owner of
/var/www/html so that Apache and PHP can access the directory.
$ sudo chown -R www-data:www-data /var/www/html
Delete the downloaded archive and the extracted directory.
$ cd ~ $ rm -fr phpbb-release-3.3.4/ release-3.3.4.tar.gz
Open the default virtual host configuration file.
$ sudo nano /etc/apache2/sites-enabled/http.conf
Any 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.
ServerName directive, remove the leading
# character, and change its value to your server's fully qualified domain name or IP address, as shown.
Save the configuration file and exit.
Check the new configuration. Make sure you see
Syntax OK in the output.
$ sudo apache2ctl configtest
Disable the default HTTPS configuration.
$ sudo a2dissite https.conf
Reload Apache to activate the new configuration.
$ sudo systemctl reload apache2.service
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 Vultr guide to install Certbot with Snap.
Run Certbot to get and install a Let's Encrypt certificate for Apache. Replace email@example.com with your email if needed.
$ sudo certbot --apache --redirect -d phpbb.example.com -m firstname.lastname@example.org --agree-tos --no-eff-email
Certbot 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.
Restart the server.
$ sudo reboot
Wait a moment for the operating system to boot.
Open your browser and type in the
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
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
$ sudo rm -fr /var/www/html/docs
Prevent unintended changes to the
$ sudo chmod 644 /var/www/html/config.php $ sudo chown root:root /var/www/html/config.php
install directory to activate phpBB.
$ sudo rm -fr /var/www/html/install
You have successfully installed phpBB. Now your forum is ready to serve visitors.
To learn more about phpBB, please see these resources: