Nexym
  • Business
  • Finance
  • Technology
  • Health
  • Life
  • More
    • Auto
    • Food
    • Health
    • Home
    • Space
    • Travel

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot
Are you looking to purchase a laptop in 2023? Please read our guide to help you decide which laptop fits you best.

The best laptops you can buy today

January 26, 2023

How to grow your hair faster and thicker

January 26, 2023
Find out how to use the best balance transfer credit cards to start reducing your debt in 2023. Compare offers and find the card that works for you.

The best balance transfer credit cards

January 26, 2023
Facebook Twitter Instagram
Nexym
  • Business
    Learn the skills you need to become a great content writer. From writing, editing, and researching to storytelling and creative thinking.

    Top skills you need to become a great content writer

    January 24, 2023

    How to see the bigger picture in business

    January 13, 2023
    What is a corporation? What does it mean to be incorporated? How do you start one? Read the definition of corporation, learn the different types of corporations and how to incorporate them.

    What is a corporation? Definition, meaning, types and more

    January 13, 2023
    Many people dream of creating a Starbucks coffee shop chain. Here are three alternatives for how to open a Starbucks franchise in your city.

    The best alternatives to opening a Starbucks franchise

    January 9, 2023
    Domino’s is giving you $3 not to use their delivery service. Find out how to get your hands on that cash.

    Interesting strategy – Domino’s pays you $3 if you don’t use the delivery

    January 5, 2023
  • Finance
    Find out how to use the best balance transfer credit cards to start reducing your debt in 2023. Compare offers and find the card that works for you.

    The best balance transfer credit cards

    January 26, 2023

    What is options trading? A quick guide and overview

    January 25, 2023
    What is Forex trading? Learn the basics of Forex, including how to trade currencies using technical indicators.

    What is forex trading? A complete guide

    January 22, 2023
    Learn what Ethereum is, how to buy it and how you can benefit from investing in this cryptocurrency.

    What is Ethereum? Everything you need to know about this cryptocurrency

    January 20, 2023
    Southwest Airlines Rapid Rewards rewards customers with points redeemable for flights, upgrades, and more. Learn more about it in this article!

    The complete guide to the Rapid Rewards program by Southwest Airlines

    January 19, 2023
  • Technology
    Are you looking to purchase a laptop in 2023? Please read our guide to help you decide which laptop fits you best.

    The best laptops you can buy today

    January 26, 2023
    If you are getting an error 500 Internal Server Error in WordPress, then you might want to check this post for a solution.

    How to fix the 500 internal server error in WordPress

    January 21, 2023
    You can upload files to your WordPress site with FTP, but there are many different tools that you could use for that purpose. This article will help you decide which tool is the best to use on your WordPress blog.

    The 4 best FTP clients for WordPress

    January 20, 2023
    Purchasing a guitar for the first time can be intimidating. This guide provides helpful tips on where to begin, including checking different types of guitars.

    Everything to know about getting your first guitar

    January 19, 2023

    What is the difference between WordPress.com and WordPress.org?

    January 17, 2023
  • Health
  • Life

    How to grow your hair faster and thicker

    January 26, 2023
    Teacher Appreciation Week is an excellent time to show teachers how much we appreciate them. Learn gift etiquette to get a meaningful and thoughtful gift.

    Teacher Appreciation Week gift ideas they will love

    January 24, 2023
    Learn what makes a Capricorn so driven and determined by reading this article. You'll discover their personality traits, which you can use to understand them better.

    Capricorn personality traits: how to understand them better

    January 24, 2023
    Learn how to remove acrylic nails in just minutes. Follow these steps and you’ll be able to remove acrylic nails with ease!

    How to remove acrylic nails: Fast and cheap!

    January 24, 2023
    Are you ready to test your knowledge of the holiday season? This is a fun quiz that features some tricky questions.

    Top 90 fun Christmas quiz questions | The best Christmas games

    January 20, 2023
  • More
    • Auto
    • Food
    • Health
    • Home
    • Space
    • Travel
