How to Install phpBB with Nginx (LEMP) on Ubuntu 20.04

phpBB is one of the most extended open-source forum bulletin software on the market. With the rise of social media platforms such as Reddit, Facebook, Twitter, and online chat platforms such as discord, we have seen online bulletin forum communities dwindle. Personally, it seems they are slowly making a comeback in specific niche communities over the newer additions, as I just mentioned.

phpBB isn’t the only option. Others such as VBulletin, Nodebb, Xenforo, and so on, but most of these are paid with mixed reviews. VBulletin used to be a powerhouse, but now it’s a shadow of its former self. Xenforo is one of the best-paid bulletin pieces of software. However, that is just my personal opinion, but I will always choose phpBB first as it’s free, open-source, and has some great 3rd party open-source developers, both new devs and ones that have been around since the start.

Today we will look at installing phpBB on our server, along with the first few steps in the initial setup in the Administrator control panel. Please note the below guide does not explain how to install NGINX, MariaDB, or PHP 7.4 and assumes you have this in working order. We will release additional articles on how to install LEMP in time with a complete setup.

Step 1. Pre-phpBB Installation

Firstly we need to check we have the PHP-7.4 prerequisites installed. We recommend using ondrej/PHP over the default Ubuntu installed repository as it’s more up to date and ondrej is the main dev who works on PHP and Debian. Hence, the packages are a pretty safe bet to use his repository as it’s more up-to-date.

sudo add-apt-repository ppa:ondrej/php
phpBB Ubuntu 20.04 install ondrey ppa hit enter

Hit enter to install the custom PPA.

If you would like to remove it in the future, do so by the following:

sudo apt install ppa-purge \
sudo ppa-purge ppa:ondrej/php

Next, we install the prerequisites.

sudo apt install php7.4-fpm php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-gd php7.4-xml php7.4-intl php7.4-mysql php7.4-cli php7.4-ldap php7.4-zip php7.4-mcrypt php7.4-curl php7.4-json php7.4-opcach php7.4-readline php7.4-xml php7.4-gd unzip -y

Secondly, after installing the prerequisites, we need to make sure we have our system up to date as many ondrej’s PPA is more ahead of Ubuntu’s default in several other supporting packages.

sudo apt update && sudo apt full-upgrade -y

Main phpBB Installation

To install phpBB, it is recommended to modify /etc/php7.4/fpm/php.ini and adjust the following. Please note you can have higher numbers, but this is recommended as a minimum:

max_execution_time = 180
max_input_time = 60
memory_limit = 256M
upload_max_filesize = 64M

Optional, while you are editing your php.ini, you can edit, find and change some of those below to harden your server. Remember to remove ; to uncomment the line:

session.use_strict_mode = 1
session.use_cookies = 1
session.cookie_secure = 1
session.use_only_cookies = 1 = BBCookies (Change the name, example: POPme)
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain = (example only)
session.cookie_httponly = 1
session.cookie_samesite = Strict

A critical aspect you must set if you are going to use the add-on for phpBB for auto back-ups is setting a time zone in PHP FPM and PHP CLI. You can copy and paste all these settings and the ones above between both php.ini files:

php lemp time zone

Now we proceed to make a database for your forums using MariaDB terminal input:

sudo mysql -u root -p

Then create the database name. It recommended you do not use phpbb as the name if you potentially will add additional forums to this database, name the database uniquely:


Create a database user called phpbbuser with a new password:

CREATE USER 'phpbbuser'@'localhost' IDENTIFIED BY 'new_password_here';

Then we grant the user full access to the database by doing the following:

GRANT ALL ON phpbb.* TO 'phpbbuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;

Finally, we save our changes and exit:


Moving on to the next part, we are going to download phpBB’s latest release. As of the date 24/05/2021, phpBB’s stable version is 3.3.4, released in April 2021. Stable releases vary from 3 to 6 months. We download phpBB doing as below:

cd /tmp &&


sudo mv phpBB3 /var/www/html/phpbb

While performing the move, you can name the folder anything you like, we used /www/html/phpbb, for example only, but it could be /www/html/bytesboss-forums.

Now we need to modify the directory permission for NGINX:

sudo chown -R www-data:www-data /var/www/html/phpbb
sudo chmod -R 755 /var/www/html/phpbb

Configure NGINX

Now we move into editing NGINX forums site config:

Add the upstream socket for PHP7.4-FPM first before the server part:

