Problem Background
A WordPress-based website, deployed on a Hong Kong cloud server. The server environment was CentOS 6.8 64-bit, using the LNMP 1.5 one-click installation package.
The site initially had full HTTPS (SSL encryption) enabled. Later, it was discovered that HTTPS had some impact on SEO, and users in certain regions could not access HTTPS sites due to network restrictions.
Therefore, a plan was made to remove HTTPS and migrate the server. During the transition, both HTTP and HTTPS access were maintained.
Simultaneously, the object cache was changed from Memcached to Redis.
Symptoms
After migrating the server and switching the cache to Redis, it was found that the WordPress admin dashboard could not be accessed via the HTTP protocol.
Even after directly modifying the administrator password in the MySQL database via phpMyAdmin, login remained impossible. The system consistently displayed errors like "password mismatch" or "cookies are not enabled."
Analysis and Solution
After investigation, the root cause was identified as the Redis object cache. Redis likely contained cached old data related to user sessions, login status, or the non-HTTPS environment, causing login verification to fail.
Solution: Log into Redis and clear all cached data.
Steps
- Log into the server via SSH.
- Navigate to the Redis installation directory (path may vary):
cd /usr/local/redis - Access the Redis command-line client:
./bin/redis-cli - Execute the command to flush all databases (Warning: This deletes ALL data in Redis):
flushall
After execution, exit the Redis client and attempt to log into the WordPress admin again. Access should be restored.
Additional Notes and Recommendations
1. Root Cause: During the complex operation of migrating from HTTPS to HTTP and changing cache systems, Redis may have cached user sessions, site URLs, or authentication cookies containing old protocol (HTTPS) information, causing verification to fail in the new HTTP environment.
2. Safer Operation: If you only want to clear WordPress-related cache, not all data, it's recommended to use the management features provided by a WordPress Redis cache plugin (like Redis Object Cache) for clearing, or in the Redis CLI, specify to flush only the database used by WordPress (e.g., execute select 0 followed by flushdb).
3. Preventive Measures: Before making major environmental changes (like protocol switching or cache system replacement), proactively clear old cache data to avoid such issues.
4. Environment Update: The CentOS 6.8 and LNMP 1.5 versions mentioned are outdated. Consider upgrading the system to a supported version (like CentOS 7/8 or Rocky Linux/AlmaLinux) and using a more recent software stack for better security and compatibility.