WordPress Cyber Monday Deals 2021!

How to Install WordPress Securely

Many WordPress users are looking for the easiest way to install and setup WordPress. It can be as easy as clicking a button, if your web host provides that option, but if the install our site vulnerable to attack – the ease of setting it up quickly fades.

Here are a few steps we can do to tighten up the security for our WordPress websites.

Always, Always, Always Upgrade to the Latest Version

WordPress’ popularity makes it a big target for security attacks. At the same time, its popularity requires that security gets better and better. The latest version of WordPress will be the most secure. Upgrade WordPress as soon as possible when a new version come out.

Install WordPress to a Subdirectory

Since WordPress installs are so common, the default naming convention for files/folders/databases, etc. are well known. One way to make your install different from the guy next door is to install your WordPress into a subdirectory off your root directory. This can be done without exposing the name of your subdirectory to the general public.

After installing WordPress to a subdirectory, move the index.php file from inside this subdirectory to the root directory. This not only keeps your root directory clean, your subdirectory name will not be used in the URL for your site.

Use Obscure Database Name and Table Names

The other way to make things less obvious is to name your database something besides wordpress or wp. Call it sometopic_wp, or wp_somenumbers, or somethingmoreobscure. Along the same lines, give the prefix for your database tables something else besides wp_. Try wp_numChars or wpnumChars.

If you are using a self-installer, you will be prompted for this information. Plug in your obscure names.

If you are not using a self-installer, set these parameters inside the wp-config.php file.

Set the database name in the following line:

[php]define(‘DB_NAME’, ‘obscurename’);[/php]

For the table prefix, change the following line

[php]$table_prefix = ‘wp_'[/php]


[php]$table_prefix = ‘wp_obscurename'[/php]

Use Obscure Database User Name

In carrying through with the idea security through obscurity idea, use an obscure database user name, too.  A unique combination of letters and numbers hides the obvious.

Disabling Directory Views

If directory views are enabled the contents of your website directories will be listed for your visitors to see if that directory does not have a index file. Not good! If someone has access to your wp-config.php file, they could quickly compromise your site. Many hosts already disable directory view, but if it hasn’t been disabled, you can take care of it rather quickly.

In the htaccess file of the root directory add this line near the top of the file

[php]Options -Indexes[/php]

If htaccess is not an option, you can add a blank index.htm or index.php into each of your WordPress directories. Instead of seeing a directory listing, a blank page will appear (the index file).

Protect wp-config.php File

WordPress uses the wp-config.file to connect to the database and set various preferences. Valuable information is contained within this file. At a minimum, set the permissions of the wp-config.php file to 644 (read and write for the owner, read for group, read only for the world).

To further secure the file, you could update the htaccess file and limit the IP address that can access the file. Visit themelab for more info. (Note: In themelab’s example, they show how to limit access for the wp-login.php file. Substitute wp-config.php for the file name.)

Permissions for File and Directories

It’s likely that your web host has already set up optimal permission settings and access rights. Directory permissions should be set to 755, file permissions to 644.  You might run across exceptions to this when configuring files or directories with plugins, but for the most part these settings should work across the board.

Change Admin Username

Most self-installers let you specify an admin name and password upon installation. Never use ‘admin’ as the user name. Be a bit more creative! If the install automatically adds the admin user, update this immediately after installation to a different username.

This gives you a good foundation in securing down your site. What are some of the steps you’ve taken to keep your site secure from the bad guys?

Note: If you stumbled across this post looking for a security service that’ll clean your hacked site, then utilize this excellent WordPress Malware Removal Service by MalCare, one of the best security services out there. It’ll clean your website in a jiffy.

If you enjoyed this post, make sure to subscribe to WPMayor’s RSS feed.

Carma Leichty
Carma Leichty
Carma Leichty is a trainer in WordPress and web design. A converted Dreamweaver user, she is crazy about WordPress. She's done websites for the past upteen years and most enjoys helping others promote their Creative Work.

Consider sharing this post so others can find it:

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on telegram
Share on whatsapp
Share on pocket
Share on email

Join thousands of people receiving real-world, genuine evaluations of WordPress products and services just like this one every week.

Our Sponsors
Solid Affiliate

8 Responses

  1. Also, don’t forget to remove the references to WordPress in theme php coding, etc. It’s one thing to use obfuscation for directory structure, etc. but it’s also important to not give out too much information.

    Additionally, what about monitoring? Sites like WebSiteDefender allow people a free account to monitor and scan the security of their WordPress based sites. If something changes, or an update is needed, etc. They get an alert.

    Don’t forget, users should also configure the salt (secret keys) in their wp-config.php file. 😉

    Another HUGE issue is that users should be advised to use strong passwords. It’s easy to access the admin area if a simple “easy” password is used.

    One very large point that could me mentioned… Do not use “admin” as the username, (some people still do that for some strange reason).

    What about plugins?

    * Block Bad Queries
    * WordPress Firewall
    * Login LockDown
    * WP Security Scan

    The above are just some plugin examples, there are more available at WordPress.org

    All to often, I find that there is no .htaccess file in the admin folder. To help with securing WordPress, there really should be! Below is one example of such an .htaccess file:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    Backup, backup, backup… Don’t forget that backups are an important aspect of security.

    I hope this comment helps someone, somewhere! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

The Beginner’s Handbook
From an introduction on how WordPress works to our recommendations on products and services.
👋 Hey there! We're Gaby and Mark
Every week we share tutorials and genuine reviews of WordPress products and services in our newsletter.
Thousands of people read it!
We’d love for you to join.
We’d love for you to join. Here’s what you’ll be getting:

A single weekly email directly to your inbox.