Facebook Twitter Instagram
Trending
  • The best laptops you can buy today
  • How to grow your hair faster and thicker
  • The best balance transfer credit cards
  • Avoid these tourist traps and visit better locations
  • What is options trading? A quick guide and overview
  • Office or a gaming chair – what to look for when buying one
  • Teacher Appreciation Week gift ideas they will love
  • Top skills you need to become a great content writer
Nexym
Home»Technology»WordPress»How to edit the WordPress configuration file (wp-config.php)
WordPress

How to edit the WordPress configuration file (wp-config.php)

Matthew DrummondBy Matthew DrummondDecember 1, 20228 Mins Read
Facebook Twitter LinkedIn Reddit Telegram WhatsApp Pinterest Email
Share
Facebook Twitter LinkedIn

Sometimes, you’ll stumble upon a tutorial that asks you to edit the WordPress configuration file (wp-config.php), so here’s our article that helps explain how it works and how to edit it.

wp-config.php is part of the WordPress Core, and it’s automatically generated whenever you go through the setup of a new WordPress website. It stores various useful information that keeps your website up and running, for example:

  • Database connection information
  • Authentication keys
  • Database table prefix option
  • Debug mode

Default wp-config.php

Here’s how the entire default wp-config.php file looks like:

<?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';

As you can see, the majority of the settings are defined using PHP constants, in this format:

define( 'constant_name', 'value');

Edit wp-config.php

Each section is properly documented so you can understand what it’s used for.

To edit the wp-config.php file, you can either:

  • Download it via FTP; edit it on your computer, and then upload it back to your account
  • Edit it directly via the FileManager in your hosting control panel, cPanel control panel > Files section

Before moving to the next step, always make sure to create a backup of your WordPress database and folder.

Let’s explain what each part does!

MySQL Configuration

The first section is related to your website’s database configuration, and to fill this section, you will need your database name, username, and password.

// ** 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 keys

The wp-config.php file includes secret authentication security keys and salts, which are additional passwords that provide secure encryption. Together with cookies, they help verify the identity of logged-in site users and commenters. The authentication keys are almost impossible to break since they are long, random and complicated. Here’s how this section looks:

/**#@+
 * 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');
 
/**#@-*/

These are generated in the wp-config.php file by default when you install WordPress. However, if you suspect that your website security could be compromised, you can create new WordPress security keys here and paste them in the authentication section.

This action will log out all currently logged-in users on your site and they will be required to log in again.

WordPress database table prefix

WordPress automatically adds a wp_ prefix to all database tables created through it to differentiate them, and this setting can be changed in the wp-config.php file as well:

