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

Hmmm... can't access the original forum now... lol. Seems like this wouldn't be that complicated... we really need some detailed instructions. For you guys that do it all the time... the small things fly right by you.

Trying to access avnrivana.com... it redirects me to avnirvana.com/test/ and I get the following:

1635217502799.webp

I did add the following code at the bottom of the src/config.php file of the /test/ directory. I do not have a config.php file in the library/ directory...

Code:
$config['enableMail'] = false;

$config['cookie'] = array(
'prefix' => 'test_',
'path' => '/',
'domain' => ''
);
 
Do you you have an htaccess file in the test folder? If so try removing that. Double check config.php has the test database not live.

EDIT:Those art the things that have caught me out, along with getting this correct:

Code:
config['cookie']['prefix'] = 'test_';
$config['cookie']['path'] = '/';
$config['cookie']['domain'] = '';
 
Last edited:
Do you you have an htaccess file in the test folder? If so try removing that. Double check config.php has the test database not live.

EDIT:Those art the things that have caught me out, alomng with getting this correct:

Code:
config['cookie']['prefix'] = 'test_';
$config['cookie']['path'] = '/';
$config['cookie']['domain'] = '';
I do have an .htaccess file and I deleted the redirects in it... but perhaps I should remove it altogether and see if that helps. Not sure if there is anything in it that is needed for typical XF functions.
 
I do have an .htaccess file and I deleted the redirects in it... but perhaps I should remove it altogether and see if that helps. Not sure if there is anything in it that is needed for typical XF functions.

It could be the redirects in the .htaccess file of the public_html folder that are causing conflicts with the /test folder too.

Yes a folder will see the .htaccess file in the root (public_html). I think it appliies that first
 
Here is my .htaccess file in public_html.

I'm not sure I can comment out anything and it not affect the operation of the live forum during the testing phase.

Code:
#    Mod_security can interfere with uploading of content such as attachments. If you
#    cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
#    SecFilterEngine Off
#    SecFilterScanPOST Off
#</IfModule>

#Comodo domain validation
#RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt$


#Force www:
#RewriteEngine on
#RewriteCond %{HTTP_HOST} ^avnirvana.com [NC]
#RewriteRule ^(.*)$ https://www.avnirvana.com/$1 [L,R=301,NC]

RewriteRule ^/?threads/hsu-research-ccb-8-speaker-preview.201/ https://www.avnirvana.com/threads/hsu-research-ccb-8-bookshelf-speaker-review.917/ [R=301,L]

# Force https
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.avnirvana.com/$1 [R,L]
#RewriteCond %{HTTP_HOST} ^avnirvana\.com [NC]
#RewriteCond %{SERVER_PORT} 80
#RewriteRule ^(.*)$ https://www.avnirvana.com/$1 [R,L]

# Password protect admin.php
<FilesMatch "admin.php">
    AuthType Basic
    AuthName "Restricted Area"
    AuthUserFile blah/blah/blah
    require valid-user
</FilesMatch>

# Default error handling
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 406 default
ErrorDocument 500 default
ErrorDocument 501 default
ErrorDocument 503 default

<IfModule mod_rewrite.c>
    RewriteEngine On

    #    If you are having problems with the rewrite rules, remove the "#" from the
    #    line that begins "RewriteBase" below. You will also have to change the path
    #    of the rewrite to reflect the path to your XenForo installation.
    #RewriteBase /xenforo

    #    This line may be needed to workaround HTTP Basic auth issues when using PHP as a CGI.
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^(data/|js/|styles/|install/|favicon\.ico|crossdomain\.xml|robots\.txt) - [NC,L]

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^.*$ index.php [NC,L]
</IfModule>


