Home > Help Center > Applications > Other Applications > WordPress Configuration File wp-config.php

WordPress Configuration File wp-config.php

WordPress keeps all information about each individual site in a database.

During the installation process, the WordPress copies a wp-config-sample.php file from the root directory as wp-config.php file and writes all site-specific information including database access data in this new file.

wordpress configuration file

Note: The contents of the wp-config-sample.php file are in a very specific order. The order matters. If you already have a wp-config.php file, rearranging the contents of the file may create errors on your website.

Here is the original content of wp-config-sample.php without comments:

wordpress configuration file

If you delete or rename wp-config.php for a test, whether you are trying to log in to the administration or load the site, you will get the following error: Error establishing a database connection.

Important: Never use a word processor like Microsoft Word or Google Docs for editing WordPress files!

The basic installation of WordPress contains the minimum settings allowing the administrator to continue building a unique custom site.

In this article, we'll show you a few additional settings you can add to wp-config.php.

MySQL Alternate Port

If your host uses an alternate port number for your database you'll need to change the DB_HOST value in the wp-config.php file to reflect the alternate port provided by your host.

For localhost:

define( 'DB_HOST', '127.0.0.1:3307' );

define( 'DB_HOST', 'localhost:3307' );

For specified server:

define( 'DB_HOST', 'mysql.example.com:3307' );

Replace 3307 with whatever port number your host gives you.

MySQL Sockets or Pipes

If your host uses Unix sockets or pipes, adjust the DB_HOST value in the wp-config.php file accordingly:

define( 'DB_HOST', '127.0.0.1:/var/run/mysqld/mysqld.sock' );

define( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' );

define( 'DB_HOST', 'example.tld:/var/run/mysqld/mysqld.sock' );

Replace /var/run/mysqld/mysqld.sock with the socket or pipe information provided by your host.

Adding Extra Code

If you need to add in extra lines, find this comment:

/* That's all, stop editing! Happy blogging. */

Don't put anything below that line. While it may work, it has a tendency to cause problems.

Disable the Plugin and Theme Editor

Occasionally you may wish to disable the plugin or theme editor to prevent users from being able to edit sensitive files and potentially crash the site. Disabling these also provides an additional layer of security:

define( 'DISALLOW_FILE_EDIT', true );

Autosave Interval

When editing a post, WordPress uses Ajax to auto-save revisions to the post as you edit. You may want to increase this setting for longer delays in between auto-saves, or decrease the setting to make sure you never lose changes. The default is 60 seconds.

define('AUTOSAVE_INTERVAL', 180 );

Post Revisions

WordPress, by default, will save copies of each edit made to a post or page, allowing the possibility of reverting to a previous version of that post or page. The saving of revisions can be disabled, or a maximum number of revisions per post or page can be specified.

Disables post revisions (default is true):

define('WP_POST_REVISIONS', false );

Changes the number of revisions (default is unlimited):

define('WP_POST_REVISIONS', 3);

Note: Some users could not get this to function until moving the command to the first line under the initial block comment in wp-config.php.

Disable Javascript Concatenation

To result in a faster administration area, all Javascript files are concatenated into one URL. If Javascript is failing to work in your administration area, you can try disabling this feature:

define( 'CONCATENATE_SCRIPTS', false );

Language and Language Directory

WordPress v3.9.x and below use WPLANG and WP_LANG_DIR to define WordPress administration screens language:

define( 'WPLANG', 'de_DE' );

define( 'WP_LANG_DIR', dirname(__FILE__) . '/wordpress/languages' );

To find out the WPLANG language code, please refer to polyglots teams.

Note: WPLANG was deprecated in WordPress 4.0.

Now you can change the language in the admin settings screen by going to Settings > General and selecting Site Language.

Summary

Be extra careful when edit wp-config.php file and always make backup before you start editing.

A detailed tutorial on editing wp-config.php can be found here.

#wordpress #settings

Still not finding what you're looking for?

Contact our support team with any additional questions or concerns.

Contact support