WP-config is one of the most powerful files on your WordPress site, and it plays an important role in how WordPress works behind the scenes. There are some really useful WordPress setup tips that most newbies don't know. In this tutorial, we're going to share some of the most useful WordPress setup tips that will help you troubleshoot, optimize, and secure your WordPress site.

wordpress configuration tutorial.png

How to use these WordPress configuration tips?

WordPress comes with a powerful configuration file called wp-config.php. It is located in the root folder of every WordPress site and contains important configuration settings.

All the best companiesaccommodation WordPress come with a one-click installation, which means that you will never need to modify the wp-config.php file during installation. This is the main reason why many users are not familiar with the power of this file.

You can use the wp-config file to troubleshoot, optimize and secure your WordPress site.

The wp-config.php file is a powerful tool, and a small error in the code can make your website inaccessible. You should only edit this file if necessary and always create a full WordPress backup before making any changes.

That being said, let's take a look at some handy WordPress setup tips that you can use on your website.

1. Basic WordPress configuration settings

By default, you only have to fill in the database settings when installing WordPress. If you do not have a wp-config.php file present, you will be asked to create one by filling in your database information.

creating a wordpress.png installation file

WordPress will try to automatically save these settings by generating a wp-config.php file. However, if this fails, you will have to add them manually.

To do this, you will need to connect to your website using an FTP client. Once logged in you will need to rename the wp-config-sample.php file to wp-config.php.

rename the file wp config wordpress.png

After that you can go ahead and edit the newly created wp-config.php file. You will need to add your database information by changing the following lines:

define ('DB_NAME', 'database-name'); define ('DB_USER', 'database-username'); define ('DB_PASSWORD', 'database-password'); define ('DB_HOST', 'localhost');

Remember to save your changes and upload the file to the server.

2. Adding security keys on WordPress

The default WordPress installation automatically adds security keys to your configuration file. These security keys are used to add an extra layer of security to your WordPress login and cookie authentication.

You can always regenerate security keys if you think someone can access your website without proper authentication. Changing the security keys logs out all logged in users.

define ('AUTH_KEY', 'put your unique phrase here'); define ('SECURE_AUTH_KEY', 'put your unique phrase here'); define ('LOGGED_IN_KEY', 'put your unique sentence here'); define ('NONCE_KEY', 'put your unique sentence 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 sentence here'); define ('NONCE_SALT', 'put your unique sentence here');

For more information, see our article on WordPress security keys and how to use them.

3. Change the prefix of WordPress tables

A default WordPress installation adds a prefix wp_ to all table names in the WordPress database. Some WordPress security experts believe that changing the table prefix can make your WordPress database more secure.

To do this, you must edit the following line in your WordPress configuration.

$ table_prefix = 'wp_';

If you are doing this for an existing website, you will also need to change the table prefix in your WordPress database. To do this, check out our article on how to change the WordPress database prefix.

4. Enable debugging in WordPress

WordPress comes with a neat debugging feature that lets you see or hide WordPress errors in debug mode. To enable it, you will need to add this rule in your WordPress configuration file.

define ('WP_DEBUG', true);

You can also enable debugging while hiding errors on your website and log them to a log file instead. To do this, add the following lines to your configuration settings.

define ('WP_DEBUG', true); define ('WP_DEBUG_LOG', true); define ('WP_DEBUG_DISPLAY', false);

This will create a debug.log file in the wp-content folder of your website and store all debugging errors and notifications in the log file.

5. Change your site or your WordPress address

Normally, you can set your WordPress and Site URLs from the page Settings " General. However, you might not be able to do this if you don't have access to your WordPress site, see redirect errors, or just moved your site.

In this case, you can edit your site and your WordPress URLs via the wp-config.php file by adding the following lines:

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

Don't forget to replace example.com with your own domain.

6. Replace file permissions

WordPress allows you to override file permissions if your host has restrictive permissions for all user files. Most people don't need it, but it's there for those who do.

 define ('FS_CHMOD_FILE', 0644); define ('FS_CHMOD_DIR', 0755);

7. Changing post-revision settings

WordPress has a very useful post-revisions feature that allows you to undo changes to your posts and pages by reverting to a previous version or auto-saving.

You can disable or change the post-publish settings through the configuration file. Here are various post review settings that you can use.

You can change the frequency with which WordPress saves an automatic backup as a revision by adding the following line:

define ('AUTOSAVE_INTERVAL', 120); // in seconds

Some articles on your site may have dozens of post revisions, depending on how long it took to write them. If you think this feature bothers you, you can limit the number of revisions per post.

define ('WP_POST_REVISIONS', 10); // 10 reviews by articles

If, for any reason, you want to completely disable the post-revisions feature (not recommended at all), you can use the following code to disable later revisions.

Define ('WP_POST_REVISIONS', false);

8. Changing the settings of the WordPress Recycle Bin

WordPress comes with a recycle bin feature called Recycle Bin. When a user submits an article to the trash, it is still stored on your website for the next 30 days as a trash. After this time, WordPress automatically deletes them forever.

You can change this behavior by changing the number of days you want to keep the trash.

define ('EMPTY_TRASH_DAYS', 15); // 15 days

If you don't like this feature, you can disable it by adding the below feature:

define ('EMPTY_TRASH_DAYS', 0);

Note: Using zero means your posts will be permanently deleted. WordPress would not ask for confirmation when you click Permanently delete. Any accidental click could cost you dearly.

9. Adding FTP / SSH constants to the WordPress configuration

By default, WordPress allows you to update core, themes, and WordPress plugins from the admin dashboard. Some hosts require an FTP or SSH connection each time you try to upgrade or install a new plugin.

WordPress requests FTP information

By using codes, you can define FTP or SSH constants and never have to worry about them again.

// forces the filesystem method: "direct", "ssh", "ftpext", or "ftpsockets" define ('FS_METHOD', 'ftpext'); // absolute path to root installation directory define ('FTP_BASE', '/ path / to / wordpress /'); // absolute path to "wp-content" define ('FTP_CONTENT_DIR', '/ path / to / wordpress / wp-content /'); // absolute path to "wp-plugins" define directory ('FTP_PLUGIN_DIR', '/ path / to / wordpress / wp-content / plugins /'); // absolute path to your SSH public key define ('FTP_PUBKEY', '/home/username/.ssh/id_rsa.pub'); // absolute path to your SSH private key define ('FTP_PRIVKEY', '/home/username/.ssh/id_rsa'); // either your FTP or SSH username define ('FTP_USER', 'username'); // password for FTP_USER username define ('FTP_PASS', 'password'); // hostname: combo port for your SSH / FTP server define ('FTP_HOST', 'ftp.example.org:21');

Note: Remember to replace the WordPress and ftp.example.com path with your own FTP host information.

10. Allow automatic database repair

WordPress comes with a built-in function to automatically optimize and repair the WordPress database. However, this feature is disabled by default.

To enable this feature, you must add the following line to your WordPress configuration file.

define ('WP_ALLOW_REPAIR', true);

After adding this, you need to visit the following url to optimize and repair WordPress database

http://exemple.com/wp-admin/maint/repair.php

Don't forget to replace example.com with your own domain. You will see a simple page with the options to repair or repair and optimize the database. You do not need to be logged in to access this page.

repairing the database wp.png