How to re-create your config.php file

Occasionally I have a client whose config.php file gets deleted. This happened most recently to a client using GoDaddy for their hosting.

It’s hard to say why GoDaddy deleted it, but it wasn’t recoverable. If I had to guess, it’s because like most web hosts GoDaddy assumes everyone is running WordPress, which means phpBB gets short shrift.

Anyhow, it was gone and needed to be re-created but she had no idea how to do it. She did figure out its purpose. The config.php file sits in your phpBB root folder and its primary purpose is to connect your phpBB board with the correct database. So it’s absolutely essential and phpBB won’t work without it.

Start with an example file

Unfortunately, the config.php file is empty when setting up phpBB and gets created when you run the installation wizard. But here’s an example of a properly configured config.php file:

<?php
// phpBB 3.3.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'phpbb\\db\\driver\\mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'phpbb';
$dbuser = 'forum';
$dbpasswd = 'password123';
$table_prefix = 'phpbb_';
$phpbb_adm_relative_path = 'adm/';
$acm_type = 'phpbb\\cache\\driver\\file';

@define('PHPBB_INSTALLED', true);
@define('PHPBB_ENVIRONMENT', 'production');
// @define('DEBUG_CONTAINER', true);

You can use your web host’s file manager to copy and paste this text. Obviously it will need some editing. You can also create it on your computer and upload it when done.

Check your database management system

Most phpBB board are installed on a mySQL or MariaDB database management system. If so, leave the $dbms line unchanged. MariaDB is virtually identical to mySQL so it will use mySQL drivers. Otherwise you need to change this line to use your database management system. Use the following values:

$dbms = 'phpbb\\db\\driver\\mysqli'; // Use for mySQL or MariaDB
$dbms = 'phpbb\\db\\driver\\postgres'; // Use for Postgres
$dbms = 'phpbb\\db\\driver\\oracle'; // Use for Oracle
$dbms = 'phpbb\\db\\driver\\sqlite3'; // Use for SQLite
$dbms = 'phpbb\\db\\driver\\mssqlnative'; // Use for Microsoft SQL Server Native Driver
$dbms = 'phpbb\\db\\driver\\mssql_odbc'; // Use for Microsoft SQL Server ODBC Driver
$dbms = 'phpbb\\db\\driver\\mssql_base'; // Use for Microsoft SQL Server Base Driver

Check your host name

Generally, you don’t need to change your $dbhost line from localhost. If your database exists on a machine separate from the webserver, you’ll have to change it. You can often get this information in your web host control panel.

If all the other information is correct and you cannot connect, you will know this line has to be changed. Ask your web host the exact machine name if necessary. On my DreamHost hosting, it’s on a different machine, mysql.phpbbservices.com in my case. Simply edit the line if needed placing the machine name between the single quotes. You should not preface the machine name with http:// or https://.

Check your database port

You generally leave the $dbport line unchanged. The default database port for the database management system is used. For example, with mySQL it’s 3306. If the null string is set, the default port will be used. You can ask your web host if necessary if a different port should be used, but this is extremely unusual.

Find your database name

Generally you can use a web host control panel program like phpMyAdmin to browse your databases and determine the database name. Be careful. You may have old phpBB databases and you want to choose the right one. You can look at the number of rows in the posts table using a utility like phpMyAdmin to help you decide. Generally the database with the most rows in this table is the correct database to use. Replace the $dbname line with the correct database name, placing it between the single quotes.

Find your database user

The database user is not (usually) the same username you use to login to your board. This is the user that has privileges to access the database name found in the last step. Usually you can get this from your web host control panel.

In the most typical case, there is a MySQL databases icon you can click on. Find your database and see the username associated with the database. Replace the $dbuser line with the correct database user name, placing it between the single quotes.

This database user must have all privileges granted to your board’s database. You can check this in the same web interface.

If you have only command line access to your database, a short SQL query will show this information. For the configuration above and a mySQL database, for example, once logged into the database this command would work:

show grants for 'phpbb'@'localhost';

Set the database user’s password

If you don’t know the database user’s password, your web host control panel usually has an interface to change the database user’s existing password. Change it in this interface and replace $dbpasswd with the correct password, placing it between the single quotes.

Check the table prefix

