scripts-fabq/notes/wordpress.md

3.4 KiB

WordPress

Table of Contents

Documentation

Common WordPress Errors

  1. HTTP Errors
  • 404 Not Found: Page or resource missing.
  • 403 Forbidden: Insufficient permissions to access the resource.
  • 500 Internal Server Error: Generic error, often caused by server misconfiguration or PHP errors.
  • 503 Service Unavailable: Server is overloaded or in maintenance mode.
  1. Database Errors
  • Error Establishing a Database Connection: Database credentials incorrect or database server is down.
  • Table Prefix Issues: Wrong $table_prefix in wp-config.php.
  • Corrupt Database: Can be fixed using wp db repair.
  1. PHP Errors
  • Parse Error: Syntax error in PHP files.
  • Fatal Error: Missing function or class.
  • Deprecated Function Warnings: Old functions being used.

Debugging Steps

  1. Enable Debug Mode

Edit wp-config.php:

// Enable Debug Mode
define('WP_DEBUG', true);
// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);
// Disable display of WordPress errors and warnings
define('WP_DEBUG_DISPLAY', false);
// Disable display of PHP errors and warnings
@ini_set('display_errors', 0);

Logs will be saved in wp-content/debug.log.

  1. Check .htaccess

Ensure WordPress rules exist:

# BEGIN WordPress

<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>

# END WordPress
  1. Check Apache and VirtualHost config

Redhat and derivatives

  • /etc/httpd/conf/httpd.conf
  • /etc/httpd/conf.d/welcome.conf

Debian and derivatives

  • /etc/apache2/apache2.conf
  • /etc/apache2/sites-available/000-default.conf
<Directory "/var/www">
    AllowOverride All
    # Allow open access:
    Require all granted
</Directory>
<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
  1. Reset File Permissions
find /var/www/html -type d -exec chmod 755 {} \;
find /var/www/html -type f -exec chmod 644 {} \;
  1. Disable Plugins & Themes

Hide the plugin directory:

mv wp-content/plugins wp-content/.plugins

Switch to a default theme:

wp theme install twentytwentyfive --activate
wp theme activate twentytwentyfive
  1. Check Server Logs

For Apache:

tail -f /var/log/httpd/error_log

For Nginx:

tail -f /var/log/nginx/error.log
  1. Verify Database Connection
wp db check

If corrupt:

wp db repair
  1. Increase Memory Limit

Edit wp-config.php:

define('WP_MEMORY_LIMIT', '256M');

Debugging Tools

  • WP-CLI: Command-line interface for WordPress.
  • Query Monitor: Plugin for analyzing database queries and errors.
  • Health Check & Troubleshooting: Plugin for diagnosing issues.