Question

Apache errors (No matching DirectoryIndex...)

Posted May 11, 2021 1.4k views
ApacheWordPress

Yesterday and today, my site’s traffic dropped by almost 100%.

I checked and the site is still indexed on Google and it still ranks for its main keywords. So that’s not the issue.

Then I noticed my site has been loading very slow. So I checked the error log and I see a lot of errors in the apache error log.

Example erros:

AH01276: Cannot serve directory /srv/users/serverpilot/apps/sitename/public/wp-content/uploads/2021/05/: No matching DirectoryIndex (index.html,index.htm,index.php) found, and server-generated directory index forbidden by Options directive

[Tue May 11 10:22:52.161451 2021] [core:error] [pid 15803:tid 140383480702720] (36)File name too long: [client 87.102.119.16:0] AH00127: Cannot map HEAD /free-software-download-sites/@2x.data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNDhweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgNDggNDgiIHZlcnNpb249IjEuMSIge…This (the charactors) continues for a few paragpahs

I haven’t changed anything in the past few days. Didn’t mess with any settings or anything like that.

I did update a few plugins including:
Breeze cache plugin
EWWW Image Optimizer
Really Simple SSL

It’s a WordPress site on Ubuntu 16.04.1 x64. I am using ServerPilot to manage the server.

I was hoping someone could help me and point me towards the right direction. Thank you very much in advance.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
3 answers

Hi @saeeddarabi,

As I promised, I’m posting this answer explaining Apache Workers and why I think they can be the source of the slowness you’ve been experiencing recently.

So first, what are Apache Workers and what are they used for:

Imagine you are in a cinema, and there are 300 chairs inside. Those are the Apache Workers and the movie is your Webiste. If someone wants to watch the movie(your website) they need to sit in the chair (Apache Workers). If all 300 chars are taken, the 301 person needs to wait for someone to leave in order for them to sit and watch the movie. That’s how ApacheWorkers work. Once all ApacheWorkers are taken, a new person that wants to open your website waits for a spot to be open and only after that they can see your website.

Usually, these limits are set by 256 by default but they can be increased.

You can open your Apache configuration file. In there you should see something similar to:

ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000

Increase both the ServerLimit and MaxClients options, restart Apache, and see if this would solve your issue.

It’s possible they do not exist (haven’t been added) and the default values are the ones above. Adding them to the prefork content of apache mods should be fine as well.

Don’t forget to restart Apache afterward.

Regards,
KFSys

  • What a fantastic example. Your awesome explanation took me from hearing the term “Apache Workers” for the first few times to understanding what it actually is and does. Brilliant analogy.

    I’m still a bit timid and green when it comes to editing core files and working on the “server” so I am going to take my time and carefully implement your recommendation this weekend and see how it works.

    Once again, thank you so very much for taking your time to explain things so clearly. Have a fantastic weekend.

    • Hi @saeeddarabi,

      I’m really glad to be of help and thank you so much for the kind words!

      If you have any other questions either regarding this topic or any other, don’t hesitate to ask them, this is why this community is here so that we can help each other.

Hi @saeeddarabi,

Looking at the errors, both are not and should not be related to your website loading slow, most probably the issue is somewhere else.

Nevertheless, let’s explain the errors you see just so that you are aware what they are from.

The first error - No matching DirectoryIndex shows that there is no index file (index.html,index.htm,index.php) inside /srv/users/serverpilot/apps/sitename/public/wp-content/uploads/2021/05/ and as such can’t server the directory. This is not a problem, most probably someone tried to load the directory directly.

The second error - (36)File name too long. You are running into a limitation of the underlying file system. Most OS have a Maximum filename length of 255 bytes. Thus, when apache and/or your rewrite rule checks if the file exists an error is returned to apache by the operating system.

With Apache, if you put rules such as this in the .htaccess file, it’s too late to work around the problem. Apache will have already attempted to stat the long filename thus throwing the file system error ’(36)File name too long. I’ll recommend changing the URL format of your WordPress Website to a maximum of 255 characters.

Now, let’s review the slow website issue. I believe it’s related to something else rather than the above. When you SSH to your droplet and type in:

free -mh

and

w

How much Free memory you see and how much load do you see?

