Wordpress Migration from hosting to Fresh LAMP stack

I've been tasked with migrating a Wordpress site from a hosting company to Amazon Web Services. I'm pretty familiar with AWS, but Wordpress not so much (medium, lets say). This site is going to use the same domain name, but on a different server.

Today I build a LAMP stack from scratch and have successfully tested Apache, MySQL and PHP.

I have a compressed copy of the website along with the MySQL Database.

Can I just copy the contents of that zipped folder and MySQL to the new LAMP stack? (e.g use wget to dump the root contents, like the "wp-contents" folder into the /var/www/html root, etc. )

If anyone has a good recipe for this, I'd love to read it.

Thanks for your help.
TessandoIT AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gregory MillerGeneral ManagerCommented:
I would do an install of WordPress on the new LAMP Stack and then copy everything in from the old site. Your idea is correct and you will simply replace the newly created folders with the older folders. Import the SQL data. You undoubtedly will have some variances which you cannot fix before you copy but I would guess they should be minimal.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Yes. Just copy all your files to their new home + load your database into MariaDB or MySQL, which ever is running.

The only minor gotcha. If you create the zip file yourself, be sure to use the --symlinks option, else some caching + monitoring plugins may break.

https://wordpress.org/plugins/duplicator/ is also a great option, especially if you migrate + change domain names, like moving a dev/staging site to a production site.
TessandoIT AdministratorAuthor Commented:
Thanks Guys - I was able to get this working based on both suggestions: To bottom-line it, I did an "air lift" the best I could. I ended up importing the SQL User and MySQL Database with the same password and username based off the wp-config file.

Now, that said, there is a goofy 301 redirect plug-in so, unless there is another way to test, I'd have to swap the DNS, wait for the propagation and test using the domain name.

I'm going to leave this open today, as I'll start working on this in the next couple hours. Thanks again for your help.
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
In your original question you stated...

This site is going to use the same domain name, but on a different server.

If you've changed the domain, then the process of just moving the database will fail.

If old domain + new domain name differ, than you must use a backup/restore process like Duplicator or BackupBuddy or similar provide.

Part of the restoration process for this type of plugin is rewriting all the database serialized data which contains embedded site URLs.

If your domain name changed + you miss the complete database rewrite step... trouble will ensue...

You can also do this manually on the command line (my preferred method), using wp-cli via something like this...

wp search-replace "https://oldfoo.com" "https://newfood.com" --precise --recurse-objects --all-tables --dry-run

Open in new window


Using dry-run will tell you how many links will be changed.

Remove --dry-run to actually have command commit changes.

If you go this route, be sure you change all the www + bare domain + http, so you end up with https://newfoo.com as your only site wide link.

Or whatever your site wide link might be.
TessandoIT AdministratorAuthor Commented:
Thank you, David. I am not going to change the domain name.
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
If the domain name remained the same, then a simple migration (with now database rewrites) should be sufficient.

Just change the IP + you should be good.
TessandoIT AdministratorAuthor Commented:
Thank you, David. Yes, I hit a road-block with the .htaccess file, but I was able to turn that breakdown into a break-thru: Once I modified Apache's httpd.conf file (/etc/httpd/conf/httpd.conf) I was able to get in. Changing the "AllowOverride" feature lets me now login to the Dashboard and see various pages.

However, changing hosts has opened up some permission challenges (not suprisingly).

The first one is to update Wordpress. When I click on the link from the dashboard I get the following:

Downloading update from https://downloads.wordpress.org/release/wordpress-4.9-no-content.zip…

Unpacking the update…

Could not create directory.

Installation Failed

Open in new window


This leads me to my other question: What permissions do I need to set/assign in order to get Wordpress and Plugins to update?

Thanks again for your help.
TessandoIT AdministratorAuthor Commented:
Per the best practices that Wordpress recommends, Folders are set to 755 and Files set to 644. I am logged into the server now and have verified that this is the case.

I am wondering if this has to go with Folder and File permissions in order to write to a given folder. I setup this LAMP stack per Amazon's instructions and (in doing so) have the User ec2-user and the Group Apache.

I purposely changed these from "root root" to "ec2-user" "apache".

Because this was an "airlift" do I need to reset those permissions in order for them to become effective? I attempted using the following and still can't get Wordpress or Plugins to update.

sudo find /var/www/html/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/ -type f -exec chmod 644 {} \;

Open in new window


perms.png
Man, I'm pretty stumped here. Is there another place to check for permissions? My User in Wordpress has "Administrator" permissions.
TessandoIT AdministratorAuthor Commented:
As it turned out, I had not fixed file permissions for the Apache web server.

Changed file ownership of /var/www and it’s contents to the apache user
sudo chown -R apache /var/www

Open in new window


Changed group ownership of /var/www and it’s contents to the apache group
sudo chgrp -R apache /var/www

Open in new window


Changed the directory permissions of /var/www and it’s subdirectories to add group write permissions and to set the group ID on future subdirectories
sudo chmod 2775 /var/www
find /var/www -type d -exec sudo chmod 2775 {} \;

Open in new window


Recurively change the file permissions of /var/www and it’s subdirectories to add group write permissions
find /var/www -type f -exec sudo chmod 0664 {} \;

Open in new window


Restarted Apache to pick up new groups and permissions
sudo service httpd restart

Open in new window


Detailed directions are found in the AWS Documentation.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TessandoIT AdministratorAuthor Commented:
Airlifting WP can be difficult for those of not super familiar with Wordpress.  All the solutions and contributions in this post were very helpful. Ultimately, making sure permissions are set properly and that the way Apache reWrite is being used are two common issues.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux

From novice to tech pro — start learning today.