<IfModule mod_expires.c>
     ExpiresActive On
     ExpiresByType image/jpg "access plus 1 year"
     ExpiresByType image/jpeg "access plus 1 year"
     ExpiresByType image/gif "access plus 1 year"
     ExpiresByType image/png "access plus 1 year"
     ExpiresByType text/css "access plus 1 month"
     ExpiresByType text/html "access plus 3 hours"
     ExpiresByType application/pdf "access plus 1 month"
     ExpiresByType text/x-javascript "access plus 1 month"
     ExpiresByType application/x-shockwave-flash "access plus 1 month"
     ExpiresByType image/x-icon "access plus 1 year"
     ExpiresDefault "access plus 1 month"
</IfModule>

<IfModule mod_deflate.c>
    <filesMatch "\.(js|css|html|php)$">
        SetOutputFilter DEFLATE
    </filesMatch>
</IfModule>

# BEGIN cPanel-generated php ini directives, do not edit
# Manual editing of this file may result in unexpected behavior.
# To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
# For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
<IfModule php7_module>
   php_flag display_errors On
   php_value max_execution_time 90
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 100M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
   php_value upload_max_filesize 100M
   php_flag zlib.output_compression Off
</IfModule>
<IfModule lsapi_module>
   php_flag display_errors On
   php_value max_execution_time 90
   php_value max_input_time 60
   php_value max_input_vars 1000
   php_value memory_limit 256M
   php_value post_max_size 100M
   php_value session.gc_maxlifetime 1440
   php_value session.save_path "/var/cpanel/php/sessions/ea-php73"
   php_value upload_max_filesize 100M
   php_flag zlib.output_compression Off
</IfModule>
# END cPanel-generated php ini directives, do not edit

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
  AddHandler application/x-httpd-php .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
 
I also have this caching setup in the original src/config.php file that could be causing issues and I'm not sure how to fix it.

Code:
$config['cache']['enabled'] = true;
//$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
//      'directory' => '/home/blahblahblah/www/cache'
    'host' => '127.0.0.1',
    'port' => 6379,
    'timeout' => 0.0,
    'persistent' => false,
    'persistent_id' => ''
];
 
I also have this caching setup in the original src/config.php file that could be causing issues and I'm not sure how to fix it.

Code:
$config['cache']['enabled'] = true;
//$config['cache']['sessions'] = true;
$config['cache']['provider'] = 'Redis';
$config['cache']['config'] = [
//      'directory' => '/home/blahblahblah/www/cache'
    'host' => '127.0.0.1',
    'port' => 6379,
    'timeout' => 0.0,
    'persistent' => false,
    'persistent_id' => ''
];
Have you tried removing it? NB do you have the cookie prefix path etc set as above?
 
I will comment it out and try it.

I have cookie set as follows in src/config.php

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

Is this what allows simultaneous sessions on multiple test sites under one domain?

example.com/test-forum-1/
example.com/test-forum-2/
 
I have 3 test site directories under one sub domain. Do I need to change anything in 'prefix' => 'test_', to mention the sub domain? And does test change to the actual name of each directory (mine are not named test)?

tests.example.com/1/
tests.example.com/2/
tests.example.com/3/

^That's how I have mine.
 
I had a test site with its own database. Call it test1.

I just exported the database of my live site and created a new database with it. Call it live2.

I went to config.php of test1 and put the credentials of the live2 database.

After doing that, going to test1.com says "The site is currently being upgraded. Please check back later."

test1.com/admin.php says the same thing.

test1.com/install/ says
An exception occurred: [ErrorException] [E_WARNING] Array to string conversion in src/XF/App.php on line 2327

  1. XF::handlePhpError() in src/XF/App.php at line 2327
  2. XF\App->setupAddOnComposerAutoload() in src/XF/Install/App.php at line 160
  3. XF\Install\App->setup() in src/XF.php at line 461
  4. XF::setupApp() in src/XF.php at line 484
  5. XF::runApp() in install/index.php at line 14

Can a clone be made the way I did it? Do I need to upload the XF upgrade files maybe?
 
Top Bottom