Addiionally, the websites not working might be related to ApacheWorkers being full so I’ll recommend checking this possibility out as well.

  • Hi KFSys,

    Thank you very much for taking the time to explain things so clearly for somebody like me who is a beginner when it comes to managing servers. I really appreciate it.

    So turns out the problem (at least as far as the traffic drop goes) was because of the Breeze cache plugin. As soon as I deactivated, the W3Counter started counting again and today’s traffic number is where it usually should be during this time of the day.

    So I’m assuming the latest Breeze update (which I updated right before all of this happened) had some conflicting issue with other stuff. So for now I have it deactivated. I am assuming those errors had to do with the cache plugin?

    The first error - Thank you for that. I am glad that’s not an issue and I don’t have to worry about it.

    The second error - *The results I got from the commands you gave me are:
    Mem: I have *
    280M free
    .
    Load average: 0.85, 0.80, 0.83

    Here are the whole results to give you a bigger picture:

    Memory:
    total used free shared buff/cache available
    Mem: 992M 295M 280M 33M 416M 478M
    Swap: 511M 398M 113M

    Load:
    16:16:57 up 94 days, 13:08, 1 user, load average: 0.85, 0.80, 0.83

    I have actually been thinking about upgrading my server. I started with the basic one a while back but the site has gotten too big now (even though I think I am doing a decent job of doing the usual stuff, few plugins, clean codes, optimized images, caching, etc). Does what you see above suggest that upgrading could help load time?

    My current plan is the basic $10/mo, Shared CPU 1 vCPU 1GB / 30GB Disk.

    I’ll recommend changing the URL format of your WordPress Website to a maximum of 255 characters.
    Would something like this do it?

    Once again, thank you very much for taking the time to help out. I really appreciate it. And so sorry for all the questions.

    • Hi @saeeddarabi,

      First, let me say that I’m very glad to be of help!

      Good catch with the plugin (Breeze) and regarding the errors, yes, it’s possible they had something to do with the cache plugin, you understood it correctly.

      Regarding load and memory everything looks great and okay. You seem to have enough Memory and your Droplet is not under load. Which makes this a lot more interesting as to why your website was loading slower.

      I’ll add another answer to the topic about how to change your ApacheWorkers as I think this was the source of the issue.

      About the URLs format, the link you posted should be a of help, yes. That way you won’t need to change their format and just allow ones with more characters in Apache directly.

Hello @saeeddarabi

If all the Apache errors are for no matching index in the wp-content folder this is fine, because you wouldn’t expect to have an index file in public/wp-content/uploads/2021/05

Do you have some custom rewrite rules in the .htaccess access? That will explain the second error, but this can also happen if some robot is crawling the site and it’s not following the redirection. You can also increase the LimitRequestLine Directive in Apache but this should only be a temporary solution since the LimitRequestLine directive can help you in case of denial of service attacks and etc.

Regards,
Alex

  • Hi Alex,

    Thank you very much for helping. Much appreciated.

    I do have some custom rewrite rules but not sure which if any would be the issue.

    They include:

    A few 301 redirecting a few posts

    One for redirecting www to non www version which is:

    RewriteCond %{HTTP_HOST} =www.site.com
    RewriteRule (.*) https://site.com/$1 [R=302,L]
    

    And this one:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
        RewriteBase /
        RewriteRule ^index\.php$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /index.php [L]
    </IfModule>
    

    Thanks very much again for your help, Alex. You guys taking tie out of your busy day to help others for free is absolutely fantastic.

    • Hello, @saeeddarabi

      The rewrite rules look fine and should not be causing the issue. Can you recall if the issues with the File name too long: AH00127: Cannot map HEAD started recently perhaps after plugin install or a version update?

      You can temporary disable the Breeze plugin and test to see if it will fix the issue. It is possible that the plugin may change some of the URLs by adding some extra characters in the permalinks.

      Regards,
      Alex

      • Hi Alex,

        So sorry for the very late reply. Totally missed it.

        So as I mentioned to KFSys comment above, it turns out Breeze was actually the problem. The issue started a day after I updated the plugin to the latest version. I went through the 3-4 recently updated plugins and after deactivating Breeze, the problem went away.

        I contacted the plugin creator and explained the issue. Haven’t heard back. I can’t complain though, this is a great free plugin so I don’t expect them to offer free support 24/7. Just the fact they offer this amazing plugin for free is more than enough.

        For now, I have installed the WP-Optimize plugin since it does other stuff besides caching like image optimization, database clean up, etc. Hopefully, Breeze will fix the issue in their future update. I love the plugin mainly because it is very light (I am kind of obsessed with trying to make sure the site loads fast so I try to use limited plugins and only the lightest ones) compared to other ones and it does the job brilliantly.

        Thanks very much for taking the time to help out, Alex. Much appreciated.

        • Hello, @saeeddarabi

          You’re most welcome! I’m glad that you’ve found the source of the issue and I hope that the plugin support team will sort out the problem for you in no time.

          Regards,
          Alex