Wp-config.php is a WordPress configuration file that contains sensitive information to control the behavior of your website. WordPress software does not contain wp-config.php by default, it comes with a sample file named wp-config-sample.php. However, when you install WordPress on your site, it will generate wp-config.php file dynamically. The configuration file contains your database name, username and password. In addition, you can add many other controlling parameters manually.
Why to Edit wp-config.php File?
There are many reasons you may need to add additional parameters on your installation. Here are some of the popular reasons why bloggers want to edit wp-config.php file in WordPress site:
- You want to increase the PHP memory limit so that sufficient memory is allocated for running PHP scripts on your server.
- Enable or disable debugging on the frontend of your site for troubleshooting purposes.
- Disable theme and plugin editor from admin panel for security reasons.
- Change the default wp_ table prefix of your MySQL database.
Where is wp-config.php File Located?
Wp-config.php is available in your WordPress site’s root installation folder.
- If you have installed WordPress on the main domain, then you should look under “/public_html” folder.
- If you have installed WordPress in subdomain or subdirectory, then look the file under “/public_html/folder-name/”.
How to Edit wp-config.php File?
Unlike functions.php and other theme’s files, you can’t edit wp-config.php file from your WordPress administrator panel. You have the following two options:
- Use File Manager app from your hosting account
- Use FTP to remotely edit server files
Edit wp-config.php File with File Manager
Follow the below instructions to edit the file from your hosting account.
- Login to your hosting account.
- Depending upon the setup you can go to cPanel or any other custom option available on your server. For example, you can go to cPanel in Bluehost and HostGator while you need to access Site Tools in SiteGround hosting. Here we will explain with the cPanel setup.
- Find File Manager app and open it.

- Locate wp-config.php file in your root installation and click “Edit” button to modify the file.

- Again click on “Edit” button on the pop-up that appears.

- Add your code and save the changes to upload the file back to the server.

- Test your site is working with the expected results.
Edit wp-config.php File with FTP
- Login to your hosting using your favorite FTP client like FileZilla.
- Navigate to your WordPress site’s root installation folder.
- Find wp-config.php file, right click on it and choose “Edit” option.

- Update the code in the file.
- Save the changes to upload the file back to the server.
Points to Note:
- Make sure to upload the file back into the server and check your site is working fine.
- Many hosting companies define the maximum allowed limit for the server parameters. Therefore, it is a good idea to confirm with your host before you add additional parameters in the configuration file.
- The order of the code in the file is important. Hence, always add your code at the bottom of the file after the comment “/* That’s all, stop editing! Happy blogging. */”
Sample File Details
Below is the wp-config-sample.php file that comes with WordPress package. You can find similar details in the dynamically generated wp-config.php file also.
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the
* installation. You don't have to use the web site, you can
* copy this file to "wp-config.php" and fill in the values.
*
* This file contains the following configurations:
*
* * MySQL settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/support/article/editing-wp-config-php/
*
* @package WordPress
*/
// ** 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', '' );
/**#@+
* 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', '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' );
/**#@-*/
/**
* 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_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
You should your codes before the line that says “/* That’s all, stop editing! Happy publishing. */”.