What is wp-config.php File?
You should know the template files when working with self-hosted WordPress sites. There are many template files like wp-admin.php, post.php, header.php, etc. Wp-config.php is one of the core WordPress template files and WordPress automatically generates this file during installation process. This wp-config.php file contains base configuration and MySQL database details of your site. The file is located in your root directory (…/public_html/wp.config.php) and one of the most important file for your WordPress site to work properly.
Why You Need to Modify Configuration File?
Here are some of the reasons why you need to modify this file:
- Change database details like password or database name.
- Change media upload folder to a custom folder
- Disable or modify post revisions
- Change post autosave interval
It can be modified by directly through your hosting account or remotely using a FTP program. Here we discuss both the ways of modifying wp-config.php file with the examples of Bluehost and FileZilla. The same process is applicable for any other hosting company and FTP programs.
Backup the File Before Editing
As mentioned, wp-config.php file contains the database username and password for your site. In addition, the file also contains the authorization key and directives to control the behavior. Therefore, make sure to backup your original wp-config.php file before any modification. Your site may not be accessible (both frontend and admin panel) if you make any mistakes in wp-config.php file. In such a case, you need to use FTP to restore the previous version to access the site’s admin dashboard.
Note that WordPress by default comes with a sample configuration file with the name as “wp-config-sample.php”. This is a dummy file supplied with the installation package that you can download from WordPress.org site. Do not confuse this sample file with the real wp-config.php file that is generated during WordPress installation.
1. Modify wp-config.php File Using “File Manager” option in Bluehost
Login to your hosting account, navigate open “File Manager” option. This will be available under different category depending on your hosting account. For example, in Bluehost hosting account, go to “Hosting > cPanel > File Management > File Manager”.
Based in your settings you may be prompted to select the directory to open (there is a checkbox to skip this question when File Manager is opened). Choose “Web Root (public_html/www)” if you installed WordPress in your root directory or select the sub-directory from “Document Root for” drop-down if you installed WordPress on sub-domain or sub-directory of a main domain.
File manager will open where you can perform various actions on your site’s files like editing, uploading, downloading, moving, etc.
Locate wp-config.php file which is stored under your root domain and click on “Edit” button. If prompted, choose “utf-8” encoding in the Text Editor pop-up and click on “Edit” button (You will not see this pop-up if encoding is disabled).
Text Editor will open where you can edit and save your file. The changes will be immediately effective on your live WordPress site.
Note: Change the “Text Editor” to “Code Editor” option to see the codes with line numbers which will be useful in troubleshooting since most of the time WordPress will show the line number in the error message.
2. FTP using FileZilla
File Transfer Protocol (FTP) is an another option by which you can remotely access server files and modify them from your local PC or Mac. In order to use FTP, you need to setup a FTP account in your hosting account and need to install a free program like FileZilla in your computer.
- Open FileZilla and connect to your server, you will see FileZilla screen as below containing various sections.
- Navigate to your WordPress installation folder where wp-config.php file is stored under “Server Folders & Files” section.
- Right click on the file and choose “View/Edit” option.
- File will open in a local text editor. You can edit as a normal local file, save and close it.
- FileZilla will ask you whether you want to upload the saved file back to server, click on “Yes” button. The changes will be effective immediately on your live site.
When you open the same file multiple times to modify the content, choose “Finish editing and delete local file” check box when uploading back to server.
Remember to Use Proper Text Editor
It is very important NOT to use text editors like Microsoft Word to modify WordPress files. Copying and pasting from Word document will change the single and double quote style and you will not be able to access WordPress dashboard using admin login. In case of such an issue WordPress will show the line number on which it fails, it will be mostly the line number your inserted code by copying the content from Word.
2 Comments
Leave your reply.