The WordPress wp-config.php file is the core configuration file that appears in your WordPress installation’s root directory. It is also known as a powerhouse of features.
So whether you are running a WordPress website or managing a website, you have to tweak this wp-config.php file in order to add more functionality to your website.
Now before modifying the file, you must have to get a clear concept about each line of the file and its function.
Today, we will explain what is the wp-config.php file, how it helps and the common settings of the wp-config.php file.
So. Let’s begin!
Wp-config.php is the configuration file that includes configuration details such as your WordPress website’s database, settings, authentication keys etc. This information is important to your WordPress website because it helps you to connect with the database.
The wp-config.php is not pre-included in WordPress but will be created when you install WordPress. In addition, You will find that file in your website’s root directory.
Besides knowing the database information, there are several reasons when you use the wp-config.php file or edit the file to get high-level settings. These circumstances may,
Before customizing the wp-config.php file, you need to take a backup of your website’s configuration file or backup the whole website. If you don’t do it, a small mistake can make your website inaccessible for all. So, we recommend you to create a whole WordPress backup to intact the file.
To view the wp-config.php file in your WordPress’s root directory, first, you have to connect an FTP client to your website. As this file is the core files of WordPress, you need to go to your root folder and search the file. Once you get the file, right-click on the file and open it as Notepad or Text Edit. This file looks like same as below:
The file holds the following functions,
Now, Let’s take a closer look at each section in wp-config.php file.
Your all website data including posts, comments and other vital pieces of data are stored in a database.
Your database consists of six parameters that are applied to your wp-config.php file in the “MySQL Settings” section, but you only need to learn about username, password, host (typically localhost) and database name in order to build a database link.
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'database_name_here' ); /** MySQL database username */ define( 'DB_USER', 'username_here' ); /** MySQL database password */ define( 'DB_PASSWORD', 'password_here' ); /** MySQL hostname */ define( 'DB_HOST', 'localhost' ); /** Database Charset to use in creating database tables. */ define( 'DB_CHARSET', 'utf8' ); /** The Database Collate type. Don't change this if in doubt. */ define( 'DB_COLLATE', '' );
All the information can usually be retrieved from your web host. But, If you manage your own web server or hosting account or even have access to cPanel, You can get that information from the database and user development.
As we know, a security key for your website means a password which creates an extra layer of protection to your website. The Authentication unique keys and salts are the security keys in the wp-config.php file which also give encryption and security for your WordPress site. Such keys provide the user sessions and cookies created by WordPress with strong encryption.
/**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. * * @since 2.6.0 */ define('AUTH_KEY', '75589020c6952c1c4dcffc2831067c19945126afdc8b02c41ec52a12b30a3dc0'); define('SECURE_AUTH_KEY', '33d91c732b22a8ce0610f5d37410e497bc899abfa44894e7db7dfc5cba9e43f7'); define('LOGGED_IN_KEY', 'f92a599ca3974565d49b44fbc5b0161b05f3617a71828132f7acea1be04c7f84'); define('NONCE_KEY', '121b53f5110c300a0e923ad10708114d9961ede37b0e6fbed8e4e158285ed171'); define('AUTH_SALT', 'd8cfca35abbace2fc406ac8ad370ef1d370c1f44578eba4e188acba9b4106370'); define('SECURE_AUTH_SALT', '61f668d2792bda4aa329684efe00d64ceef9654dff93ba15f25b8be3f22c9795'); define('LOGGED_IN_SALT', '2344cd0d2e6211e7113fa2d81dd395da5661a2f57de840fa9a5ec46f066e5f48'); define('NONCE_SALT', '30fc7c39258437cc9b667f6c65a5aef9c0033cf0bbda49e0a60e5dd12950a514'); /*#@-/
You can create security keys for WordPress and paste it here under the “Authentication unique keys and salts” section of the wp-config.php file. This is especially useful when you think your WordPress site might have been hacked. In addition, you can change your keys as many times as you want to invalidate all existing cookies, sessions, and unwanted user login.
A table prefix is a value that is put in front of each WordPress database table. In WordPress, there are 11 default database tables and by default, the prefix of the tables are as start with ‘wp_’ such as wp_comments, wp_posts, wp_options, etc.
Since it is quite easy to know the default prefix and hack your site, You can change the default table prefix to save your site from the hackers.
/** * WordPress Database Table prefix. * * You can have multiple installations in one database if you give each * a unique prefix. Only numbers, letters, and underscores please! */ $table_prefix = 'wp_'; /**
So, we suggest you change this prefix during the installation process and use only numbers, letters and underscore for this.
As we know, Debugging in WordPress is the process of identifying errors in code. When you have faced problems with your WordPress website, the debugging function will help you to find out the issue on your site.
By default, the settings mode is disabled in the wp-config.php file under the WordPress debugging mode section as,
define ('WP_DEBUG', false);
If you want to view all the error message on your site, you have to enable the debugging mode as change the function as true, as follows:
define ('WP_DEBUG', true);
The last part of the wp-config.php file specifies the utter path that is used to set up WordPress vars and included files. Furthermore, it defines the absolute path to your WordPress directory. Here, we recommend you not to change anything about these settings.
/** Absolute path to the WordPress directory. */ if ( ! defined( 'ABSPATH' ) ) { define( 'ABSPATH', dirname( FILE ) . '/' ); } /** Sets up WordPress vars and included files. */ require_once( ABSPATH . 'wp-settings.php' );
There are some additional settings may exist in your wp-config.php, depending on your WordPress installation. So, Before making any changes, make sure that you understand those settings clearly. We will describe some settings below:
When you will move your site to a new domain name you have to change your WordPress URL. In the wp-config.php file, you will find two functions as wp-home and wp-site url that mainly control your Website URL.
For example:
define('WP_HOME','http://example.com'); define('WP_SITEURL','http://example.com');
You can also change it from the WordPress dashboard in Settings > General, like as below:
Pingback is a setting that gives you a notification as a comment when someone links to your blog post. You can disable the pingback option from the wp-config.php file or even from the admin dashboard.
The core configuration file gives you a huge opportunity to tweak your website design by modifying or adding settings on the file. But before making any changes we have to understand each of the common settings clearly and its function.
We have listed the most common functions of the wp-config.php file, however, if you want to know more about the advanced setting you can find the full list from here. Hopefully, this guide helped you to understand the basics of wp-config.php file in WordPress.
If this article will help you, then please subscribe to our YouTube channel to get more tutorials related to WordPress. You may join our Facebook page to update yourself with more tips, solutions, offers and so on.
You may also ask any questions related to it in the comment or want us to write on some specific topics you have in your mind. We appreciate your further comments, support or suggestions!