部署在Apache与AWS上的WordPress站点无明显诱因崩溃求助
Hey there, let's break down how to troubleshoot your suddenly offline WordPress site on this AWS setup. Since it's a low-traffic personal project, we can narrow down the issues pretty quickly without getting overwhelmed.
First, let's confirm if traffic is even reaching your backend instances:
- Head to the EC2 Console > Load Balancers, find your Application Load Balancer. Check its monitoring metrics (like Request Count, HTTP 5xx/4xx errors) and the Target Group health status. If all targets show as unhealthy, your ASG might be terminating instances because they fail health checks, leaving no backend to serve traffic.
- Jump to your Auto Scaling Group's Activity History tab. Look for any recent instance terminations or failed launches—this will tell you if the problem is with instance provisioning itself.
Since your WordPress files live on EFS (mounted automatically on instance launch), a failed mount is a common culprit here:
- If there are running EC2 instances, connect via SSH and check if EFS is mounted properly. Run
df -hto see if the EFS filesystem appears in the list. If not, check the system log (EC2 Console > Instance > Actions > Monitor and troubleshoot > Get system log) for mount errors—common issues include EFS security group not allowing NFS (port 2049) access from your EC2 security group, or incorrect mount target in your user data script. - If no instances are running, spin up a temporary test EC2 instance in the same VPC/security group, then manually mount EFS using the AWS CLI or mount command to confirm the filesystem is accessible.
Your WordPress database is the backbone—let's rule out DB issues:
- Go to the RDS Console, find your MySQL instance. Check its Status (should be "Available") and Storage Usage—even low-traffic sites can fill up storage over time with backups, spam comments, or post revisions.
- Verify the RDS security group allows inbound traffic on port 3306 from your EC2 instances' security group. If you recently modified security rules, that could block DB access.
- Test DB connectivity: From a running EC2 instance, use
mysql -h <RDS-endpoint> -u <db-user> -pto try logging in. If you can't connect, that's the issue. If you can, runUSE <wp-db-name>; SHOW TABLES;to confirm the database isn't corrupted.
If all infrastructure checks out, the problem might be with WordPress itself:
- Access your wp-config.php file (on the EFS mount) and double-check the DB credentials/endpoint—make sure
DB_HOST,DB_USER,DB_PASSWORD, andDB_NAMEare correct. - Enable WordPress debug logging to get specific error details: Add these lines to wp-config.php:
Then check thedefine( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true );wp-content/debug.logfile for fatal errors, plugin conflicts, or missing files.
Since this is a personal site with barely any visitors, consider temporarily disabling your Auto Scaling Group and launching a single EC2 instance manually. This removes the complexity of auto-scaling while you troubleshoot, making it easier to isolate the root cause.
内容的提问来源于stack exchange,提问作者Glenak1911

