views:

242

answers:

3

For example:

I have a Wordpress site (blog) on www.xxxxxx.com

I want to upgrade some plugins and WP version of site but before it I want to check all things on a mirror version.

How to make a mirror backup site of currently running site on same server like www.xxxxxx.com/testing-site/?

Whatever I will do on mirror site, should not effect to live site.

I will delete mirror after successfully checking all upgrade on it? And will upgrade WP version and plugin on live site.

I don't want to lose any content, comment on live site (blog).

My hosting is on PHP based server and my hosting control panel is cpanel.

+1  A: 

I don't think you can go and make a mirror site behave like your live site and NOT affect the live site when something in your mirror site blows. Especially if you're wanting to access WP functionality down to the plugin level, not to mention the WP version.

Safest way to go about this would probably be to copy the live site down to the last piece -- DB export + import, copy your WP installation into your testing-site subfolder, and manually config it to run like your live site.

Even so, you're can't be (too) sure that your mirror runs like your current because they're essentially two separate installs.

Richard Neil Ilagan
I downloaded all content of public_html folder then reuploaded to www.xxxxxx.com/testing-site/ now how to do this step "DB export + import, copy your WP installation into your testing-site subfolder, and manually config it to run like your live site."
metal-gear-solid
If you have phpMyAdmin or some other way to manage your database you'll be able to export everything to an SQL file and then import it again.
Blair McMillan
basically what Blair said. you'll want to (1) export your current WP DB to an SQL file, (2) create a second database for your mirror site, and import your SQL file into that somehow, (3) copy your WP site onto a subfolder, and (4) config it to use your new database. You'll want to look at your config.php settings.
Richard Neil Ilagan
@Richard Neil Ilagan - see my comment @desertwebdesigns answer.
metal-gear-solid
How can you not be sure they'd run the same? Yes, they are two different installs, but if you are copying the entire file system of the blog and the database verbatim, they **will be exact duplicates** of one another and they **will run exactly the same**, until you start editing one. Like I said in my response below, I do this all the time.
desertwebdesigns
while you're right, I was thinking more along the lines of the fact that not all of Wordpress' settings are set on the site's DB (simplest example would probably be the wp-config.php file. Another would be the .htaccess, and a few more).It might be an exact copy, but while that ensures an exact mimic of a system's behavior, there's still the very slight chance of discrepancy, provided that you overlook one of these settings.You did a good job of summing it up above in your independent solution though. Cheers.
Richard Neil Ilagan
A: 

Your only real option is to duplicate the install and have two of them. Once you do as Richard suggests, you'll not only have to change the config file but also search the DB for references to the live site's location. Depending on the theme, you may also need to change code in the them. Same goes for plugins.

Forrest
True about the plugins/themes. However, good authors will not hard code paths into their files. There are very easy wordpress functions to get the path of the plugin/theme installation. This is assuming way to much on the author's part and can break easily. I would strongly advise staying away from any such themes/plugins. They're ticking time-bombs.
desertwebdesigns
+1  A: 

There is a way to do this, I do it all the time. I develop new WordPress sites on my local development server on my home network, and then upload them to my testing site for my clients to review them. This involves changing the URL of the site. Here's a step-by-step:

  1. Do a mysqldump of your database (export the whole content) - eg. site.sql
  2. Copy EVERYTHING from your current wordpress root directory into a new sub-directory (site.com/testing-site)
  3. Update your .htaccess file. It will look something like this at a minimum, more if you have plugins installed that modify the .htaccess

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    

    This is for an installation in the web root. You need to update any paths that are set to point to the new site root. In the above example, you would edit two lines

    RewriteBase /testing-site/
    RewriteRule . /testing-site/index.php [L]
    
  4. Next, you will need to do a find and replace on your sql dump (this could be difficult depending on the size). Open it in a basic text editor (like notepad) and search for the path of your current installation, and replace it with the path of your new installation. Example: If your blog is installed to www.site.com and you're changing to www.site.com/testing-site, replace all occurrences (Ctrl+H) of the former (www.site.com) with the latter (www.site.com/testing-site) and save the sql file.

  5. Next, you need to setup another database (you could reinstall to new tables in the current database, but that's more difficult). I would recommend using the same username/password and just changed the database name. Once that is setup, update the database information in the wp-config.php file in the /testing-site directory. Update the lines:

    define('DB_NAME', 'new_db_name');
    define('DB_USER', 'new_db_username');
    define('DB_PASSWORD', 'new_db_password');
    define('DB_HOST', 'new_db_host');
    

    MAKE SURE you update this file. Otherwise, your new installation will be connecting to the old database.

  6. Finally, import your edited sql file into the new database. If all went well, you're new site will be up and function on site.com/testing-site and will be using the new database.

I'm not saying this will be easy, there are a lot of little things that can get you, but it can be done. Like I said, I do it all the time. I hope it works out for you.

desertwebdesigns
@desertwebdesigns - Can i use same database for both sites main and testing. because in testing site i will not add any new article or comment. i will just upgrade wordpress versions and plugins and i think it will not write anything in database.
metal-gear-solid
No. If you use the same database, any changes made on the testing site, will be reflected on the main site. Even without adding/editing content, many plugins store information in the database so by upgrading plugins, you will be changing database content. If an upgrade ends up breaking the blog on the test site, it would break it on the main site as well if they're both using the same database.
desertwebdesigns
perfect solution. :) I would just like to comment though that Wordpress allows you to use the same database for two or more different installs via a setting on the wp-config.php file.I **REALLY** wouldn't advise on using this, though, unless your server somehow restricts you to only one SQL database.
Richard Neil Ilagan
@desertwebdesigns - I tried as you described but see this question http://stackoverflow.com/questions/3416768/wordpress-test-site-goes-to-main-site-url-how-to-solve
metal-gear-solid