Error "not found or unable to stat" in apache logs, and difference in httpd.conf and site Document Roots

112,424

Solution 1

Found the answer; problem was hosts entries: Hosts file entries for multiple domains on VPS?

Solution 2

The DocumentRoot in httpd.conf is likely to be the default for any hosts not handled by a virtual host. For example, requests on the IP address.

You could set the DocumentRoot to be the same as the default site (if that's what you want for requests to the IP address), or you use a RewriteRule to rewrite the request back to the main site either in the httpd.conf or in the .htaccess file:

<Directory /var/www/html>  
    RewriteRule wp-cron.php http://yourdomainname.com/wp-cron.php [R=301]  
</Directory>

Without knowing what the script is, or if it exists elsewhere, it's not easy to advise. A symlink could also fix it, but permissions might get in your way.

Share:
112,424

Related videos on Youtube

markratledge
Author by

markratledge

Updated on September 17, 2022

Comments

  • markratledge
    markratledge almost 2 years

    I get many of these errors each day in my apache error log:

    [error] [client 127.0.0.1] script '/var/www/html/wp-cron.php' not found or unable to stat

    and I'm wondering if it has something to with my httpd.conf, because my DocumentRoot is set as "/var/www/html" but my WordPress site(s) are in a top directory called httpdocs, not html. wp-cron.php exists, but it's in httpdocs, not html, and there is no html directory. There are multiple WordPress sites and domains on the VPS and at the IP.

    There are no other errors like that in the logs, and WordPress seems to run fine. But I want to fix these errors, as it's a bit of an extra load on the server.

    Is there a way to add a redirect or alias in httpd.conf so wp-cron.php can be found? Or this a different matter with a different solution?

    Edit: Found the answer; problem was hosts file entries: Hosts file entries for multiple domains on VPS?

  • markratledge
    markratledge almost 14 years
    That makes sense. The file does exist, except it's in httpdocs, not html. And there are multiple installs of Wordpress under different domains, so I think they are all calling wp-cron.php at different times. So should I add that 301 redirect to each .htaccess in each Wordpress directory?
  • James L
    James L almost 14 years
    It would be more useful to determine why it's being called every day, and then fix the source. However, if you can't do that, just a 301 redirect in the /var/www/html should suffice.
  • markratledge
    markratledge almost 14 years
    It's Wordpress; that cron call happens at least every few hours. But I don't have a html directory, so I suppose I could make one and put a 301 redirect there in an .htaccess file?
  • James L
    James L almost 14 years
    If you don't have a /var/www/html, you need to fix your default documentroot so it's not pointing there.
  • markratledge
    markratledge almost 14 years
    Little hesitant to change the doc root and possibly take everything down. What should my etc/hosts file look like? There are multiple sites on the one IP, and the main site in particular isn't listed in hosts.