1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to duplicate a live site to use as a test site

Testing, testing

Tags:
  1. Brogan

    Brogan XenForo Moderator Staff Member

    These instructions explain how to create a test installation which is an exact duplicate of your live installation.

    On Your Server
    • Create a new test database with a different database name, user name and password to your live installation
    • Export your current live database and import it into your new test database
    • Create a new directory on your server, e.g. /test
    • Copy all of the files from your current live site directory to the new /test directory
    • Edit the /library/config.php file in your new /test directory and change the database details to match your new test database
    • Update Options -> Basic Board Information -> Board Title to something like Test MySite
    • Update Options -> Basic Board Information -> Board URL to match the new test URL
    • If you are using a cache on your live site, update the new /test directory /library/config.php file with a different cache prefix
    • Add the code below to the bottom of your new /test directory /library/config.php file
    PHP:
    $config['enableMail'] = false;

    $config['cookie'] = array(
    'prefix' => 'test_',
    'path' => '/',
    'domain' => ''
    );
    Don't forget that the test installation should be password protected to stop others from accessing it.

    You can do that with .htaccess - copy the instructions here but apply it to the directory where the test install is located instead: http://xenforo.com/community/resour...and-the-install-directory-using-htaccess.353/


    On Your Computer (Localhost)

    If you wish to duplicate your live installation on your PC, first you need to install a program such as XAMPP: http://xenforo.com/community/resources/how-to-install-xenforo-locally-to-your-pc-using-xampp.355/

    Then the steps are very similar:
    • Create a test database with the same database name, user name and password as your live installation*
    • Export your current live database and import it into your new test database
    • Create a new directory on your computer to match your live site directory, if it is not installed in the root
    • Copy all of the files from your current live site directory to the same directory
    • Replace the .htaccess file with the following contents
      • Code:
        RewriteEngine On
        
        RewriteCond %{REQUEST_FILENAME} -f [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^(data|js|styles|install) - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    • Add the code below to the bottom of the new test installation /library/config.php file
      • PHP:
        $config['enableMail'] = false;

        $config['cookie'] = array(
        'prefix' => 'test_',
        'path' => '/',
        'domain' => ''
        );

    *If you use root/root for the user name and password for XAMPP, then ensure you update the /library/config.php file accordingly.
     
  2. RoldanLT

    RoldanLT Well-Known Member

    It would be better if the database are automatically sync :)
     
  3. Brogan

    Brogan XenForo Moderator Staff Member

    That would defeat the purpose of a test site.

    The last thing you want is changes on your test site to affect your live site.
     
    Taminoful likes this.
  4. RoldanLT

    RoldanLT Well-Known Member

    This is what I mean.

    Live > test site
    Not Live !< test site.
     
    Valhalla likes this.
  5. Brogan

    Brogan XenForo Moderator Staff Member

    And if your test site is running a different version has different add-ons installed, has different styles and template edits?
     
    RoldanLT likes this.
  6. Martok

    Martok Well-Known Member

    This also wouldn't work with new posts and threads. If I make a new post on the test site and then someone makes a new post on the live site, there would be a conflict with the post numbers as they would be the same on both sites.
     
    RoldanLT likes this.
  7. bart

    bart Active Member

    My question would be: how do you go back? If you make changes to the test-site, what would be the best way to update the live site to match the test-site.
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    If you wanted to apply any changes you have made to your test site to your live site, then you would need to document them and reapply them.

    The purpose of having a test site is to test add-ons, upgrades, styles, tweaks and changes, etc. without affecting your live site.

    That then enables you to put a proper plan together for repeating it on your live site.
     
    Methodical likes this.
  9. bart

    bart Active Member

    Yes, thanks for the guide.

    Unfortunately, documenting is not my strongest point. :)
     
  10. The Sandman

    The Sandman Well-Known Member

    I didn't see mention of PHP opcode cachers. If you're running one of those (such as XCache) don't forget to give the test forum a unique cache prefix in the config file. Otherwise things can get sideways in a hurry.
     
    MattW likes this.
  11. Brogan

    Brogan XenForo Moderator Staff Member

    Good point @The Sandman, that has caught more than a few people out.

    I'll update the resource.
     
    The Sandman likes this.
  12. The Sandman

    The Sandman Well-Known Member

    I know - it happened to me. :eek:
     
  13. 0ptima

    0ptima Well-Known Member

    What does this do?

    Code:
    $config['cookie'] = array(
    'prefix' => 'test_',
    'path' => '/',
    'domain' => ''
    );
     
  14. Brogan

    Brogan XenForo Moderator Staff Member

    It sets a cookie prefix specifically for that installation.
    It's very useful if you have multiple installations and don't want to keep getting logged out when you switch between them.
     
    0ptima likes this.
  15. LurkerLou

    LurkerLou Active Member

    Getting an error. How do I correct it?
    An exception occurred: Access denied for user '**************'@'******************' (using password: YES) in /Applications/MAMP/htdocs/library/Zend/Db/Adapter/Mysqli.php on line 333
     
  16. 0ptima

    0ptima Well-Known Member

  17. LurkerLou

    LurkerLou Active Member

    Created user multiple times and even copied and pasted username and password from config. Still no dice.

    This is the rest of the error but I'm assuming this is all related to the username issue?

    1. Zend_Db_Adapter_Mysqli->_connect() in Zend/Db/Adapter/Abstract.php at line 315
    2. Zend_Db_Adapter_Abstract->getConnection() in XenForo/Application.php at line 684
    3. XenForo_Application->loadDb()
    4. call_user_func_array() in XenForo/Application.php at line 921
    5. XenForo_Application->lazyLoad() in XenForo/Application.php at line 952
    6. XenForo_Application::get() in XenForo/Application.php at line 1336
    7. XenForo_Application::getDb() in XenForo/Error.php at line 52
    8. XenForo_Error::unexpectedException() in XenForo/Application.php at line 363
    9. XenForo_Application::handleException()
     
  18. LurkerLou

    LurkerLou Active Member

    Deleted the database and now getting a new error when trying to import db.

    CREATE TABLE `dark_postrating` (
    `id` int( 10 ) unsigned NOT NULL AUTO_INCREMENT ,
    `post_id` int( 10 ) unsigned NOT NULL ,
    `user_id` int( 10 ) unsigned NOT NULL ,
    `rated_user_id` int( 10 ) unsigned DEFAULT NULL ,
    `rating` int( 10 ) unsigned NOT NULL ,
    `date` int( 10 ) unsigned NOT NULL ,
    PRIMARY KEY ( `id` ) ,
    UNIQUE KEY `post_id_user_id` ( `post_id` , `user_id` ) ,
    KEY `post_id_rating` ( `post_id` , `rating` ) ,
    KEY `user_id_rating` ( `user_id` , `rating` ) ,
    KEY `rated_user_id_rating` ( `rated_user_id` , `rating` ) ,
    KEY `date` ( `date` )
    ) ENGINE = InnoDB DEFAULT CHARSET = utf8 AUTO_INCREMENT =3348;

    MySQL said:

    #1050 - Table '`******`.`dark_postrating`' already exists
     
    Last edited: Jan 27, 2014
  19. LurkerLou

    LurkerLou Active Member

    Just noticed the @ part isn't local host. It's @'***********.dyn.optonline.net'. Shouldn't that be local host?
     
  20. LurkerLou

    LurkerLou Active Member

    Looking at the config.php for local testing shouldn't the following be changed since it's local?

    $config['db']['host'] = 'mysql.****.com';
    $config['db']['port'] = '3306';
     

Share This Page