Using phpBB’s command line interface

Most forum administrators are unaware that phpBB has a command line interface (CLI). Most popular software solutions for the web have CLIs too, for example, WordPress. A CLI allows you to do from a command prompt a lot of tasks that would otherwise have to be done with a browser.

In fact most tasks, including upgrades, can be done through the browser, which may explain why phpBB’s CLI is often unknown. Also, to use the CLI you have to be able to connect remotely to your server, usually via Secure Shell (SSH). For those not technically inclined, this is a bit of a hurdle.

Also, for the most part, phpbb.com doesn’t say much about it, other than to allude to it. Nonetheless, it has its own set of instructions, fully detailed here.

Using SSH

If you are not familiar with using SSH, there may be a substantial learning curve. SSH is a method of connecting remotely to external servers using the command line.

But you can only use phpBB’s CLI if you web host supports access via SSH. Most do, but often it takes some digging to figure out how to do this. Often you have to use a supplied username and password, or upload a set of cryptographic keys. Generally though it’s straightforward once you learn a few things. You may have to ask your host if SSH is allowed. They will usually point you to their knowledge base where you can learn more.

Your computer needs a terminal program to access SSH. With Linux or a Mac, simply use the terminal app. Since Windows 10, this has been built into Windows. You can learn how to configure your Windows machine to use SSH here. Earlier versions of Windows can use Putty, a third-party application, to run SSH.

In the most typical case, once the right terminal program is running, the following command is used to connect via SSH:

ssh username@hostname.com

The standard port for SSH is 22. If you are told to use a different port, such as 2222, the command changes to:

ssh -p 2222 username@hostname.com

hostname.com can be a domain name or sometimes a special IP address provided by your web host.

You may have to authenticate with a password. If so, type in the password and press Enter or Return when done.

Typically you get a command prompt from the server if you login successfully, generally >.

If you need to exchange cryptographic keys, you may first have to upload or download some keys. You may have to reference the key as an argument for the command.

So it can be time consuming just to connect with SSH to your web host, but usually it’s straightforward.

Once connected, you need to navigate to the root folder of your phpBB installation. Assuming it’s /var/www/mydomain.com/board the following command would work:

cd /var/www/mydomain.com/board

If you are unsure what folder you are in, type:

pwd

CLI Basics

The CLI is the program /bin/phpbbcli.php. To run it you need to preface the command with php, so the php interpreter is run. Your web server and database server should be up to avoid errors.

From your phpBB root folder, try either of these commands:

php ./bin/phpbbcli.php list

or

php ./bin/phpbbcli.php help

If a path to php is not defined, you may have to preface php with its path, e.g.:

/bin/php ./bin/phpbbcli.php help

The version of PHP that you use should be compatible with the version used by your version of phpBB, generally PHP 7.1.3 or higher.

In some cases you must change the file permissions to phpbbcli.php to make it executable for it to work, ex:

chmod 644 ./bin/phpbbcli.php

What can I do from the phpBB command line?

The functionality from the CLI is just a small subset of what can be done through the web interface. It is most useful if you need to automate installing or upgrading phpBB. This method largely avoids potential timeouts and resource limitations doing it through the web interface.

But there are other commands available. For example, you can purge the cache:

php ./bin/phpbbcli.php cache:purge

The user command allows you to activate, add, delete or re-clean the usernames.

Extensions can be enabled and disabled through the interface.

phpBB’s cron is invoked through this command:

php ./bin/phpbbcli.php cron:run

You can also ask if your version of phpBB is up to date:

php ./bin/phpbbcli.php update:check

I recommend just playing with the CLI to gain some basic familiarity with it, then consider how you can use it as an administrator to make your life easier.

Leave a Reply

Your email address will not be published. Required fields are marked *