2014-10-20

WordPress is one of the easiest platforms one can use online for website creation. It has become popular in the recent past years thanks to its simplicity to install, configure and customize. With WordPress, web designing and development are easy with the help of core files and tools.

Wp-config.php file is one of the most crucial files on WordPress. This particular file is important to those who understand the WordPress well. In addition to having simple automatic configurations after downloading WordPress, you can also manually configure it using the wp-config file.

In this article, you can learn how to use the file to configure and modify WordPress for better performance and function.

What is wp-config.php?

wp-config.php is an important file in WordPress. It carries database information that includes the name, username, host (localhost) and a password. This is the communication link between WordPress and the database, and allows WordPress users to store, access and retrieve data, which may include users, posts and settings. It also defines other advanced settings for WordPress.

This file is not contained in the WordPress download package. Instead, the file contained on the package called wp-config-sample.php that is renamed to wp-config.php. Below are some lines of code showing part of the file:



This is the most crucial part of this file.

Access the WordPress Config File

After downloading WordPress, open the unzipped file and select the wp-config-sample.php. Right click on the sample and select rename. Rename the file to wp-config.php.

The first window that meets you when you upload your WordPress via FTP allows you to add your database details. Click on Create Configuration File and enter the database details. These include the database name and the host among others. Here is where you use the wp-config-sample.php.

The information you enter here allows WordPress to connect to the database. As you enter the database information, it gets into your wp-config.php as follows:



Use the wp-config.php

The Security Keys on WordPress are randomly variables used to enhance the encryption of website cookies. The security keys are added automatically by the use of installing wizard since the WordPress 3.0. However, if you are using the older version of WordPress, you have to enter this manually into your WordPress config file. There is a total list of eight keys on WordPress 3.0.

You need to enter the keys in the wp-config.php as follows:



These keys are great security measures for your site.

Database Prefix

There is a table prefix-stored at wp-config.php that you need to select while installing WordPress. The table appears as:

While setting up the table, change the wp- to something else. This can help you stay avoid of hackers on your site.

Changing the Language

You can change form English to your native language by the use of the following shortcodes on your wp-config.php.

As seen on the code above, you can define your language as you like. You can learn more about WordPress in another language on official WordPress Codex.

Debugging WordPress

WordPress has a great debugging feature that is by default set to false. You can enable the feature as following on wp-config.php:

Adding Blog Site Address to wp-config.php

You can specify the WordPress address on your WordPress settings. The information goes to your database and runs as a database query every time the developer requests a template. By adding this to your wp-config.php, you can reduce the frequency of the queries and thus improve your site performance. Add the information as follows.

Overriding Permissions on Files

If there are restrictions from your host for user files, then you can override the permissions by editing your wp-config.php. Though most bloggers and site users do not need this, to some it comes handy. Use the code below to edit it.

Auto-Saving Configuration

After every one minute, WordPress saves your post. However, you can modify this to reduce the time WordPress takes to save your post. Use the code below to set the duration on your wp-config.php.

There are also blogs with different numbers of revisions; it can be 10 or 20 and can even go up to 100. You can change this to the number of revisions you need as follows.

You can put any number you like. You can also disable the feature if you do not like the post revisions at all. You can do this as below.

WordPress Trash Enhancement

WordPress 2.9 comes with a Trash feature on its core that has the same function as a recycle bin. It gives the advantage of sending your posts to trash where you can retrieve them later other than deleting them permanently. You are thus covered if you click the delete button mistakenly as you can reclaim your post.

The trash can empty its content by 30 days by default, but you can change this through your WordPress config file to any number of days you like by use of the function as below.

You can also decide to disable the feature if you feel that it is not important to you at all. Use the following function.

When you disable the Trash feature, WordPress does not require confirmation from you when you click delete post permanently even if it is accidental. This can lead to loss of important posts, and you are thus advised not to disable the feature.

FTP/SSH Coefficients

WordPress allows users to upgrade plugins and core versions by default from the backend. Most of the hosts ask for an SSH or FTP when you try to upgrade any new plugin or install it. You can set this on your wp-config.php and forget the issue again. Use the codes below to set that on your WordPress config file.

Auto Database Optimization

Automatic Database Optimization comes with WordPress 2.9, and allows you to optimize the database automatically. You should enable the feature on wp-config.php by use of the function as below.

You can check the settings after the activation on http://www.yoursite.com/wp-admin/maint/repair.php

The purpose of this function is to repair a corrupted database, and thus the user cannot login. You can access the functionality without logging in. Once you are done with the repairs and the optimization, ensure this does not remain in your wp-config.php.

Up the PHP Memory Limit

You might have noticed Exhausted Memory Error when you try to update the plugin or when you want to activate it. This problem can be solved by upping the PHP memory limit. Use the code below on your wp-config.php to increase the memory.

Some hosts may deny you the use of this feature, and thus you have to talk to your host to increase your PHP memory before you pasting the code above.

Error Log for WordPress

An error log is important to developers. You should thus strive to create an error log for your site. If you are on WordPress, you can use the wp-config.php to simply create the error log. You need to create a file and name it “php_error.log”, and ensure that it is server-writable. Place the file on the directory you like and edit its path using the code below in the third line.

Moving your wp-content directory promotes your site security. You can move this starting WordPress 2.6. Use the code below on your wp-config.php to do this.

The plugin directory must be defined as above as some may fail to work if you fail to define it fully.

Custom User

All user data is by default stored in tables, wp_usermeta and wp_users. However, you may want to change this and specify the specific table where you want the data to be stored. This can be done easily on your wp-config.php by using the code below.

Multi-Site Network Activation

The WPMU is combined into the WordPress core. This means that you have to activate the multi-site network feature. This is done by adding the code below on your wp-config.php.

You can find a new page called Network on your wp-admin found in Tool >> Network. Follow the instructions on that page to finalize the setup of the Multi-Site Network.

Secure the WP-Config File

There are lots of configurations that this file does on your WordPress site, and thus you must keep it within the highest security. The file is located on the WordPress root folder although the user can decide to transfer it from here.

You can transfer it into the public_html directory where it is not accessible by users. You can also limit file access by the use of .htaccess. Once you move the file to another folder, WordPress can by default search it from other folders.

Use the following code to limit its access.

The post An In-Depth and Comprehensive Guide to WordPress wp-config.php File appeared first on WPMatter - WordPress Coding, Web Hosting, Theme, Plugin and SEO Matters.

Show more