Are you using self-hosted wordpress site? If yes, then have you ever gone through your wordpress core files? If yes, then do you have any idea of what it is? Most of the time we manage our wordpress site from back end administrative pages that is wp-admin. After your initial wordpress setup you will start managing your site from wp-admin (for ex: yoursite.com/wp-admin), but for configuring and setting up wordpress; wp-config.php file plays an important role. Here let’s see what is wp-config.php? Where wordpress configuration file is located and how to edit wp-config.php file manually?
What is wp-config.php? WordPress configuration file
Wp-config.php is one of the wordpress core files and the most important file for wordpress installation. It is the main base configuration file for your website that controls many aspects of wordpress. Wp-config.php file consist of information’s like MySQL database username, password, hostname, table prefix, security keys etc.
The main purpose of wp-config.php file is that it enables wordpress to connect to the database that is to receive and store specific information. Other than that it can be used to improve your site security, to customize several functionalities and to improve your sites performance. This file holds numerous mysteries which most wordpress users do not know. But remember one think; wp-config.php is like a knife, messing on it will really break your entire site.
Where and how to edit wp-config.php file?
If you are a wordpress.com user then this topic is not for you. Only self-hosted wordpress sites will have access to edit wp-config.php file.
WordPress wp-config.php file location
WordPress by default does not include this wp-config.php file in your download package instead you will see a sample file named wp-config-sample.php. You don’t have to deal with this file because wordpress automatically creates a wp-config.php file from this sample file based on the information you provide during wordpress installation.
You can find your sites wp-config.php file in your main root directory that is where wordpress is installed. Access your wordpress installation directory (public_html) using cPanel or FTP (FileZilla). This is the common location where wordpress is mostly installed, but for some it may vary depending upon your wordpress configuration and host. Find and dig your wordpress installation directory and you will see wp-config.php file along with several php files and folders like wp-admin, wp-content, wp-includes.
How to edit wp-config.php file in wordpress
WordPress automatically creates wp-config.php file for you, but however it’s worth knowing the elements and learning how to edit wp-config-sample.php file manually.
Step 1: First Download wordpress zip version from wordpress.org and then unzip the downloaded wordpress file to your computer.
Step 2: You will see a sample wp-config.php file. Just rename wp-config-sample.php file to wp-config.php.
Step 3: Now open your wp-config.php file using Notepad ++ or any advanced text editor.
Step 4: At very first you will see several php comment lines, just ignore it. Then you will see a few lines for MySQL settings like this which is the most important segment in your wp-config.php file.
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
/** MySQL hostname */
/** Database Charset to use in creating database tables. */
/** The Database Collate type. Don't change this if in doubt. */
- In the very first line enter your database name where it says “database_name_here”.
- At the second and third line enter your database username and password which is used to access your database.
- The next line is where you need to enter your MySQL hostname. Mostly you don’t have to edit this field because “localhost” is the DB_HOST values for most hosting companies.
Learn more about the database setup
Related: How to backup wordpress database
Authentication unique keys and salts
Step 5: Next you will see several set on lines like this that is wordpress security keys and salts.
* Authentication Unique Keys and Salts.
define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');
This is the second most important part used for your site security. The above 8 lines should be replaced with a set of random variables which you can generate from here. These security keys will enhance the encryption of data stored in your user’s cookies and it makes harder to hack your site. We have already covered wordpress security keys and salts in detail.
WordPress Database table prefix
$table_prefix = ‘wp_’;
When you run the wordpress setup wizard you will have the option to set table prefix, but most will ignore it. Changing the default values will improve your site security.
Next thing you will see is wordpress language settings, the default one is English. However if you wish to have wordpress in your own language then you can change the values of define(‘WPLANG’, ”);. Do you know that wordpress supports more than 75 languages.
Related: How to change languages in wordpress dashboard
Next thing is Debugging wordpress which is mostly useful for theme and plugin developers. By default debugging mode is disabled.
Hope this helped you to understand about wordpress wp-config.php file.