upstream phpbb {
server unix:/run/php/php7.4-fpm.sock;

Next, in our Server tab, we add the following:

location / {
	try_files $uri $uri/ @rewriteapp;

	# Pass the php scripts to FastCGI server specified in upstream declaration.
	location ~ \.php(/|$) {
		include fastcgi.conf;
		fastcgi_split_path_info ^(.+\.php)(/.*)$;
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
		fastcgi_param DOCUMENT_ROOT $realpath_root;
		try_files $uri $uri/ /app.php$is_args$args;
		fastcgi_pass phpmmo;
		fastcgi_intercept_errors on;	

	# Deny access to internal phpbb files.
	location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) {
		deny all;
		# deny was ignored before 0.8.40 for connections over IPv6.
		# Use internal directive to prohibit access on older versions.

location @rewriteapp {
	rewrite ^(.*)$ /app.php/$1 last;

# Correctly pass scripts for installer
location /install/ {
	try_files $uri $uri/ @rewrite_installapp =404;

	# Pass the php scripts to fastcgi server specified in upstream declaration.
	location ~ \.php(/|$) {
		include fastcgi.conf;
		fastcgi_split_path_info ^(.+\.php)(/.*)$;
		fastcgi_param PATH_INFO $fastcgi_path_info;
		fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
		fastcgi_param DOCUMENT_ROOT $realpath_root;
		try_files $uri $uri/ /install/app.php$is_args$args =404;
		fastcgi_pass phpmmo;
		fastcgi_intercept_errors on;	

location @rewrite_installapp {
	rewrite ^(.*)$ /install/app.php/$1 last;

# Deny access to version control system directories.
location ~ /\.svn|/\.git {
	deny all;

Example in Microsoft Visual Studio edit of what it will look like roughly, this isn’t the entire configuration file but is for illustration only:

phpBB Ubuntu 20.04 install microsoft visual nginx server config example only

Next, we enable the site in NGINX:

sudo ln -s /etc/nginx/sites-available/phpbb /etc/nginx/sites-enabled/

Test NGINX before a complete restart:

sudo nginx -t

No errors, then you can proceed to restart the NGINX instance:

sudo systemctl restart nginx

Configure phpBB and final install.

If everything has worked correctly, we now move to the nominated address of your freshly installed phpBB forums. For our example, it is, and if successful, you will see the following screen:

phpBB Ubuntu 20.04 install first page

If you see this, hit install and proceed to the next screen, which will be very similar, and you also hit install again, example below:

phpBB Ubuntu 20.04 install second page

Now we enter our first page, where we need to input some credentials. Firstly we need to make the Site-Owner/Admin as highlighted below. Make sure you make the password secure and hit submit:

phpBB Ubuntu 20.04 install enter admin details, create and hit submit

Once you have entered your Admins details successfully, we move onto the database details. In our example, we named our database bbforums and database prefix bbforums_ however, the default phpbb and phpbb_ will do, but as stated earlier, we recommend changing this.

Database hostname is simply localhost for most installs on the same server, if not, you would put the remote database IP in and enter the database username/password we made earlier in the guide.

phpBB Ubuntu 20.04 install enter database details made with mariadb

Set your server configuration. The default settings should not need changing right now for most installs unless you are not running on SSL. Hit next:

phpBB Ubuntu 20.04 install set cookies and ssl settings if needed

Next page, you can set up SMTP if you would like. If not, leave defaults and hit next.

phpBB Ubuntu 20.04 install set smtp settings if needed

Set your Board Name / Title and Language. If you are unsure what to name your forums, leave defaults and hit submit. You can change these settings later.

phpBB Ubuntu 20.04 install set title of board, description and default language

After hitting submit, you should see a final screen similar to below with the forums installed and a link taking you to the ACP panel. If you have errors refer back to this guide, especially regarding permissions:

phpBB Ubuntu 20.04 install final success page

Post Set Up Config

Congrats on getting to this part. After logging into your ACP panel for the first time, you will see a friendly big red alert telling you to remove or rename your install directory. BytesBoss recommends you delete it with the following command in the terminal:

sudo rm -R /var/www/html/phpbb/install
phpBB Ubuntu 20.04 post config warning to delete or rename install directory

While you are active doing terminal commands for your phpBB folder, It is critical after the installation. We set correct chmod permissions. The official phpBB guide on this can be found here. Skipping this can leave open some significant security risks, so please follow this precisely or in your way if you have a better technique but do not leave the default permissions!!

sudo find /var/www/html/phpbb -type d -exec chmod 755 {} \;
sudo find /var/www/html/phpbb -type f -exec chmod 644 {} \;

Afterwards, we need to give some folders/files some special permissions only as follows:

sudo chmod 777 -R /var/www/html/phpbb/files
sudo chmod 777 -R /var/www/html/phpbb/cache
sudo chmod 777 -R /var/www/html/phpbb/store
sudo chmod 777 -R /var/www/html/phpbb/images/avatars/upload

Failure to do this will break the functions of your board. Make sure you follow these paths strictly, or re-give your entire phpBB directory full read and write access back to the public, re-causing a security problem.

The final last step in our guide is to set up a cronjob. Cronjobs are recommended on busy and slow forums to set up cron jobs to run every 5 minutes by phpBB standards. We can do this two ways

Bring up crontab:

sudo crontab -e

First cronjob option:

* * * * * cd "/path/to/board"; ./bin/phpbbcli.php cron:run

This may come into conflict and not work possibly, a solution is to CD into /bin/phpbbcli.php and add chmod +x, or I have seen some threads in phpBB forum’s suggesting setting it to 755 chmod permission, but this leaves a security loophole. If you do not want to do this, then do the following:

* * * * * curl -A=Mozilla/4.0

Example of how it may look below:

phpBB Ubuntu 20.04 post config cronjab, crontab example

Don’t forget to go to enable this in your Server Settings as the example below:

phpBB Ubuntu 20.04 post config set run periodic tasks in cron on server settings page in acp panel

Congrats, you have successfully installed phpBB forums, set up a cronjob, and you are ready to go designing your forums and pushing your changes.

I would recommend checking out phpBB’s official website and wiki as it contains much information about customization of your forums which would be too much to put in this guide we have created here.
Example of the default look once installed:

phpBB Ubuntu 20.04 post config first look

Comments and Conclusion:

phpBB is a tried and tested open source free software that does not appear it’s disappearing anytime soon. As for security, the phpBB team indicates having no CVE’s for years and, when investigating possible breaches, found users not focusing on “secure” installs, such as some of the steps we pointed out in the guide like chmod permissions. I never had an issue with a robust, hardened server, phpBB initial set up.

The 3rd party community is pretty good. A few of these to look at are SplickerSnap and DMZX, but I could list 20 or so more worthy of being mentioned.

I know this guide was long, but I hope it has helped. I will update this guide with any feedback I get. Please let me know how you go in your phpBB setup. Good luck!


Like to get automatic updates? Follow us on one of our social media accounts!