The error message appearing in Apache logs indicates a fundamental path resolution issue. When Apache receives a request for wp-cron.php
, it's looking in /var/www/html/
while your actual WordPress files reside in /var/www/httpdocs/
. This mismatch between the DocumentRoot directive and actual file structure creates unnecessary 404 errors.
In a standard Apache setup for WordPress multisite, you'll typically find these configurations:
# In httpd.conf or sites-available/your-site.conf
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Meanwhile, your WordPress files are actually located at:
/var/www/httpdocs/
├── wp-admin/
├── wp-content/
├── wp-includes/
├── wp-cron.php
└── wp-config.php
Three approaches can resolve this permanently:
1. Correcting DocumentRoot
DocumentRoot "/var/www/httpdocs"
<Directory "/var/www/httpdocs">
# Rest of configuration remains same
2. Using Alias Directive
If you need to maintain the original DocumentRoot for other purposes:
Alias /wp-cron.php "/var/www/httpdocs/wp-cron.php"
<Directory "/var/www/httpdocs">
Options None
AllowOverride None
Require all granted
</Directory>
3. VirtualHost Configuration (Recommended for Multi-site)
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot "/var/www/httpdocs"
# Additional directives...
</VirtualHost>
For WordPress multisite environments, consider these best practices:
- Use separate VirtualHost blocks for each domain
- Maintain consistent directory naming conventions
- Verify host file entries match your VirtualHost configurations
- Use complete paths in WordPress configuration (WP_HOME, WP_SITEURL)
To verify your Apache configuration:
apachectl -t # Test configuration syntax
apachectl -S # Show parsed settings
Remember to restart Apache after configuration changes:
systemctl restart apache2 # For systemd systems
service apache2 restart # For older init systems
When running multiple WordPress sites on a VPS, you might encounter Apache errors like:
[error] [client 127.0.0.1] script '/var/www/html/wp-cron.php' not found or unable to stat
This typically occurs when there's a discrepancy between the DocumentRoot defined in httpd.conf and the actual WordPress installation directory structure.
The key problems in this scenario are:
- Apache's DocumentRoot is set to
/var/www/html
- WordPress files are actually located in
/var/www/httpdocs
- No physical
html
directory exists - wp-cron.php exists in httpdocs but Apache looks for it in html
Here are three approaches to resolve this:
1. Correcting DocumentRoot in Virtual Host
Update your virtual host configuration:
<VirtualHost *:80>
ServerName yourdomain.com
DocumentRoot /var/www/httpdocs
<Directory /var/www/httpdocs>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
2. Creating a Symlink (Quick Fix)
For a temporary solution until proper configuration is in place:
ln -s /var/www/httpdocs /var/www/html
3. Proper Hosts File Configuration
Ensure proper entries in /etc/hosts
for each domain:
127.0.0.1 yourdomain.com www.yourdomain.com
127.0.0.1 anotherdomain.com www.anotherdomain.com
To optimize WordPress cron handling:
# In wp-config.php
define('DISABLE_WP_CRON', true);
Then set up a proper system cron job:
# In crontab -e
*/15 * * * * wget -q -O - http://yourdomain.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1
After making changes:
- Restart Apache:
systemctl restart apache2
- Check error logs:
tail -f /var/log/apache2/error.log
- Test wp-cron access directly:
curl -I http://yourdomain.com/wp-cron.php
These changes should eliminate the error messages while maintaining proper WordPress functionality.