parallax background

An error occurred while processing this directive [Fixed]

How to see the current WordPress version you have
February 26, 2020
WordAds vs AdSense: Which one to pick for your website?
March 4, 2020
 

Working with WordPress can be frustrating sometimes. Users often report various errors and issues, which take time to be repaired and it can be quite difficult for beginners to manage all these errors. Some of the most common errors include the 500 Internal Server Error, wp-admin not working, error establishing a database connection, and the “an error occurred while processing this directive” issue.

This article will discuss the “an error occurred while processing this directive” error, and how to eradicate it. This error usually appears during the 4th step of the installation. Everything seems fine until you click the “Site Login” button. It is an unpredictable error which can occur when loading pages, or upon several refreshes.

So what does it mean, and what is the solution?

 

The directive error normally occurs when the server has no access to files and folders which indicates that WordPress is handling things for the current user.

It can occur with specific file permissions, and if you have recently changed your hosting provider.

This error may also be caused by plugins. Try disabling all plugins, then enable them one by one and check if the directive error still appears.

The solutions to “an error occurred while processing this directive” should fix the problem.

How to Fix the Issue

 

One of the main culprits for this issue is the file permissions for your scripts which might be incorrectly set up and prevent the server from accessing the files. These include the 666 and the 777 permissions, which you will need to change to either 644 or 755 to fix the problem.

Use the FTP editor to explore the functional WordPress sites. Check whether all files are set with the 644 permission and if the directories have the 755 permission.

The main reason for the “an error occurred while processing this directive” are faulty file permissions. Please note that this can be a very long fix, often taking hours and you will need FileZilla or other similar software.

First, you need to use a PHP script that will automatically set permissions for every directory on your website. This is the code to use.

<?
header('Content-Type: text/plain');
/*
* Recursively changes permissions of files and directories within $dir and all subdirectories.
* This script by XDude: http://www.xdude.com/
* Original script borrowed from http://stackoverflow.com/questions/9262622/set-permissions-for-all-files-and-folders-recursively
*/
function chmod_r($dir)
{
$dp = opendir($dir);
while($file = readdir($dp))
{
if (($file == ".") || ($file == "..")) continue;
$path = $dir . "/" . $file;
$is_dir = is_dir($path);
set_perms($path, $is_dir);
if($is_dir) chmod_r($path);
}
closedir($dp);
}
function set_perms($file, $is_dir)
{
$perm = substr(sprintf("%o", fileperms($file)), -4);
$dirPermissions = "0755";
$filePermissions = "0644";
if($is_dir&& $perm != $dirPermissions)
{
echo("Dir: " . $file . "n");
chmod($file, octdec($dirPermissions));
}
else if(!$is_dir&& $perm != $filePermissions)
{
echo("File: " . $file . "n");
chmod($file, octdec($filePermissions));
}
flush();
}
chmod_r(dirname(__FILE__));
?>

Now you can proceed to fix the “an error occurred while processing this directive” issue.

  • Backup all your files first.
  • Download this PHP script, which will automatically set the right permissions for all your files and directives (644 and 755).
  • You can freely edit the script and add other permissions of your liking.
  • Download the file, unzip it, and upload it to the root folder of your site.
  • Go to yourdomain.com/php_permissions_755_644.php

After waiting for a few seconds, you will be able to see a list of all files and directories – which means that the script works and that the permissions are now set.

 

The script works in such a way that it constantly checks the permissions for your files and folders, and it will set them to the right values when they are set incorrectly. Please note that the most important thing is to backup everything before you do this, which prevents any losses during the procedure.

Once the script does its work, we recommend that you delete it, as it can be easily hacked if you use it for prolonged periods.

If the fix doesn’t work (which it should), you can contact your hosting provider for more information and they should be able to fix the “an error occurred while processing this directive” problem for you.

About File and Permissions in WordPress

 

To gain greater awareness of this problem you need to understand the files and the permissions within WordPress. These permissions dictate who can access the files and folders from your site, and to what extent they can do so. They provide a certain level of security for your files.

Having no permissions or wrongly set permissions can expose you to hacker attacks and make your files much more vulnerable by allowing unauthorized persons to quite freely access your files. This means they can

alter them, change your settings, or even plant backdoors, which would obviously lead to losses and harm your site.

Having the proper file permissions can secure your site and prevent hackers from easily injecting various hack codes and software into it. .

There are three options for file permissions (who you give the permission to). These are: user (the administrator of the site), group (other people connected to your site, such as editors), and the world (which is anyone using the internet).

The scope of permissions for each user is defined by a predetermined set of numbers, and each number dictates what a certain person can do. There are three digits for permissions, and here is what they mean:

  • The first digit tells us what the user of the account, or the person who owns the site, can do with the files.
  • The second digit defines what other users within the admin group can do; this group consists of editors and other similar members of the group.
  • The third digit dictates what the rest of the world can do with the files; namely, your website visitors.

The numbers range from 1-7, and each has its own meaning.

 

0: no permissions

1: execute

2: write

3: write and execute

4: read

5: read and execute

6: Read and write

7: read, write, and execute

So, for example, a 777 permission would mean that everyone has the permission to read, write and execute. Most commonly we find the number 7 in the first place, while the rest of the numbers vary. For example, 755 means that the admin can read, write and execute, while others can read and execute. This is a rough guide to files and permissions.

If you enjoyed reading this article about an error occurred while processing this directive, you should read these as well:

Albert Ślusarczyk
Albert Ślusarczyk
As the co-creator of Be Theme, I am a strong believer in designing with care and patience. I pour my energy, time & knowledge into perfecting the theme for our 157,000+ customers.

Comments are closed.

Free cheat sheets available

Subscribe to download a set of cheat sheets for CSS, JS, and HTML

You'll receive an email with the cheat sheets in an instant.