The wp-configure.php file is the most important file of a WordPress site. It is not available file in WordPress package. It will be created while installing based on the information you provide in the installation process. The wp-config.php file can be used to troubleshoot, optimize, and secure your WordPress site
There are some useful tips that most beginner don’t know about. Therefore, in this article, we will provide you the most tips that will bring experience on your WordPress site better. Let’s begin:
1. Database Configuration
The entire data of your website will be stored in a database. Your data can be blogs, comments, product or other important pieces of data. So, to install and run your site, you need to connect it with a database.
With WordPress, during the installation, you need to fill up all of your database information such as database name, database host, username, password. These information will be automatically store on the core files. However, if it hasn’t worked, you can add them manually on your wp-config.php file with the code belows:
define('DB_NAME', 'database-name');
define('DB_USER', 'database-username');
define('DB_PASSWORD', 'database-password');
define('DB_HOST', 'localhost');
2. Table_prefix
The table_prefix is simply a group of characters. It will be placed in front of your database tables. The default value of table_prefix is “wp_”.
Unlucky that major of users don’t know its importance and never change the default value of table_prefix during installation. This helps hackers attack your site easier. So, changing the table_prefix during installation is the first solution to prevent it.
Besides, in the case you have multiple installations in one database, you also use the table_prefix to do that by giving a different unique prefix for each installation.
With WordPress, you can set database table prefix during installation very easy. After installation, you can open wp-config.php file and check:
/**
* 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_';
/**
3. Turn on Debugging in WordPress
Your site is showing white screen after installing or configuring. And you don’t know what is the reason? In this case, turn on the WP_DEBUG is the first thing you must to do. It is really useful in detecting the reasons.
To enable WP_DEBUG, please open the wp-config.php file and change the value of WP_DEBUG from false to true.
define( 'WP_DEBUG', true );
In the case, you want to enable WP_DEBUG but don’t want to show your issue in the front-end, you can add this code to the wp-config.php :
define( 'WP_DEBUG_DISPLAY', false);
Besides WP_DEBUG, WordPress also support WP_DEBUG_LOG. WP_DEBUG_LOG will store all problems of your site in a file. And it will help you re-create a bug, detect the reasons and find a solution easier. And to enable this feature, please open the wp-config.php file and add this code below:
define( 'WP_DEBUG_LOG', true );
4. Increase PHP Memory Limit
In WordPress, you can receive a message such as ” Allowed memory size of xxxxxx bytes exhausted” during using or installing.
And one of way to fix this problem is increase the PHP memory limit directly in the wp-config.php file. To do it, you can adding the code bow:
define( '
WP_MEMORY_LIMIT
', '128M'
);
Please note that:
- Normally, the WordPress default, the default value of PHP memory for single site is 40MB and 65MB for multi-site. So, if you see this problem on your site, you need to increase these values to a higher value.
- This setting will be only applied on PHP memory for your site, not other applications.
5. Set WP_ENVIRONMENT_TYPE
Normally, an application will have many kinds of environment as local, development, staging and production. And with a WordPress site, WP_ENVIRONMENT_TYPE option will help you to controls these environment types. The simplest way to set the value is probably through defining the constant:
define( 'WP_ENVIRONMENT_TYPE', 'staging' );
The values of environment types are processed in the following order with each sequential method overriding any previous values: the WP_ENVIRONMENT_TYPE PHP environment variable and the WP_ENVIRONMENT_TYPE constant.
For both methods, if the value of an environment type provided is not in the list of allowed environment types, the default production
value will be returned.
Note: When development
is returned by wp_get_environment_type(), WP_DEBUG will be set to true
if it is not defined in the wp-config.php
file of the site.
6.Override of default file permissions
Configuration the file permissions is a necessary step to protected your site from hacker. This step will detect which users can view, modify, delete or execute the core files of your website.
Normally, you can do this though file manager of hosting or FTP. However, you also can do it through wp-config.php by using 02 code below:
define( 'FS_CHMOD_DIR', ( 0755 & ~ umask() ) );
define( 'FS_CHMOD_FILE', ( 0644 & ~ umask() ) );
7. Disable WordPress Auto Updates
Generally, WordPress Update is a best thing and we always recommend you should update the latest version of WordPress for your site. However, if you use a theme or plugins, which are not default of WordPress, disabling some or all automatic updates may be beneficial to you.
To disable automatic updates for your site, you just have to add the following code to your wp-config.php file:
define( 'WP_AUTO_UPDATE_CORE', false );
8. Empty Trash
By WordPress default, when user delete all post, product or other data types, they will be move to the trash and stored there in 30 days. If you want to control the number of days, you can use this below code:
define( 'EMPTY_TRASH_DAYS', 10 ); // 30 days
If you want to disable the trash, you can change 10 -> 0.
9. Enable cache
Enable cache will help your site run faster and smoother. The simplest way to enable the cache for a WordPress site is using WP_CACHE. With the 02 values are true and false, you can turn on/off cache of your site very easy. Here is this code:
define( 'WP_CACHE', true );
10. Set cookies domain
If you have plan to build multisite by creating subdomain, this is a setting you shouldn’t pass. To set cookies domain for a WordPress site, you only need to open wp-config.php and add the below code:
define( 'COOKIE_DOMAIN', 'www.example.com' );
By this way, the cookies of www.example.com
won’t be applied on other subdomains.
Leave Your Comment