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 trialSteven Stufflebean
2,885 PointsWill this work on a live server, with a domain and sub domain?
I have a site on a domain and I copied the database and site over to a subdomain.
Like this... example.com to dev.example.com. My problem is trying to setup the config.php file. I entered in all the information for the DB name and DB user and DB password and also defined the site but when I try and login to the back end at dev.example.com/wp-admin it keeps redirecting me...so that I am unsure if I'm logging into the dev site or the production site.
Another problem is in PHPMyAdmin wp_options... the dev site is still pointing to the example.com domain.
Has anyone dealt with this before?
3 Answers
Raymon Oleaga
19,298 PointsHello, This are the steps I take whenever I create a test version of a WP site. Assuming you have all the files copied on your computer and the sql database
Create sub domain.
-
Create new database in the Cpanel using PhpMyAdmin or the Wizard.
- make sure you give the database user all privileges.
Go into PhpMyAdmin click on the database you just created and upload the database file from the website you want to copy.
-
Once the database is loaded click on wp_options table and edit this:
- siteurl: this should be your new url -home: this should be your new url also (I usually dont use www so it looks something like this: http://testsite.mywpsite.com)
Go into your WP files and open wp_config.php -replace the user name with the new user name of the new database you created -replace the database name with the new database name you created -replace the PASSWORD with the new database password you created -keep HOST the same I assume it says localhost -after this line: define('DB_COLLATE', ''); type this: define('WP_HOME', 'http://yournewsiteurlhere'); define('WP_SITEURL', 'http://yournewsiteurlhere');
6.Upload all your WP files with this changes you made to the wp_config.php This might take a while depending how big your site is
(no need to upload the sql database if you have it save within the files)
and that's it...
Hopefully this will help you!
Steven Stufflebean
2,885 PointsThanks Raymon! This is more like what I was thinking I should do, I just couldn't figure out the order to do all the steps in. Another problem is I'm using Plesk and every tutorial out there seems to be for CPanel. But I think I'm finally understanding how copying sites works.
Thanks again to you and everyone else on the forum for your help!
Jenny Stoffel
20,709 PointsYou might try this approach (assumes your old site is still active on the main domain)
- Delete what you have on the subdomain
- Do a fresh 1-click WP install on the subdomain (automatically takes care of database for you) it will provide you with new login credentials you will use temporarily.
- Install the plugin WP Clone on BOTH the installation of WP on the main domain and on the WP installation on the subdomain.
- Use WP Clone to clone your old site and copy the address it provides of the cloned site
- on the WP install on the subdomain, open WP Clone and restore, paste in the address you copied and hit restore
- You should be able to login to the new site using your old credentials. You don't need to touch any databases.
- Delete WP clone from your old site. It's up to you if you want to keep it on your new one for backup purposes.
- When you've confirmed it's successful, you can delete your old site.
- If you wind up with too many databases and want to delete some to save space, you can find out which database NOT to delete by looking at config.php for your new site.
- If you have cPanel or similar, set up a redirect which redirects the old web address to the new one.
WP Clone can be finicky, so you may need to try it a few times. Also, sometimes it successfully creates the backup but says it hasn't in the front end. You should go into the file manager to look for the .zip backup if that happens. If your zip file is HUGE, you might need to FTP it into the new location and use that restore address instead. Also if your storage space is too full it may not work correctly until you clear out some space.
Steven Stufflebean
2,885 PointsThank you Baruch and Jenny for your suggestions!
I'm setting up the dev site to test plugins and updates to see what works and what doesn't. That way I won't mess up anything on the production site. That's why I made a copy of the production site and copied it over the sub domain which I'm using as my dev site. I was finally able to login to the wp-admin and make changes on the dev site and they didn't affect my live site so I know the dev site is working and seperate.
Sorry this is confusing. I'm still pretty new to wordpress.
Baruch Velez
275 PointsBaruch Velez
275 PointsDid you install WordPress in the subdomain? Uploading the files is not enough. you need to run the installation I.E. dev.example.com/wp-admin/install.php. Also, if you've done, where is it redirecting you when you try to login the admin panel? As far as the Database problem, I don't quite understand the issue.