|How to set up local copy of my wp site|
First off, I apologize if this is the wrong place for this post. If so, let me know and I'll move it.
I'd like to set up on my Mac a copy of my existing WordPress site so I can work on it without crashing the live one. ;-)
I don't have background in this stuff but have found instructions and gotten some support at my wp theme site. However I just can't make it work. Here's what I've done:
1. I backed up my complete site files to my desktop.
2. I installed MAMP.
3. I created a database with the same name as my live site's database.
4. I imported the existing table data into this new MAMP database.
5. I opened the wp-config.php file and made sure that database name, username and password were all correct (db=my just created db name which is same as for my live site; un=root, pw=root and host is set to localhost).
6. I place all my backed up files (WordPress files and my theme files in wp-content) into a folder that I call mysitelocal. Then I put this folder into the htdocs folder within the MAMP folder.
7. I open my browser and type [localhost:8888...] and am taken to the homepage of my site.
8. However, when I add the /wp-admin or wp-login.php, I am redirected to the live site WP login page.
9. ALSO, when at the homepage on my localhost, if I click to go to an interior page, I'm also redirected to my actual site.
I have been trying all sorts of fixes with the help of my Theme support site. I have read the wp codex for moving a wp site, changing the url (which, even though I followed it to a T, disabled the local server) and more.
I just reinstalled MAMP to start over, and still can't get to the point where my entire site is available locally PLUS I'm able to login to WP locally and edit.
Can anyone help out? I'm a novice at all of this so please provide specific steps if you can.
Thanks so much.
OK, you had it installed and working correctly. Here's where you went wrong.
You type in localhost:8888 and you get your local site.
You type in (or in this case, click) www.example.com/wp-admin - and where is www.example.com? that's right, it's on your webserver, the live copy.
You should have visited localhost:8888/wp-admin. That (or some url like that) would have taken you to the local copy.
But that alone won't fix your problem. Here's what you really need to do (and the only thing you need to do, that will fix your problem). You need to tell your computer that www.example.com is on your local pc not your webserver. Then ALL your links will go to your local pc.
This is done in a hosts file. You should google 'mac hosts file' on how to change it on a mac. Basically you'll add a line something like this:
So, in summary, rebuild what you'd done. Change your hosts file. Restart your browser, and you can then go to www.example.com/wp-admin on your local pc.
Whenever you want to see the live site again, comment out the line in your hosts file and restart your browser.
But I actually did type localhost:8888/wp-admin and got redirected to the live site. (I was told I needed to change the url within my database options. I did that using wp codex instructions but that shut down the local server.)
I will search on what you suggest and try to get it done. Thanks so much, wheel!
|I was told I needed to change the url within my database options. I did that using wp codex instructions but that shut down the local server.) |
Yes, in the WP database is your domain name, but just changing that is more problematic than what I've suggested.
It's handy to know the hosts file anyway, Then you can do development locally, easily. And you can do stuff like point ad networks to your local PC as well. Then when you visit a site,it tries to grab the ads from your machine and you of course end up with no more ads :).
Sounds good! I'll give it a whirl.
(btw, one support guy suggested that using MAMP Pro instead of MAMP would be the easy way to handle this problem. Know anything about that?)
MAMP has nothing to do with the problem you were having. It's a DNS issue. Your computer was looking for example.com. The general order of finding out where a site is located is:
your local hosts file
Since your local hosts file is normally mostly blank, it looks, sees nothing, then queries the web to find a site. You're simply inserting an address for example.com, overriding the normal query that everyone else does.
MAMP and MAMP pro then either serve the page or they don't. But you've already established that they were serving the pages just fine.
Play with the hosts file a bit. It's handy for stuff like you're doing. You can speed up queries, i.e I have my mail server IP address in mine, so when I check email I don't have to ask on the web every time as to where my email server is - it grabs it from my hosts file.
If you have a static IP on your PC, and your router redirects http requests to your desktop, then you can screw with your client's hosts file and point their website to your IP. Then they can watch the development of the new site on your PC as well. (this is similiar to what is done when developing on a new/second webserver. Change your hosts file to the new IP and you automatically go to the new webserver. Everyone else still sees the old one. At end of development, change the DNS and that moves everyone else over to the new server).
Awesome. Thanks, wheel.