Good day!
How do you properly migrate your localhost wordpress file to a live server? What I do is usually copy all my wordpress file then transferred to my website thru FTP and the database is usually imported to the target sql.
The problem is when I do this, the website layout gets all messed up. I wanted to migrate my website without the layout being affected.
Thanks.
You can use the WP CLI too to rename your site’s hostname safely and effectively. There’s a chance that your layout is being messed up because naively replacing the domain name with a simple string replace, e.g. perl -pi -e 's/oldhost/newhost/g' backup.sql
, will not take into account things like serialized data.
Try this on your local machine after install WP-CLI:
Using the db-checkpoint
package:
wp package install binarygary/db-checkpoint
wp dbsnap pre-search-replace
wp search-replace --precise oldhost newhost
wp dbsnap post-search-replace
wp dbsnapback pre-search-replace
Now, take the file in wp-content/uploads/checkpoint-storage
that starts with post-search-replace
and import that to your remote host.
Without db-checkpoint
:
# Backup your database here, this will be restored to your local once the
# operation is done
wp search-replace --precise oldhost newhost
# Take another backup now - this backup will go to your remote server
# Now, restore your original backup to have your local in a working state...
# OR do this:
wp search-replace --precise newhost oldhost