Wordpress Notes
This document contains various notes and configurations related to managing and maintaining WordPress installations.
Migration
When migrating a WordPress site from one server to another, consider the following steps:
- Backup Files and Database: Ensure you have a complete backup of your WordPress files and database.
- The files to back up include the entire WordPress directory, typically located at
/var/www/html/your-site. - The database can be backed up using tools like
mysqldump
- The files to back up include the entire WordPress directory, typically located at
mysqldump -u username -p database_name > backup.sql
- Transfer Files: Use
rsyncorscpto transfer the WordPress files to the new server.
rsync -avz /path/to/wordpress/ user@newserver:/path/to/destination/
- Import Database: On the new server, create a new database and import the backup.
mysql -u username -p new_database_name < backup.sql
-
Update wp-config.php: Modify the
wp-config.phpfile on the new server to reflect the new database credentials. -
Update Site URL: If the domain name has changed, update the site URL in the database. You can do this using wp-cli:
# Migrate http to https
docker run --rm --volumes-from wp-container --network container:wp-container wordpress:cli search-replace 'http://original.domain' 'https://new.domain'
# Migrate https to https
docker run --rm --volumes-from wp-container --network container:wp-container wordpress:cli search-replace 'https://original.domain' 'https://new.domain'
# Migrate any remaining references
docker run --rm --volumes-from wp-container --network container:wp-container wordpress:cli search-replace 'original.domain' 'new.domain'
# Flush cache
docker run --rm --volumes-from wp-container --network container:wp-container wordpress:cli cache flush
Remember to recreate any cache of the extensions you are using.