If you used a utility like phpMyAdmin to browse your board’s tables, the $table_prefix line is easily discerned. All phpBB table must have the same prefix. The default is phpbb_. If yours is different, replace it with the correct prefix, placing it between the single quotes.

Save the file and test

Generally at this point you save the file. To test, simply run index.php on your board and it should come up. Any errors that come up will hopefully point to where the problem is.

Occasionally, you may need to manually purge the cache to bring up your board. Delete all files in the /cache/production folder using a tool like FTP or your web host’s file manager. If queue.php exists, deleting this will remove any emails scheduled to go out, so you may not want to delete this file. Then refresh the index.php page in your browser.

You may notice other lines at the bottom of the config.php line. Generally these are left alone. But if you moved certain folders from their default location you might have to change these lines.

Check the config.php files permissions

This file must not be publicly writeable, so minimally its permissions should be set to 644 on Linux-based systems. The phpBB Group recommends 640 permissions. You can use FTP or your web host control panel file manager to change its permissions.

May 2022 work summary

No question that this was a slow month. Having released a new edition of my book and having updated most of my extensions, there wasn’t much to fill in the slack. I did release version 3.3.15 of my digests extension, but the changes were very minor. And I released a development version of a Notify admin on new error log entry extension for comment.

For my large commercial client, we completed our own testing and patched a number of minor bugs. It now goes to a more formal internal review by the company.

For another long standing commercial client, I helped troubleshoot a number of issues. The server had been moved from one virtual private server to another some months back. This caused a Let’s Encrypt certificate issue to manifest itself. I don’t consider myself a system administrator but was able through trial and error in Plesk to figure it out. Essentially, the new server couldn’t work with an old package that kept Let’s Encrypt updated and I had to install a new one while figuring out why it kept complaining that the certificate was out of date. I also installed the Auto Groups extension to ensure newly registered users were put into a Subscribers group I created. Anyone in this group gets emails when new posts are made.

Other work in May:

  • A client’s sessions table needed repair. I repaired it then changed all tables to use the INNODB storage engine. I had to write a script to do this rather than use phpMyAdmin because the logged in phpMyAdmin user did not have the permissions to do this. I provided guidance on how to remove or reduce administrator permissions for a user.
  • Updated a board from phpBB 3.3.0 to 3.3.5. I also changed PHP from 7.2 to 8.1, which required enabling mysqli. I updated the parent Absolution style from version 3.3.0 to 3.3.5. I investigated a WordPress error but only noticed that there was a complaint in the dashboard that PHP 7.2 was no longer supported, so updating PHP to 8.0 solved that. A digest cron was disabled that had to be re-enabled. Had to increase the memory size for PHP to avoid a timeout manually running digests. The simple mentions extension required reparsing of tables to get it working again.
  • Rehosted a board with 330,000 posts and 43GB of files from Network Solutions to Dreamhost. Worked with customer to determine good plan on Dreamhost he picked a VPS solution. Customer moved files to Dreamhost because he has a much speedier connection than me, saving him some money and time. I loaded and moved events database and software (something I had written for him years ago, and sits outside of phpBB), updating the database connection statements so it would find the right database. I loaded this database from extract provided by customer. I then upgraded the board from phpBB 3.3.3 to 3.3.7. I upgraded the Add user extension from 1.0.4 to 1.0.5. I set up two email accounts on the new host. I changed the DNS to Dreamhost for the client. I also got email integrated again. This feature no longer worked on the old host. I installed a Let’s Encrypt SSL certificate. I remade the search index (chose MySQL fulltext) and disabled Google search extension, which was no longer needed.
  • I billed a client for miscellaneous work on a site he is relaunching since I last helped him in January. The work involved about three hours of answering questions mostly related to integrating phpBB forum feeds into WordPress. I installed two extensions: Smartfeed and Install External Link in New Windows. I later updated phpBB from 3.3.5 to 3.3.7 and the American English language pack to 4.7.0.
  • Performed a commercial upgrade from phpBB 3.0.11 to 3.3.7. No mods and no style issues to worry about and only 4000 posts. I disabled contact form. Set up and tested reCaptcha V3 spambot countermeasure. I disabled SMTP because of certificate mismatch issue. I set up home page link.