diff --git a/README.md b/README.md index 975a1f0..3ecd868 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ This repository is structured into several key directories: - `pdftk.md`: PDF Toolkit usage. - `pip packaging.md`: Packaging Python projects with pip. - `ssh.md`: Secure Shell (SSH) configuration and tips. + - `wordpress.md`: WordPress debugging and tips. - **pages/other/**: Templates for other pages, such as the homepage of my Debian package repository. These are provided as inspiration and should not be used as-is. diff --git a/notes/wordpress.md b/notes/wordpress.md new file mode 100644 index 0000000..649c0f2 --- /dev/null +++ b/notes/wordpress.md @@ -0,0 +1,163 @@ +# WordPress + +## Table of Contents + +- [WordPress](#wordpress) + - [Table of Contents](#table-of-contents) + - [Documentation](#documentation) + - [Common WordPress Errors](#common-wordpress-errors) + - [Debugging Steps](#debugging-steps) + - [Debugging Tools](#debugging-tools) + +## Documentation + +- [wp-cli](https://developer.wordpress.org/cli/commands/) +- [Documentation Overview](https://www.wordpress.info/doc/overview/) +- [Tutorials](https://wordpress.com/learn/) + +## 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. + +2. **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`. + +3. **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`: + +```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`. + +2. **Check `.htaccess`** + +Ensure WordPress rules exist: + +```apache +# BEGIN WordPress + + +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] + + +# END WordPress +``` + +3. **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` + +```apache + + AllowOverride All + # Allow open access: + Require all granted + + + Options Indexes FollowSymLinks + AllowOverride All + Require all granted + +``` + +4. **Reset File Permissions** + +```bash +find /var/www/html -type d -exec chmod 755 {} \; +find /var/www/html -type f -exec chmod 644 {} \; +``` + +4. **Disable Plugins & Themes** + +Hide the plugin directory: + +```bash +mv wp-content/plugins wp-content/.plugins +``` + +Switch to a default theme: + +```bash +wp theme install twentytwentyfive --activate +wp theme activate twentytwentyfive +``` + +5. **Check Server Logs** + +For Apache: + +```bash +tail -f /var/log/httpd/error_log +``` + +For Nginx: + +```bash +tail -f /var/log/nginx/error.log +``` + +6. **Verify Database Connection** + +```bash +wp db check +``` + +If corrupt: + +```bash +wp db repair +``` + +7. **Increase Memory Limit** + +Edit `wp-config.php`: + +```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.