AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Synchin local mamp wordpress to live12/28/2023 ![]() A much easier way to move the database is to use Migrate DB Pro. dev in order for the site to work locally. This is because you'd need to do a second step of doing a search and replace in the database to change all your. Moving the database can be a bit tricky if you go the route of doing an export and import using phpMyAdmin. But before you move on, go ahead and delete the newly created wp-config.php file, and rename the one you edited in the previous step back to wp-config.php Migrate the Database You'll be replacing the database with your live database in the next step. It doesn't matter what you name the site, or what username/password you use during this step. You should be presented with the very familiar WordPress setup screen. In a browser, navigate to your newly created local site. We'll get put it back in place later, we just need it out of our way for a few minutes. Once that's saved, rename the file to something like wp-config.php-hold. I did this by creating a simple if/else statement to point to the proper database depending on the environment. Since it is set up to connect to the database on the live server, you're going to need to modify it in order to make it work on your local system. ![]() The Git repo created by SiteGround contains a copy of wp-config.php. In a browser window, navigate to to access the databases on your local machine. When it's done, the terminal window will look something like this:Īt this point, you now have a complete copy of all your site files in a brand new folder. Git clone ssh:// :18765/home/xxxxxx/public_html/ mysiteĭepending on the size of the site, this step can take some time to complete. Paste the command you have in the clipboard onto the command line in Terminal and then add the name of the folder you created during the MAMP setup step. Change directories to get into the htdocs folder in MAMP. You will want to copy the Git Clone command to the clipboard. We'll use that in the next step. When it's done you'll see a screen that looks something like this: ![]() It will take a minute for the repo to be created. In Cpanel, click the SG-Git link and you'll see a list similar to this:Ĭlick the Create Git Repository button next to the appropriate domain name. Next, you will need to create a Git repo on SiteGround. You need to delete those files before the next step. As it does, it will create two files in your new folder. When you save the settings for your new local dev site, MAMP will restart. Read this tutorial if you need help with that step. Side note, if your live site is using SSL, I STRONGLY suggest that you set up a self-signed cert on the SSL tab. ![]() When it comes time to set the document root, create a new folder inside your htdocs folder and select the new folder you just created. In MAMP, start by adding a new hosting entry. If you using the free version of MAMP, your screens may look a little different. Once that's saved, return to the Cpanel main page as we'll be using it again in a few minutes. Next, in Cpanel, click the SSH/Shell Access link and add your SSH key here: This will copy your public SSH key to your clipboard. To do this, start by opening the Terminal app on your Mac. In order to connect to the server, you're going to need to add your SSH key to your SiteGround account. Now that you know how NOT to do it, let's move on to the proper way. (remember how all the tutorials tell you to backup your files and database first? This is exactly why!) I had a backup and after a short freak out, I had my site back online. When I force-pushed MY Git repo from localhost to SiteGround, it deleted all the WordPress files along with the uploads directory. My previously existing local repo doesn't include the WordPress core files or any of the uploads to the media directory. This means all of your uploaded media at the time you create the repo. The Git repo that SiteGround creates for you is going to contain all of the WordPress core files and everything from the wp-content folder on your server. Let me start by telling you how I took one of my sites offline for over an hour. To follow is the step-by-step process I used to reach Git + MAMP + SiteGround glory. Use Git to keep all 3 of the above in sync.Here are the pieces of the puzzle I'm trying to put together: But, as I'm a big fan of doing, I wanted to blog about my specific process so that I could refer back to it when I need to do it again. There is a great tutorial on the process by my friends at 9seeds, that I used as a starting point. I had tried in the past but always ended up hitting a stumbling block somewhere along the way. For too long now I have put off the chore of getting my local development environment set up in a way that would allow me to use Git to push my code directly to SiteGround.
0 Comments
Read More
Leave a Reply. |