{"id":3991,"date":"2020-02-12T15:00:18","date_gmt":"2020-02-12T14:00:18","guid":{"rendered":"https:\/\/qodeinteractive.com\/magazine\/?p=3991"},"modified":"2022-02-08T22:49:05","modified_gmt":"2022-02-08T21:49:05","slug":"how-to-edit-wp-config-file","status":"publish","type":"post","link":"https:\/\/qodeinteractive.com\/magazine\/how-to-edit-wp-config-file\/","title":{"rendered":"How to Edit the WordPress wp-config.php File"},"content":{"rendered":"<div class=\"wpb-content-wrapper\"><p>[vc_row][vc_column][vc_column_text]The <strong>wp-config.php<\/strong> file is a core file within your WordPress installation. It is used to define a lot of different configurations without which WordPress would not be able to function at all. This file is used primarily for defining the constants used to connect to the database of your website, however, it is much more versatile than that. In this article, we will cover some of the constants and settings you can use within the wp-config.php file and how you can edit it to implement these.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Before Editing the wp-config.php File<\/h2>\n<p>[\/vc_column_text][vc_column_text]Before we delve into editing the wp-config file please note that even a small mistake could cause problems with your installation. To avoid any issues with this, we strongly recommend that you <strong>make a copy<\/strong> of your wp-config.php file, <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-backup-wordpress-files\/\">backup your website files<\/a>, and <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-backup-wordpress-database\/\">backup your database<\/a> as well. We also strongly recommend that you do <strong>not edit the file within Word, Google Docs<\/strong>, or any other word processing application since these applications make formatting changes that can cause errors within PHP files.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Another pothole to look out for is the fact that all of the settings within the wp-config file are written in a specific order and changing that order may cause unexpected issues. Also, any code that you would like to include must be added above the following line:[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/* That's all, stop editing! Happy blogging. *\/<\/code>[\/vc_column_text][vc_empty_space height=&#8221;74px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">How to Access wp-config.php<\/h2>\n<p>[\/vc_column_text][vc_column_text]Even though this file is crucial to the operating of WordPress itself, it is worthwhile to note that it does not come with the default WordPress package. Instead, the package contains the <strong>wp-config-sample.php<\/strong> file. Once you complete the famous <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-install-wordpress\/\">5 minute WordPress installation<\/a>, after adding the database information, WordPress will generate this file for you. However, if you ever want to change these settings down the line of your website development you can do so by editing the wp-config file.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]To edit it you need to access your theme\u2019s files. For these purposes, you could either enter your hosting\u2019s cPanel or access the files using an FTP client. We will be showing you the steps necessary to edit the files via the FileZilla FTP client. In order to be able to do so you will first need to <a href=\"https:\/\/qodeinteractive.com\/magazine\/how-to-use-ftp\/\">setup and learn to use the FTP client<\/a> on your computer.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Once you have connected to your files via your chosen FTP client you can open the wp-config file by navigating to <strong>the root folder<\/strong> of your WordPress installation, <strong>right-clicking<\/strong> the file and <strong>selecting View\/Edit<\/strong> from the dropdown.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/Open-the-wp-config-file.jpg\" class=\"attachment-full size-full\" alt=\"Selecting View\/Edit from the dropdown\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/Open-the-wp-config-file.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/Open-the-wp-config-file-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/Open-the-wp-config-file-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]The FTP client will now download the file to your computer and open it within a text editor such as Notepad. It should look like so:[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/WP-config-file.jpg\" class=\"attachment-full size-full\" alt=\"WP config file\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/WP-config-file.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/WP-config-file-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/WP-config-file-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]As previously mentioned you need to find the following line within the file:[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">\/* That's all, stop editing! Happy blogging. *\/<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]and add the changes above it.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">A Summary of Possible Changes and Settings Within the wp-config File<\/h2>\n<p>[\/vc_column_text][vc_column_text]There are many options, settings, and constants that can be set using this file. The most important ones, which coincidently are written at the very top of the file are the MySQL Database Settings.[\/vc_column_text][vc_empty_space height=&#8221;50px&#8221;]<div class=\"qodef-single-image-holder   qodef-has-border \">\n    <div class=\"qodef-si-inner\" >\n                                    <img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"378\" src=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/MySQL-Database-Settings.jpg\" class=\"attachment-full size-full\" alt=\"MySQL Database Settings\" srcset=\"https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/MySQL-Database-Settings.jpg 710w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/MySQL-Database-Settings-300x160.jpg 300w, https:\/\/qodeinteractive.com\/magazine\/wp-content\/uploads\/2020\/01\/MySQL-Database-Settings-620x330.jpg 620w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/>                        <\/div>\n<\/div>[vc_empty_space height=&#8221;38px&#8221;][vc_column_text]Within the highlighted lines of code above the wp-config file sets the following:[\/vc_column_text][vc_empty_space height=&#8221;23px&#8221;]<ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Database Name:\ndefine( &#8216;DB_NAME&#8217;, &#8216;database_name_here&#8217; );<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Username to access the database: define( &#8216;DB_USER&#8217;, &#8216;username_here&#8217; );<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Password for the above username: define( &#8216;DB_PASSWORD&#8217;, &#8216;password_here&#8217; );<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Name of your database host: define( &#8216;DB_HOST&#8217;, &#8216;localhost&#8217; );<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Charset for creating database tables: define( &#8216;DB_CHARSET&#8217;, &#8216;utf8&#8217; );<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">Database Collate type: define( &#8216;DB_COLLATE&#8217;, &#8221; );<\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_column_text]The following eight settings are authentication keys and salts. These are security features that WordPress uses. The keys are used for security checks, and the salts are used for hashing passwords.[\/vc_column_text][vc_empty_space height=&#8221;23px&#8221;]<ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;AUTH_KEY&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;SECURE_AUTH_KEY&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;LOGGED_IN_KEY&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;NONCE_KEY&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;AUTH_SALT&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;SECURE_AUTH_SALT&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;LOGGED_IN_SALT&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul><ul class=\"qodef-unordered-list-item \">\n    <li>\n\t        <div class=\"qodef-ul-title-holder\">\n            <span class=\"qodef-ul-title-content\">define(&#8216;NONCE_SALT&#8217;, &#8216;put your unique phrase here&#8217;);<\/span>        <\/div>\n            <\/li>\n<\/ul>[vc_column_text]When the WordPress installation is run the security and salt keys will be generated automatically, but you can change them anytime, adding any arbitrary string using the syntax above.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]Along with these options, using the wp-config.php file, you could also activate some features for developers such as activating Debug mode by adding the following line of code into the wp-config file:[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_DEBUG', true );<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]This option will allow WordPress to show errors and warnings if there are any within the files, which in turn will help you in debugging the theme and plugin files.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]The WP_DEBUG option has a flaw, it forces WordPress to show errors and warning on all pages, even if viewed by your users. It is not good practice to let your users see these errors so instead of using only the above-mentioned line you can set WordPress so that it logs these messages into one or more files on your servers, keeping these hidden from the view of your users. In order to do so, you will need to add the following code:[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_DEBUG', true );<\/code><br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_DEBUG_LOG', true );<\/code><br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_DEBUG_DISPLAY', false );<\/code><br \/>\n<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">@ini_set( 'display_errors', 0 );<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]To briefly explain these lines and how this feature works. With the first line, you enable the WP_DEBUG mode. Then, by using WP_DEBUG_LOG and by setting it to true you can force WordPress to store messages into a debug.log file. Now, with only these two settings we still have the issue of the user being able to see the error messages on pages. To change this you need to define WP_DEBUG_DISPLAY to be false. This way you hide the messages from the screen. Finally, by setting the value of PHP variable display_errors to 0 the error messages won\u2019t be printed to the screen at all. Since the wp-config file is never loaded from the cache it is a good practice to override the php.ini settings for this same reason and make sure that no messages will go through.[\/vc_column_text][vc_empty_space height=&#8221;81px&#8221;][vc_separator color=&#8221;custom&#8221; accent_color=&#8221;#f0f0f0&#8243;][vc_empty_space height=&#8221;50px&#8221;][vc_widget_sidebar sidebar_id=&#8221;top-picks-banner&#8221;][vc_empty_space height=&#8221;28px&#8221;][vc_separator color=&#8221;custom&#8221; accent_color=&#8221;#f0f0f0&#8243;][vc_empty_space height=&#8221;70px&#8221;][vc_column_text]For even more in-depth options you can use[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'SCRIPT_DEBUG', true );<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]in order to load the uncompressed versions of scripts and make debugging even easier.[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]You could even change the allocated server resources if they are lacking in a particular field. If that is the case you may receive a message such as:[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]<strong>Fatal error:<\/strong> Allowed memory size of xxx bytes exhausted[\/vc_column_text][vc_empty_space height=&#8221;28px&#8221;][vc_column_text]In this scenario, it would be best for you to edit the php.ini file and set the correct server resources there. However, if for some reason you do not have access to it you could set the WP_MEMORY_LIMIT from the wp-config file by using[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_MEMORY_LIMIT', '128M' );<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]and setting the limit an acceptable number. If needed, you can set a maximum memory limit, as well, with the following statement:[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'WP_MAX_MEMORY_LIMIT', '256M' );<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]Another very useful security feature that gets overlooked is the ability to force the admin to upload content and attachments over an SSL connection if the servers are using one. You can achieve this with the following command:[\/vc_column_text][vc_empty_space height=&#8221;30px&#8221;][vc_column_text]<code class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">define( 'FORCE_SSL_ADMIN', true );<\/code>[\/vc_column_text][vc_empty_space height=&#8221;34px&#8221;][vc_column_text]You can find more information about Administration over SSL within the <a href=\"https:\/\/wordpress.org\/support\/article\/administration-over-ssl\/\" target=\"_blank\" rel=\"noopener noreferrer\">WordPRess Codex<\/a>.[\/vc_column_text][vc_empty_space height=&#8221;68px&#8221;][\/vc_column][\/vc_row][vc_row][vc_column][vc_column_text]<\/p>\n<h2 class=\"qodef-h4\">Final Thoughts<\/h2>\n<p>[\/vc_column_text][vc_column_text]This article should have provided you with the necessary knowledge and understanding of the wp-config.php file and how to properly utilize and change it. Please remember to always make copies and backups of your WordPress installation and database before editing the wp-config file in order to preserve valuable progress.[\/vc_column_text][\/vc_column][\/vc_row]<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The wp-config.php file is one of the core WordPress files. Find out how to edit wp-config.php and what settings you can define within it.<\/p>\n","protected":false},"author":278,"featured_media":34715,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14,4,13],"class_list":["post-3991","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-core","tag-tips","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/3991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/users\/278"}],"replies":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/comments?post=3991"}],"version-history":[{"count":0,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/posts\/3991\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media\/34715"}],"wp:attachment":[{"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/media?parent=3991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/categories?post=3991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qodeinteractive.com\/magazine\/wp-json\/wp\/v2\/tags?post=3991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}