FateKid
DEVIL DID IT
Admin
Status
offline
Posts
14,944
Likes
130,096
Resources
3,396
Credits
492
LEVEL
11
5,910 XP
These instructions explain how to create a test installation which is an exact duplicate of your live installation.
On Your Server
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 installation is located instead: Protecting admin.php and the install directory using .htaccess
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.
This comprehensive guide explains how to that: XF on localhost
Then the steps are very similar:
These are the actual steps I take when I update my local 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 - ensure you also copy any hidden .htaccess files - Edit the the
src/config.php
file (library/config.php
file if using XF1), in your new/test
directory and change the database details to match your new test database - Update Options -> Basic options: Board title to something like Test MySite
- Update Options -> Basic options: Board URL to match the new test URL
- If you have XFES installed, to ensure it uses a different index from your live site, update the
Index name
in Options -> Enhanced search or just click onReconfigure
and save without entering a name and it will update to use the database name - If you are using a cache on your live site, update the new /test directory
src/config.php
file with a different cache prefix - Add the code below to the bottom of your new
/test
directorysrc/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 installation is located instead: Protecting admin.php and the install directory using .htaccess
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.
This comprehensive guide explains how to that: XF on localhost
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 config.php file
-
PHP:
$config['enableMail'] = false; $config['cookie'] = array( 'prefix' => 'test_', 'path' => '/', 'domain' => '' );
-
These are the actual steps I take when I update my local installation:
- Take a dump of the live database using mysqldump and then zip it
- mysqldump -u<user> -p<password> --single-transaction --skip-lock-tables db_name > /path/to/backup/db_name_$(date +%d.%m.%y).sql
- tar -czf db_name_$(date +%d.%m.%y).tar.gz /path/to/backup/db_name_$(date +%d.%m.%y).sql
- Zip the entire installation directory
- tar -czf files_$(date +%d.%m.%y).tar.gz /path/to/install
- Download the zipped database dump and files
- Delete all existing files from my localhost installation directory
- Extract the downloaded zipped files to my localhost installation directory
- Update config.php with the localhost db details - db name, user, password
- Drop the tables from the localhost db
- Import the live db using
- mysql -uroot -proot db_name_dev <db.sql