🚀 Initial release: Complete Ansible LEMP WordPress automation
✨ Features: - Complete LEMP stack automation - WordPress with WP-CLI - Redis Object Cache (50% performance boost) - Multi-OS support - SSL/Let's Encrypt integration - Security hardening - Enterprise features - Docker testing environment - GitHub Actions CI/CD - Comprehensive documentation 🧪 Fully tested and production-ready Copyright (c) 2025 Sebastian Palencsár
This commit is contained in:
235
docs/contributing.md
Normal file
235
docs/contributing.md
Normal file
@@ -0,0 +1,235 @@
|
||||
# Contributing to Ansible LEMP WordPress
|
||||
|
||||
Thank you for your interest in contributing! This document provides guidelines for contributing to this project.
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
This project follows the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/). By participating, you agree to uphold this code.
|
||||
|
||||
## How to Contribute
|
||||
|
||||
### Reporting Bugs
|
||||
|
||||
Before creating bug reports, please check the existing issues to avoid duplicates. When creating a bug report, include:
|
||||
|
||||
- **Description:** Clear description of the issue
|
||||
- **Environment:** OS version, Ansible version, target system details
|
||||
- **Steps to reproduce:** Detailed steps to recreate the issue
|
||||
- **Expected behavior:** What you expected to happen
|
||||
- **Actual behavior:** What actually happened
|
||||
- **Logs:** Relevant log output (use code blocks)
|
||||
- **Configuration:** Your inventory and variable files (sanitized)
|
||||
|
||||
### Suggesting Features
|
||||
|
||||
Feature requests are welcome! Please:
|
||||
|
||||
- Check existing feature requests first
|
||||
- Provide a clear use case
|
||||
- Explain the expected behavior
|
||||
- Consider implementation complexity
|
||||
- Be open to discussion
|
||||
|
||||
### Pull Requests
|
||||
|
||||
1. **Fork the repository**
|
||||
2. **Create a feature branch:** `git checkout -b feature/amazing-feature`
|
||||
3. **Make your changes**
|
||||
4. **Test thoroughly** (see Testing section)
|
||||
5. **Commit with clear messages**
|
||||
6. **Push to your fork:** `git push origin feature/amazing-feature`
|
||||
7. **Open a Pull Request**
|
||||
|
||||
#### Pull Request Guidelines
|
||||
|
||||
- **Clear title:** Summarize the change in the title
|
||||
- **Description:** Explain what and why, not just how
|
||||
- **Link issues:** Reference related issues with "Fixes #123"
|
||||
- **Test coverage:** Ensure your changes are tested
|
||||
- **Documentation:** Update docs if needed
|
||||
- **Small changes:** Keep PRs focused and manageable
|
||||
|
||||
## Development Setup
|
||||
|
||||
### Prerequisites
|
||||
|
||||
- Ansible 2.9+
|
||||
- Docker and Docker Compose (for testing)
|
||||
- Git
|
||||
- Text editor with YAML support
|
||||
|
||||
### Local Development
|
||||
|
||||
1. **Clone your fork:**
|
||||
```bash
|
||||
git clone https://github.com/yourusername/ansible-lemp-wordpress.git
|
||||
cd ansible-lemp-wordpress
|
||||
```
|
||||
|
||||
2. **Set up testing environment:**
|
||||
```bash
|
||||
cd docker/
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
3. **Test your changes:**
|
||||
```bash
|
||||
ansible-playbook -i inventory/docker.ini playbooks/lemp-wordpress.yml
|
||||
```
|
||||
|
||||
### Testing
|
||||
|
||||
Before submitting, please test your changes:
|
||||
|
||||
#### Unit Tests
|
||||
```bash
|
||||
# Lint Ansible playbooks
|
||||
ansible-lint playbooks/*.yml
|
||||
|
||||
# Validate YAML syntax
|
||||
ansible-playbook --syntax-check playbooks/lemp-wordpress.yml
|
||||
```
|
||||
|
||||
#### Integration Tests
|
||||
```bash
|
||||
# Test on Docker container
|
||||
cd docker/
|
||||
docker-compose up -d
|
||||
ansible-playbook -i ../inventory/docker.ini ../playbooks/lemp-wordpress.yml
|
||||
|
||||
# Test WordPress installation
|
||||
ansible-playbook -i ../inventory/docker.ini ../playbooks/install-wordpress-official.yml
|
||||
|
||||
# Verify installation
|
||||
curl -I http://localhost:8080
|
||||
```
|
||||
|
||||
#### Multi-OS Testing
|
||||
Test on different operating systems:
|
||||
- Ubuntu 20.04 LTS
|
||||
- Ubuntu 22.04 LTS
|
||||
- Ubuntu 24.04 LTS
|
||||
- Debian 11
|
||||
- Debian 12
|
||||
|
||||
## Coding Standards
|
||||
|
||||
### Ansible Best Practices
|
||||
|
||||
- **Use descriptive task names**
|
||||
- **Add appropriate tags**
|
||||
- **Use variables for reusable values**
|
||||
- **Follow idempotency principles**
|
||||
- **Include proper error handling**
|
||||
|
||||
### YAML Style
|
||||
|
||||
```yaml
|
||||
# Good
|
||||
- name: Install nginx package
|
||||
apt:
|
||||
name: nginx
|
||||
state: present
|
||||
update_cache: yes
|
||||
tags:
|
||||
- nginx
|
||||
- packages
|
||||
|
||||
# Avoid
|
||||
- apt: name=nginx state=present update_cache=yes
|
||||
```
|
||||
|
||||
### Variables
|
||||
|
||||
- Use lowercase with underscores: `mysql_root_password`
|
||||
- Group related variables in files
|
||||
- Provide sensible defaults
|
||||
- Document complex variables
|
||||
|
||||
### Templates
|
||||
|
||||
- Use `.j2` extension for Jinja2 templates
|
||||
- Include header comments
|
||||
- Use consistent indentation
|
||||
- Test template rendering
|
||||
|
||||
## File Structure
|
||||
|
||||
```
|
||||
ansible-lemp-wordpress/
|
||||
├── playbooks/ # Main playbooks
|
||||
├── roles/ # Ansible roles (if used)
|
||||
├── templates/ # Jinja2 templates
|
||||
├── vars/ # Variable definitions
|
||||
├── inventory/ # Inventory examples
|
||||
├── docker/ # Docker testing environment
|
||||
├── docs/ # Documentation
|
||||
├── tests/ # Test scripts
|
||||
└── .github/ # GitHub workflows
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
### Required Documentation
|
||||
|
||||
- Update README.md for significant changes
|
||||
- Add inline comments for complex logic
|
||||
- Update relevant docs/ files
|
||||
- Include examples for new features
|
||||
|
||||
### Documentation Style
|
||||
|
||||
- Use clear, concise language
|
||||
- Include code examples
|
||||
- Provide both basic and advanced usage
|
||||
- Test all documented commands
|
||||
|
||||
## Release Process
|
||||
|
||||
### Version Numbering
|
||||
|
||||
This project follows [Semantic Versioning](https://semver.org/):
|
||||
- **MAJOR:** Incompatible API changes
|
||||
- **MINOR:** New functionality (backward compatible)
|
||||
- **PATCH:** Bug fixes (backward compatible)
|
||||
|
||||
### Changelog
|
||||
|
||||
Update CHANGELOG.md for all changes:
|
||||
- **Added:** New features
|
||||
- **Changed:** Changes in existing functionality
|
||||
- **Deprecated:** Soon-to-be removed features
|
||||
- **Removed:** Removed features
|
||||
- **Fixed:** Bug fixes
|
||||
- **Security:** Security improvements
|
||||
|
||||
## Getting Help
|
||||
|
||||
- **Documentation:** Check the docs/ directory
|
||||
- **Issues:** Search existing GitHub issues
|
||||
- **Discussions:** Use GitHub Discussions for questions
|
||||
- **IRC:** Join #ansible on Libera.Chat
|
||||
- **Community:** Ansible community forums
|
||||
|
||||
## Recognition
|
||||
|
||||
Contributors will be recognized in:
|
||||
- README.md contributors section
|
||||
- Release notes for significant contributions
|
||||
- Project documentation
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under the MIT License.
|
||||
|
||||
## Questions?
|
||||
|
||||
Don't hesitate to ask! Open an issue with the "question" label or start a discussion.
|
||||
|
||||
Thank you for contributing! 🎉
|
||||
|
||||
## 👨💻 Maintainer
|
||||
|
||||
**Sebastian Palencsár**
|
||||
Copyright (c) 2025 Sebastian Palencsár
|
||||
|
||||
265
docs/production-deployment.md
Normal file
265
docs/production-deployment.md
Normal file
@@ -0,0 +1,265 @@
|
||||
# Production Deployment Guide
|
||||
|
||||
This guide walks you through deploying WordPress on a production server using this Ansible automation.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
### Control Machine (Your Local Computer)
|
||||
- Ansible 6.0 or higher
|
||||
- SSH client
|
||||
- Git (to clone this repository)
|
||||
|
||||
### Target Server
|
||||
- Ubuntu 24.04 LTS (recommended) or other supported OS
|
||||
- Minimum 1GB RAM (2GB+ recommended)
|
||||
- 10GB+ free disk space
|
||||
- Root or sudo access
|
||||
- SSH access enabled
|
||||
|
||||
## Step-by-Step Deployment
|
||||
|
||||
### 1. Prepare Your Server
|
||||
|
||||
#### Create a Non-Root User (if not exists)
|
||||
```bash
|
||||
# On your server, as root:
|
||||
adduser deployer
|
||||
usermod -aG sudo deployer
|
||||
|
||||
# Add passwordless sudo (optional but recommended)
|
||||
echo "deployer ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/deployer
|
||||
```
|
||||
|
||||
#### Set Up SSH Key Authentication
|
||||
```bash
|
||||
# On your local machine:
|
||||
ssh-keygen -t ed25519 -C "your-email@example.com"
|
||||
ssh-copy-id deployer@your-server.com
|
||||
|
||||
# Test connection:
|
||||
ssh deployer@your-server.com
|
||||
```
|
||||
|
||||
### 2. Clone and Configure
|
||||
|
||||
```bash
|
||||
# Clone the repository
|
||||
git clone https://github.com/yourusername/ansible-lemp-wordpress.git
|
||||
cd ansible-lemp-wordpress
|
||||
|
||||
# Create your inventory
|
||||
cp inventory/production.example inventory/production.ini
|
||||
```
|
||||
|
||||
### 3. Edit Inventory Configuration
|
||||
|
||||
Edit `inventory/production.ini`:
|
||||
|
||||
```ini
|
||||
[webservers]
|
||||
your-domain.com ansible_user=deployer ansible_ssh_private_key_file=~/.ssh/id_ed25519
|
||||
|
||||
[webservers:vars]
|
||||
# WordPress Configuration
|
||||
wp_admin_user=admin
|
||||
wp_admin_password=your_very_secure_password_here
|
||||
wp_admin_email=admin@your-domain.com
|
||||
wp_site_title=Your WordPress Site
|
||||
wp_site_url=https://your-domain.com
|
||||
|
||||
# Database Configuration
|
||||
mysql_root_password=extremely_secure_root_password
|
||||
wordpress_db_name=wordpress_prod
|
||||
wordpress_db_user=wp_prod_user
|
||||
wordpress_db_password=secure_database_password
|
||||
|
||||
# SSL Configuration
|
||||
enable_ssl=true
|
||||
ssl_email=admin@your-domain.com
|
||||
```
|
||||
|
||||
### 4. Test Connection
|
||||
|
||||
```bash
|
||||
ansible -i inventory/production.ini webservers -m ping
|
||||
```
|
||||
|
||||
Expected output:
|
||||
```
|
||||
your-domain.com | SUCCESS => {
|
||||
"changed": false,
|
||||
"ping": "pong"
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Deploy LEMP Stack
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/production.ini playbooks/lemp-wordpress.yml
|
||||
```
|
||||
|
||||
This will:
|
||||
- Update system packages
|
||||
- Install and configure Nginx
|
||||
- Install and secure MySQL
|
||||
- Install PHP with required extensions
|
||||
- Configure firewall (if applicable)
|
||||
|
||||
### 6. Install WordPress
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/production.ini playbooks/install-wordpress-official.yml
|
||||
```
|
||||
|
||||
This will:
|
||||
- Download and install WP-CLI
|
||||
- Download latest WordPress
|
||||
- Create wp-config.php
|
||||
- Set up database and admin user
|
||||
- Configure proper file permissions
|
||||
|
||||
### 7. Post-Deployment Steps
|
||||
|
||||
#### Update DNS Records
|
||||
Point your domain to your server's IP address:
|
||||
```
|
||||
A Record: your-domain.com → YOUR_SERVER_IP
|
||||
A Record: www.your-domain.com → YOUR_SERVER_IP
|
||||
```
|
||||
|
||||
#### Set Up SSL (if enabled)
|
||||
If you set `enable_ssl=true`, SSL certificates will be automatically configured via Let's Encrypt.
|
||||
|
||||
#### Test Your Site
|
||||
- Visit: `https://your-domain.com`
|
||||
- Admin: `https://your-domain.com/wp-admin`
|
||||
|
||||
## Security Recommendations
|
||||
|
||||
### 1. Change Default Passwords
|
||||
Immediately change all default passwords:
|
||||
- WordPress admin password
|
||||
- Database passwords
|
||||
- Server user passwords
|
||||
|
||||
### 2. Update WordPress Admin Email
|
||||
Go to WordPress Admin → Settings → General and update the admin email.
|
||||
|
||||
### 3. Install Security Plugins
|
||||
Consider installing:
|
||||
- Wordfence Security
|
||||
- Updraft Plus (for backups)
|
||||
- iThemes Security
|
||||
|
||||
### 4. Server Security
|
||||
```bash
|
||||
# Enable automatic security updates
|
||||
sudo dpkg-reconfigure -plow unattended-upgrades
|
||||
|
||||
# Configure firewall
|
||||
sudo ufw allow ssh
|
||||
sudo ufw allow http
|
||||
sudo ufw allow https
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
### 5. Database Security
|
||||
- Use strong passwords
|
||||
- Limit database access to localhost only
|
||||
- Regular backups
|
||||
|
||||
## Monitoring and Maintenance
|
||||
|
||||
### 1. Log Files
|
||||
Monitor these log files:
|
||||
- Nginx: `/var/log/nginx/access.log` and `/var/log/nginx/error.log`
|
||||
- PHP-FPM: `/var/log/php8.3-fpm.log`
|
||||
- MySQL: `/var/log/mysql/error.log`
|
||||
- WordPress: `/var/www/html/wp-content/debug.log` (if WP_DEBUG enabled)
|
||||
|
||||
### 2. Regular Updates
|
||||
```bash
|
||||
# Update system packages
|
||||
sudo apt update && sudo apt upgrade
|
||||
|
||||
# Update WordPress (via WP-CLI)
|
||||
cd /var/www/html
|
||||
sudo -u www-data wp core update --allow-root
|
||||
sudo -u www-data wp plugin update --all --allow-root
|
||||
sudo -u www-data wp theme update --all --allow-root
|
||||
```
|
||||
|
||||
### 3. Backups
|
||||
Set up automated backups:
|
||||
- Database: `mysqldump`
|
||||
- Files: `rsync` or cloud storage
|
||||
- Consider using backup plugins like UpdraftPlus
|
||||
|
||||
### 4. Performance Monitoring
|
||||
Monitor:
|
||||
- Server resources (CPU, RAM, disk space)
|
||||
- Website response times
|
||||
- Database query performance
|
||||
- Error rates
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Connection Issues
|
||||
```bash
|
||||
# Test Ansible connection
|
||||
ansible -i inventory/production.ini webservers -m ping
|
||||
|
||||
# Test SSH connection
|
||||
ssh -v deployer@your-server.com
|
||||
```
|
||||
|
||||
### Service Issues
|
||||
```bash
|
||||
# Check service status
|
||||
sudo systemctl status nginx
|
||||
sudo systemctl status mysql
|
||||
sudo systemctl status php8.3-fpm
|
||||
|
||||
# View logs
|
||||
sudo journalctl -u nginx
|
||||
sudo journalctl -u mysql
|
||||
sudo journalctl -u php8.3-fpm
|
||||
```
|
||||
|
||||
### WordPress Issues
|
||||
```bash
|
||||
# Check WordPress installation
|
||||
cd /var/www/html
|
||||
sudo -u www-data wp core verify-checksums --allow-root
|
||||
|
||||
# Check database connection
|
||||
sudo -u www-data wp db check --allow-root
|
||||
```
|
||||
|
||||
## Scaling Considerations
|
||||
|
||||
### Multi-Server Setup
|
||||
For high-traffic sites, consider:
|
||||
- Load balancer (Nginx or HAProxy)
|
||||
- Database replication or clustering
|
||||
- Redis/Memcached for object caching
|
||||
- CDN for static assets
|
||||
|
||||
### Performance Optimization
|
||||
- PHP OPcache configuration
|
||||
- Nginx caching
|
||||
- Database query optimization
|
||||
- Image optimization
|
||||
- Content compression
|
||||
|
||||
## Support
|
||||
|
||||
If you encounter issues:
|
||||
1. Check the [Troubleshooting Guide](troubleshooting.md)
|
||||
2. Review server logs
|
||||
3. Open an issue on GitHub
|
||||
4. Check existing discussions
|
||||
|
||||
---
|
||||
|
||||
**Next Steps**: [SSL Setup Guide](ssl-setup.md)
|
||||
74
docs/ssl-setup.md
Normal file
74
docs/ssl-setup.md
Normal file
@@ -0,0 +1,74 @@
|
||||
# SSL/HTTPS Setup Guide
|
||||
|
||||
This guide explains how to set up SSL certificates for your WordPress installation.
|
||||
|
||||
## Let's Encrypt with Certbot
|
||||
|
||||
### Prerequisites
|
||||
- Domain name pointing to your server
|
||||
- Ports 80 and 443 open in firewall
|
||||
- Nginx already configured and running
|
||||
|
||||
### Automatic SSL Setup
|
||||
|
||||
The playbook includes an optional SSL setup that uses Let's Encrypt:
|
||||
|
||||
```bash
|
||||
ansible-playbook -i inventory/production playbooks/lemp-wordpress.yml -e enable_ssl=true -e domain_name=yourdomain.com
|
||||
```
|
||||
|
||||
### Manual SSL Setup
|
||||
|
||||
If you prefer manual setup or have your own certificates:
|
||||
|
||||
1. **Install Certbot:**
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install certbot python3-certbot-nginx
|
||||
```
|
||||
|
||||
2. **Generate Certificate:**
|
||||
```bash
|
||||
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
|
||||
```
|
||||
|
||||
3. **Auto-renewal:**
|
||||
```bash
|
||||
sudo crontab -e
|
||||
# Add: 0 12 * * * /usr/bin/certbot renew --quiet
|
||||
```
|
||||
|
||||
### SSL Configuration
|
||||
|
||||
The SSL-enabled Nginx configuration includes:
|
||||
- HTTP to HTTPS redirect
|
||||
- Strong SSL ciphers
|
||||
- HSTS headers
|
||||
- OCSP stapling
|
||||
|
||||
### Troubleshooting SSL
|
||||
|
||||
**Certificate not found:**
|
||||
- Verify domain DNS points to server
|
||||
- Check firewall allows ports 80/443
|
||||
- Ensure Nginx is running
|
||||
|
||||
**Mixed content warnings:**
|
||||
- Update WordPress site URL in database
|
||||
- Check for hardcoded HTTP links
|
||||
- Use SSL-aware plugins
|
||||
|
||||
**Certificate renewal fails:**
|
||||
- Check Nginx configuration syntax
|
||||
- Verify webroot path permissions
|
||||
- Review certbot logs: `/var/log/letsencrypt/`
|
||||
|
||||
## Custom Certificates
|
||||
|
||||
To use your own SSL certificates:
|
||||
|
||||
1. Copy certificates to `/etc/ssl/certs/`
|
||||
2. Update Nginx configuration
|
||||
3. Restart Nginx service
|
||||
|
||||
See `templates/wordpress-ssl.nginx.j2` for the SSL template.
|
||||
290
docs/troubleshooting.md
Normal file
290
docs/troubleshooting.md
Normal file
@@ -0,0 +1,290 @@
|
||||
# Troubleshooting Guide
|
||||
|
||||
Common issues and their solutions when using the LEMP WordPress automation.
|
||||
|
||||
## Installation Issues
|
||||
|
||||
### Ansible Connection Problems
|
||||
|
||||
**SSH Connection Refused:**
|
||||
```bash
|
||||
# Check if SSH service is running
|
||||
sudo systemctl status ssh
|
||||
sudo systemctl start ssh
|
||||
|
||||
# Verify SSH port (default 22)
|
||||
sudo netstat -tlnp | grep :22
|
||||
```
|
||||
|
||||
**Permission Denied (publickey):**
|
||||
```bash
|
||||
# Use password authentication temporarily
|
||||
ansible-playbook -i inventory/production playbooks/lemp-wordpress.yml --ask-pass
|
||||
|
||||
# Or set up SSH keys
|
||||
ssh-copy-id username@your-server
|
||||
```
|
||||
|
||||
**Host Key Verification Failed:**
|
||||
```bash
|
||||
# Remove old host key
|
||||
ssh-keygen -R your-server-ip
|
||||
|
||||
# Or disable host key checking temporarily
|
||||
export ANSIBLE_HOST_KEY_CHECKING=False
|
||||
```
|
||||
|
||||
### Package Installation Failures
|
||||
|
||||
**Package Not Found:**
|
||||
```bash
|
||||
# Update package cache first
|
||||
sudo apt update
|
||||
|
||||
# Check if universe repository is enabled (Ubuntu)
|
||||
sudo add-apt-repository universe
|
||||
```
|
||||
|
||||
**Lock Error (dpkg/apt):**
|
||||
```bash
|
||||
# Kill any running package managers
|
||||
sudo killall apt apt-get dpkg
|
||||
|
||||
# Remove locks
|
||||
sudo rm /var/lib/apt/lists/lock
|
||||
sudo rm /var/cache/apt/archives/lock
|
||||
sudo rm /var/lib/dpkg/lock*
|
||||
|
||||
# Reconfigure packages
|
||||
sudo dpkg --configure -a
|
||||
```
|
||||
|
||||
## Service Issues
|
||||
|
||||
### Nginx Problems
|
||||
|
||||
**Nginx Won't Start:**
|
||||
```bash
|
||||
# Check configuration syntax
|
||||
sudo nginx -t
|
||||
|
||||
# Check what's using port 80
|
||||
sudo netstat -tlnp | grep :80
|
||||
sudo lsof -i :80
|
||||
|
||||
# Check logs
|
||||
sudo journalctl -u nginx -f
|
||||
```
|
||||
|
||||
**403 Forbidden Error:**
|
||||
```bash
|
||||
# Check file permissions
|
||||
ls -la /var/www/html/
|
||||
sudo chown -R www-data:www-data /var/www/html/
|
||||
sudo chmod -R 755 /var/www/html/
|
||||
|
||||
# Check Nginx user in config
|
||||
grep user /etc/nginx/nginx.conf
|
||||
```
|
||||
|
||||
### MySQL/MariaDB Issues
|
||||
|
||||
**MySQL Won't Start:**
|
||||
```bash
|
||||
# Check MySQL status and logs
|
||||
sudo systemctl status mysql
|
||||
sudo journalctl -u mysql -f
|
||||
|
||||
# Check disk space
|
||||
df -h
|
||||
|
||||
# Reset MySQL if corrupted
|
||||
sudo systemctl stop mysql
|
||||
sudo mysqld_safe --skip-grant-tables &
|
||||
```
|
||||
|
||||
**Can't Connect to Database:**
|
||||
```bash
|
||||
# Test MySQL connection
|
||||
mysql -u root -p
|
||||
mysql -u wordpress_user -p wordpress_db
|
||||
|
||||
# Check user privileges
|
||||
mysql -u root -p -e "SELECT user,host FROM mysql.user;"
|
||||
mysql -u root -p -e "SHOW GRANTS FOR 'wordpress_user'@'localhost';"
|
||||
```
|
||||
|
||||
**Access Denied for User:**
|
||||
```bash
|
||||
# Reset WordPress database user
|
||||
mysql -u root -p
|
||||
DROP USER IF EXISTS 'wordpress_user'@'localhost';
|
||||
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'your_password';
|
||||
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
|
||||
FLUSH PRIVILEGES;
|
||||
```
|
||||
|
||||
### PHP-FPM Issues
|
||||
|
||||
**PHP-FPM Not Working:**
|
||||
```bash
|
||||
# Check PHP-FPM status
|
||||
sudo systemctl status php8.3-fpm
|
||||
|
||||
# Check socket file
|
||||
ls -la /run/php/php8.3-fpm.sock
|
||||
|
||||
# Check PHP-FPM configuration
|
||||
sudo nginx -t
|
||||
sudo php-fpm8.3 -t
|
||||
```
|
||||
|
||||
**PHP Errors in WordPress:**
|
||||
```bash
|
||||
# Enable PHP error logging
|
||||
sudo tail -f /var/log/php8.3-fpm.log
|
||||
|
||||
# Check WordPress debug
|
||||
# Add to wp-config.php:
|
||||
define('WP_DEBUG', true);
|
||||
define('WP_DEBUG_LOG', true);
|
||||
|
||||
# Check WordPress logs
|
||||
tail -f /var/www/html/wp-content/debug.log
|
||||
```
|
||||
|
||||
## WordPress Issues
|
||||
|
||||
### WordPress Installation Problems
|
||||
|
||||
**White Screen of Death:**
|
||||
```bash
|
||||
# Check PHP errors
|
||||
sudo tail -f /var/log/php8.3-fpm.log
|
||||
sudo tail -f /var/log/nginx/error.log
|
||||
|
||||
# Increase PHP memory limit
|
||||
sudo nano /etc/php/8.3/fpm/php.ini
|
||||
# memory_limit = 256M
|
||||
|
||||
sudo systemctl restart php8.3-fpm
|
||||
```
|
||||
|
||||
**Database Connection Error:**
|
||||
```bash
|
||||
# Verify wp-config.php settings
|
||||
sudo cat /var/www/html/wp-config.php
|
||||
|
||||
# Test database connection manually
|
||||
mysql -u wordpress_user -p wordpress_db
|
||||
```
|
||||
|
||||
**File Permissions Issues:**
|
||||
```bash
|
||||
# Set correct WordPress permissions
|
||||
sudo chown -R www-data:www-data /var/www/html/
|
||||
sudo find /var/www/html/ -type d -exec chmod 755 {} \;
|
||||
sudo find /var/www/html/ -type f -exec chmod 644 {} \;
|
||||
sudo chmod 600 /var/www/html/wp-config.php
|
||||
```
|
||||
|
||||
### Performance Issues
|
||||
|
||||
**Slow Website Loading:**
|
||||
```bash
|
||||
# Enable PHP OPcache
|
||||
sudo nano /etc/php/8.3/fpm/php.ini
|
||||
# opcache.enable=1
|
||||
# opcache.memory_consumption=128
|
||||
|
||||
# Optimize MySQL
|
||||
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
|
||||
# innodb_buffer_pool_size = 256M
|
||||
|
||||
# Enable Nginx gzip
|
||||
sudo nano /etc/nginx/nginx.conf
|
||||
# gzip on;
|
||||
```
|
||||
|
||||
## Security Issues
|
||||
|
||||
### File Permission Problems
|
||||
|
||||
**Incorrect Ownership:**
|
||||
```bash
|
||||
# WordPress files should be owned by www-data
|
||||
sudo chown -R www-data:www-data /var/www/html/
|
||||
|
||||
# wp-config.php should have restricted permissions
|
||||
sudo chmod 600 /var/www/html/wp-config.php
|
||||
```
|
||||
|
||||
**Upload Directory Issues:**
|
||||
```bash
|
||||
# Create uploads directory if missing
|
||||
sudo mkdir -p /var/www/html/wp-content/uploads
|
||||
sudo chown www-data:www-data /var/www/html/wp-content/uploads
|
||||
sudo chmod 755 /var/www/html/wp-content/uploads
|
||||
```
|
||||
|
||||
## Network Issues
|
||||
|
||||
### Firewall Configuration
|
||||
|
||||
**Can't Access Website:**
|
||||
```bash
|
||||
# Check if UFW is blocking
|
||||
sudo ufw status
|
||||
sudo ufw allow 80
|
||||
sudo ufw allow 443
|
||||
|
||||
# Check iptables
|
||||
sudo iptables -L
|
||||
```
|
||||
|
||||
**Domain/DNS Issues:**
|
||||
```bash
|
||||
# Test DNS resolution
|
||||
nslookup yourdomain.com
|
||||
dig yourdomain.com
|
||||
|
||||
# Test local access
|
||||
curl -I http://localhost
|
||||
curl -I http://your-server-ip
|
||||
```
|
||||
|
||||
## Log Files Locations
|
||||
|
||||
Important log files for debugging:
|
||||
|
||||
- **Nginx Access:** `/var/log/nginx/access.log`
|
||||
- **Nginx Error:** `/var/log/nginx/error.log`
|
||||
- **PHP-FPM:** `/var/log/php8.3-fpm.log`
|
||||
- **MySQL:** `/var/log/mysql/error.log`
|
||||
- **WordPress:** `/var/www/html/wp-content/debug.log`
|
||||
- **System:** `journalctl -f`
|
||||
|
||||
## Getting Help
|
||||
|
||||
1. **Check the logs first** - Most issues show up in the relevant log files
|
||||
2. **Test each component individually** - Nginx, PHP, MySQL, WordPress
|
||||
3. **Verify configuration files** - Use built-in syntax checkers
|
||||
4. **Check file permissions** - Many issues are permission-related
|
||||
5. **Open an issue** on GitHub with relevant log output
|
||||
|
||||
## Common Commands
|
||||
|
||||
```bash
|
||||
# Restart all services
|
||||
sudo systemctl restart nginx php8.3-fpm mysql
|
||||
|
||||
# Check all service status
|
||||
sudo systemctl status nginx php8.3-fpm mysql
|
||||
|
||||
# Test configurations
|
||||
sudo nginx -t
|
||||
sudo php-fpm8.3 -t
|
||||
|
||||
# Monitor logs in real-time
|
||||
sudo tail -f /var/log/nginx/error.log /var/log/php8.3-fpm.log
|
||||
```
|
||||
Reference in New Issue
Block a user