This section contains detailed articles elaborating on some of the common issues phpBB users encounter while using the product. Articles submitted by members of the community are checked for accuracy by the relevant phpBB Team. If you do not find the answer to your question here, we recommend looking through the Support Section as well as using the Site Wide Search.

Rebuilding Your config.php File

Description: I deleted my config.php file--Help! This tutorial will help you get back on your feet.

In Categories:

Link to this article: Select All
[url=https://www.phpbb.com/support/docs/en/3.1/kb/article/rebuilding-your-configphp-file/]Knowledge Base - Rebuilding Your config.php File[/url]

Rebuilding the phpBB 3.1/3.2/3.3 config.php
So you have accidentally deleted your board's config.php file, and now your board is not usable; or you have installed and the config.php file did not get written because of incorrect file permissions. In both instances the files and database are still present and functional, they just have no way of connecting to each other. The trick here is not to panic and do something rash such as reinstalling the board. The config.php file is very easily recreated manually, if you have your database details at hand.

So lets look at creating a new config.php file.
  • To create a new config.php file you will need to use a plain text editor, such as, Notepad++. For some other text editor suggestions see, Tools needed to set up and customise phpBB.
  • Open your chosen editor and select to create a new file.
  • Into this fresh file paste the following code

    Code: Select all

    <?php
    // phpBB 3.2.x auto-generated configuration file
    // Do not change anything in this file!
    $dbms = 'phpbb\\db\\driver\\mysqli';
    $dbhost = 'database host/domain';
    $dbport = 'database port if not default';
    $dbname = 'dataname name';
    $dbuser = 'database user name';
    $dbpasswd = 'database password';
    $table_prefix = 'database table prefix';
    $phpbb_adm_relative_path = 'adm/';
    $acm_type = 'phpbb\\cache\\driver\\file';
    
    @define('PHPBB_INSTALLED', true);
    // @define('PHPBB_DISPLAY_LOAD_TIME', true);
    @define('PHPBB_ENVIRONMENT', 'production');
    // @define('DEBUG_CONTAINER', true);
    
    
  • You now have your blank config template pasted into your file, now you will need to edit various parts of it so it contains your database details.
  • It is worth noting that if you do not know your database details you will have to seek your hosts support in acquiring them. In nearly all instances the details will be the same as what you used when completing the installation form when originally installing the board.
    • $dbms = 'phpbb\\db\\driver\\mysqli'; Replace mysqli (usually the default) with your database type, you have various different types of database you could be using. If you're unsure about which database type applies to you, ask your host or start a topic in our Support Forums.
      Valid options for 3.1:
      • phpbb\\db\\driver\\mysql
      • phpbb\\db\\driver\\mysqli
      • phpbb\\db\\driver\\mssql
      • phpbb\\db\\driver\\mssql_odbc
      • phpbb\\db\\driver\\mssqlnative
      • phpbb\\db\\driver\\oracle
      • phpbb\\db\\driver\\postgres
      • phpbb\\db\\driver\\sqlite
      • phpbb\\db\\driver\\sqlite3
      Valid options for 3.2:
      • phpbb\\db\\driver\\mysql
      • phpbb\\db\\driver\\mysqli
      • phpbb\\db\\driver\\mssql_odbc
      • phpbb\\db\\driver\\mssqlnative
      • phpbb\\db\\driver\\oracle
      • phpbb\\db\\driver\\postgres
      • phpbb\\db\\driver\\sqlite3
      Valid options for 3.3:
      • phpbb\\db\\driver\\mysqli
      • phpbb\\db\\driver\\mssql_odbc
      • phpbb\\db\\driver\\mssqlnative
      • phpbb\\db\\driver\\oracle
      • phpbb\\db\\driver\\postgres
      • phpbb\\db\\driver\\sqlite3
    • $dbhost = 'database host/domain'; Replace database host/domain with the host/domain address of your database server. Many hosts will use localhost in this field, but check with your host.
    • $dbport = 'database port if not default'; Replace database port if not default with the port number your database server uses to accept connections. If your database server uses the default port leave this option blank. You only need to enter a value here if your database server is not using the default port.
    • $dbname = 'database name'; Replace database name with the name of the database you installed the phpBB3 board tables into. If you have phpmyadmin access to your databases you may be able to find this out from looking there, otherwise contact your host for help with this.
    • $dbuser = 'database user name'; Replace database user name with the user name of the database user account. All databases need a user account which is used to connect to them, the user name of this user account is what needs to be entered into this field.
    • $dbpasswd = 'database password'; Replace database password with the password of the database user account. All databases need a user account which is used to connect to them, the user password of this user account is what needs to be entered into this field.
    • $table_prefix = 'database table prefix'; Replace database table prefix with the prefix of the database tables. On a default install where this is not changed it will be phpbb_ however you may have changed this when installing original so double check. This is something else you may be able to determine by looking at the database table in phpmyadmin. Make sure not to forget entering the underscore character (which is _ ) when entering your database prefix.
  • The following options are things you do not need to alter or worry about when recreating your config.php, just make sure they are present in the state listed below.
    • $phpbb_adm_relative_path = 'adm/';
    • $acm_type = 'phpbb\\cache\\driver\\file';
    • @define('PHPBB_INSTALLED', true);
    • // @define('PHPBB_DISPLAY_LOAD_TIME', true);
      • Only valid for phpBB 3.1 and 3.2
    • // @define('DEBUG', true);
      • Only valid for phpBB 3.1 and 3.2
    • // @define('DEBUG_CONTAINER', true);
      Un-commenting (removing //) one of more of the last three lines above will give you the page load times at the bottom of the boards index page and other debugging information.
  • Once you have complete editing the file you will need to save it as config.php making sure that the plain text editor did not save it as config.txt or config.php.txt.
  • Now you have your newly created config.php you will need to upload it using your ftp client. It will need to be uploaded into the phpBB3 forum folder so it is in the same location as the boards common.php file.
  • In most cases your ftp client will set the correct file permissions but you should check that the file has been chmod to 644, which you had to do when installing as well. Note though that this only applies when using a Unix based web server.
  • As a last step, delete all files from your cache directory on your server except for .htaccess and index.htm. Configuration data is cached in phpBB and will only take effect once the cache has been purged.
Remember that when creating the config.php you can have nothing before the starting <?php tag at the beginning of the file. This includes blank lines or spaces, absolutely nothing can be before the <?php tag of the file. The last line of the file needs to be an empty line, a ?> is not needed.

20071009 - re-written karlsemple
20120821 - removed suggestion to use Windows Notepad - Oyabun1
20160722 - rewritten to have the correct instructions for the 3.1.x config.php file - JimA
20170910 - updated to include some constants added in 3.2.x while also staying relevant for 3.1.x - JimA