Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Matt Campbell
Matt Campbell
9,767 Points

Help with moving a WordPress from local to live

I've been looking into a quicker way of moving my local wordpress site onto the server.

If I copy the theme into a new install, I have to go through the install, re-enabling plugins and setting them up, redoing menus, adding in all the pages etc. It takes time and is annoying.

I read something about moving the database with it and while this is sort of working I'm having an issue or two with my sites links.

When clicking on a link, it is linking back to the localhost server and not to the corresponding page.

I thought the links followed similar format of stylesheets etc and used bloginfo('template_directory') which would surely mean they just work wherever the theme is.

How should I be doing this? Can you help Zac Gordon ?

Thanks.

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Don't forget to tag your posts as WordPress! I miss them otherwise so thanks for pinging me :p

6 Answers

Matt Campbell
Matt Campbell
9,767 Points

Victory Zac Gordon!

I don't know if it's because I'm using a sub-domain or I what but, everything is working lightening fast and here's my steps for moving a WordPress site from local to live.

1) FTP everything from local root to live root. Once uploaded, change wp-config to suit new database. This could be done before I suppose and then the steps just reversed after upload and re-saved.

2)Export local database contents and import to new database location.

3)Access WP-Options table and locate site_url at the top and change it to the url that the browser redirects to after whatever you type into the nav bar. For me, I can access my site through testspace5.site.com or www.site.com/testspace5. It is the second one that needs using. This makes the admin area accesible.

4)Run replace.php and do two search and replaces. First is http://localhost/devspace1/ (WITH forward slash at the end) to http://www.site.com/testspace5/ (WITH forward slash at the end). This doesn't sort linked pages though. A second search needs to be done omitting the forward slashes from the urls so, http://localhost/devspace1 (NO forward slash) and the same for the target url. This finds two additional entries to the huge number of entries the first search finds and everything then works!

5)Go back to the FTP transporter and DELETE the search and replace script. Site is insecure otherwise.

Thanks for your help Zac, it was a great help but I had to do a bit more work. Slept on it and within 20 minutes of looking at the problem again this morning, problem well a truly solved!

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

I like to hardcode the site url into the wp-config.php file by default like this: http://wp.zacgordon.com/how-to-change-the-wordpress-site-url-in-the-wp-config-php-file/

When it's hardcoded it will override what's in the DB so it saves a step in the transfer process :)

When moving a Wordpress from local to live, I re-do all the install, plugins, pages, etc.

You can import the database. Export it from your local Wordpress and import it into the live one.

Concerning your links what are they set to in the source code ?

Matt Campbell
Matt Campbell
9,767 Points

Thanks for that @Zac Gordon. I think I've worked it out, I was missing the step for changing the site url in the settings panel so it was redirecting all linked content back to the local site.

Going to give it a go now how I've worked out and add in this step. If that doesn't work, I'll follow yours step by step.

Matt Campbell
Matt Campbell
9,767 Points

Zac Gordon - It's not really working. Think I need to attack this with fresh eyes as it is late in the UK now.

Links work but I'm missing linked content, probably an easy fix, and when I try to login, it's redirecting me to the local backend admin area?

Navigating to wp-admin.php yields a 404 Not Found error.

Matt Campbell
Matt Campbell
9,767 Points

Further edit: Only problem left now is the redirect to the local backend when I've logged in.