/**
 * 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_';

However, it’s not recommended to change this value after the installation as it’s not straightforward. You’ll need to rename all your database tables to match the new prefix, and update options and usermeta tables.

Some advanced users like to change this setting to make it difficult for hackers to execute common SQL injection attacks.

Debugging mode

WordPress hides errors and notices by default, and those don’t show on the website unless debugging mode is enabled. Here’s how the WordPress debug mode looks inside the wp-config.php file:

define('WP_DEBUG', false);

You can force WordPress to show errors and warnings that can help you in theme and plugin debugging by changing the value to True. However, if you are working on a live site, you should consider disabling the debug mode for website security reasons.

When the value is set to true, errors and warnings can be shown to anyone, which may give hackers sensitive information to find a vulnerability to exploit. The ‘false’ value is the default value and means that debug mode is disabled.

Absolute path settings

This section can be ignored as it’s already set up, and helps WordPress configure variables and included files via absolute path.

/* 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_onceABSPATH . 'wp-settings.php';

Advanced tips and tricks

You can also use some advanced wp-config.php settings to troubleshoot problems and fix some basic WordPress errors.

Upload directory

If you want to change your default upload directory for your media, you can do so by adding the following variable to the wp-config.php file:

define( 'UPLOADS', 'wp-content/media' );

Make sure to change wp-content/media to the desired directory name and location.

Disable automatic updates

Automatic updates are fantastic for security; however, in some cases – they can break websites as not all plugins and themes are updated for new WordPress versions immediately.

You can disable automatic updates by adding the following line to your wp-config.php file:

define( 'WP_AUTO_UPDATE_CORE', false );

Make sure to keep your WordPress core and all plugins and themes updated to avoid potential security issues.

Change your website URL

If you want to move your website to the new domain, you need to configure WordPress for this as well. You can change your home and site URLs from your WordPress dashboard > Settings > General page, but in case you’re not able to access it, you can also do this via wp-config.php file by adding the following lines:

define('WP_HOME','http://yourdomain.com');
define('WP_SITEURL','http://yourdomain.com');

Make sure to adjust yourdomain.com to your new domain name.

Adjust MySQL port and sockets

If you’re on one of our managed plans, you’ll never have to touch it, but if needed, you can adjust the database hostname and port like this via wp-config.php file:

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

(Replace localhost and XXXX with the correct database server hostname and port)

Limit post revisions

WordPress keeps saves of your post and page edits in its revision system automatically, and if you have a big website – this could result in a massive amount of data. This makes it harder to operate and back up your website. You can limit the number of revisions WordPress keeps for each post via this line of code:

define( 'WP_POST_REVISIONS', 4 );

Replace the number 4 with the number of revisions you want to keep, and WordPress will automatically dismiss the older changes.

People also viewed:

How to edit the author in WordPress How to edit the ‘Powered by WordPress’ text and link in the footer area The 3 best ways to speed up your WordPress website How to set up forums on WordPress using the bbPress plugin How to speed up WordPress by disabling WP-cron
configuration edit WordPress wp-config wp-config.php
Share. Facebook Twitter LinkedIn Reddit Telegram WhatsApp Pinterest Email
Previous ArticleBest WordPress plugins for metrics and analytics to measure traffic
Next Article How to create a survey in WordPress
Matthew Drummond

Matthew is a Nexym Technology writer. Having worked as a systems administrator for over 15 years gives him unique insight into the inner works of technology. Ultimately his passion for writing brought him to share his technical expertise with the world.

Related Stories

The 3 best ways to speed up your WordPress website

November 3, 2022

How to edit the ‘Powered by WordPress’ text and link in the footer area

March 31, 2022

How to edit the author in WordPress

March 1, 2022

How to set up forums on WordPress using the bbPress plugin

February 19, 2022

Comments are closed.

Connect
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
  • LinkedIn
  • Reddit
  • TikTok
Don't Miss
Are you looking to purchase a laptop in 2023? Please read our guide to help you decide which laptop fits you best. Reviews

The best laptops you can buy today

By Asih Tirta

Are you looking to purchase a laptop in 2023? Please read our guide to help you decide which laptop fits you best.

How to grow your hair faster and thicker

January 26, 2023
Find out how to use the best balance transfer credit cards to start reducing your debt in 2023. Compare offers and find the card that works for you.

The best balance transfer credit cards

January 26, 2023
Discover the best places to visit when traveling and avoid tourist traps! Learn how to get the most out of your trip and save money.

Avoid these tourist traps and visit better locations

January 25, 2023
  • Auto
    • Auto Reviews
    • Electric
    • Insurance
  • Business
    • Company
    • Government
  • Entertainment
    • Movies
    • Music
  • Finance
    • Credit Cards
    • Crypto
    • Market
    • Personal Finance
  • Food
    • Coffee
    • Drinks
    • Holidays
  • Health
  • Beauty
  • Fitness
  • Food
  • Medical
  • Home
  • Backyard
  • Bathroom
  • Bedroom
  • Cleaning
  • Furniture
  • Home Office
  • Kitchen
  • Life
  • Astrology
  • Family
  • Fashion
  • Outdoors
  • Personal
  • Pets
  • Apple
  • Audio
  • Domain Names
  • Gaming
  • Google
  • Power
  • Reviews
  • Samsung
  • Destinations
  • Gear
  • Services
  • Space
  • Tourism
  • Technology
  • Tutorials
  • Web Hosting
  • WiFi
  • WordPress
  • Travel
  • Shopping
  • Sports
  • Work
  • Stocks
  • Television
  • Web Hosting
Facebook Twitter Instagram Pinterest YouTube LinkedIn Reddit TikTok
© 2023 Nexym Media

Type above and press Enter to search. Press Esc to cancel.