Why a TCExam move breaks more than the URL

TCExam is a PHP-based computer-based assessment platform, and it stores far more state than a simple brochure site. When you copy the files to a new domain or hosting account, three separate layers have to agree on where the application now lives: the PHP configuration files under config/, the values recorded inside the MySQL database, and the physical paths on disk that TCExam uses to write cached PDFs, uploaded media, and log files. If any one of these layers still points at the old location, you get symptoms that look unrelated to a migration — blank login pages, broken images inside questions, failed PDF result exports, or a session that logs you out the instant you authenticate.

The most common root cause is that TCExam hardcodes both a public URL and a filesystem path during installation. The public URL (something like https://exam.olddomain.com/) is written into config/tce_config.php and referenced again in the admin/public path constants. The filesystem path (for example /home/olduser/public_html/tcexam/) is written into the same file and is used to locate the cache/, public_html/tmp/, and asset directories. On shared hosting your home directory changes when your username changes, so a restore into a new cPanel or DirectAdmin account almost always invalidates that absolute path. Sessions add a second trap: TCExam sets its session cookie against a specific domain, so a leftover cookie domain from the old host silently rejects the new one.

Because you are working as an unprivileged hosting user, none of this is fixed at the server level. You will not touch php.ini globally, restart services, or run shell-level database dumps. Everything below is done through cPanel Jupiter or DirectAdmin Evolution, phpMyAdmin, the File Manager, and the two text files TCExam actually reads. Approached in the right order, a domain change or full account move takes under an hour and leaves your candidate records, question banks, and result history intact.

Copying the files and database into the new account

Start with a full, consistent copy of both halves of the application. In the old account, open cPanel → File Manager, navigate to the TCExam document root (commonly /home/olduser/public_html/tcexam or a subdomain root under /home/olduser/exam.olddomain.com), select the folder, and use Compress to build a single .zip archive. Download it, or if both accounts are yours, use the archive as a transfer unit. In DirectAdmin the equivalent is System Info & Files → File Manager, which also offers folder compression.

For the database, export from phpMyAdmin rather than trying any command-line dump. Select the TCExam schema in the left panel, open the Export tab, choose the Custom method, and under output tick Save output to a file with a gzip compression option if the database is large. Keep the SQL format and leave the default structure-and-data setting so triggers and table definitions come across. TCExam tables are prefixed (the default prefix is tce_), so confirm the export includes tables such as tce_users, tce_questions, tce_test_user, and tce_logs.

On the destination account, recreate the environment before importing anything. In cPanel open MySQL® Databases, create a new database, create a new user with a strong password, and add that user to the database with ALL PRIVILEGES. DirectAdmin does the same through Account Manager → MySQL Management. Write down the exact new values, because these are what TCExam needs:

Database name : newuser_tcexam
Database user : newuser_tceusr
Database host : localhost
Table prefix  : tce_

Now upload your file archive into the new document root through File Manager and use Extract, then delete the archive. Import the SQL through phpMyAdmin: select the freshly created empty database, open the Import tab, choose your .sql or .sql.gz file, and run it. Watch for a maximum-upload-size error; if the dump exceeds the phpMyAdmin limit, raise upload_max_filesize and post_max_size for your own account by adding a .user.ini in the account root, or split the export by table groups in the old panel. Do not attempt to import through global configuration changes.

Rewriting config.php, the URL, and stored paths

With files and data in place, point TCExam at its new home. Open config/tce_config.php in the File Manager code editor. This file defines the domain, the protocol, the path root, and the database credentials. Update the connection block first so it matches the account you created:

define('K_DATABASE_TYPE', 'MYSQL');
define('K_DATABASE_HOST', 'localhost');
define('K_DATABASE_NAME', 'newuser_tcexam');
define('K_DATABASE_USER_NAME', 'newuser_tceusr');
define('K_DATABASE_USER_PASSWORD', 'YourStrongPassword');
define('K_TABLE_PREFIX', 'tce_');

Next update the path and URL constants. TCExam derives many URLs from K_PATH_HOST and K_PATH_URL, and it derives filesystem roots from K_PATH_MAIN and K_PATH_CACHE. Replace the old absolute filesystem path with the new one shown in File Manager's address bar, and replace the old hostname with the new domain, keeping the trailing slashes intact:

define('K_PATH_MAIN', '/home/newuser/public_html/tcexam/');
define('K_PATH_HOST', 'https://exam.newdomain.com/');
define('K_PATH_URL', K_PATH_HOST.'tcexam/');
define('K_PATH_CACHE', K_PATH_MAIN.'cache/');
define('K_PATH_TCPDF', K_PATH_MAIN.'shared/tcpdf/');

If TCExam lives at the root of its own subdomain rather than in a /tcexam/ subfolder, set K_PATH_URL equal to K_PATH_HOST. Getting this wrong is the usual reason images and CSS 404 after a move. Confirm the protocol is https only if the new domain already has an active AutoSSL or Let's Encrypt certificate issued in the panel; mixing http in the config while forcing HTTPS at the server produces mixed-content warnings similar to those covered in our ATutor SSL and HTTPS guide.

A handful of absolute references may also live inside the database. Open phpMyAdmin, select the new database, and run a targeted search under the SQL tab before assuming everything is clean:

SELECT * FROM tce_config WHERE config_value LIKE '%olddomain.com%';

If rows appear, update only the affected values with a scoped statement rather than a blind global replace:

UPDATE tce_config
SET config_value = REPLACE(config_value, 'olddomain.com', 'newdomain.com')
WHERE config_value LIKE '%olddomain.com%';

Media stored per question can reference the old media URL as well. Check the media table and update any stored external links the same way, scoping the WHERE clause so you never touch unrelated binary or numeric columns.

Fixing permissions, sessions, and verifying the exam flow

TCExam must be able to write to its cache and temporary directories, and permissions frequently reset during a compress/extract cycle. In File Manager, select the cache/ folder and the public_html/tmp/ folder (paths vary by version), open Permissions, and set folders to 0755 and any writable data files to 0644. On CloudLinux with LiteSpeed you should not need 0777; if PDF export still fails, confirm the path in K_PATH_CACHE actually exists and matches the real directory name exactly, including case.

Session behavior is the next thing to validate. If logging in redirects you straight back to the login screen, the browser is holding a cookie scoped to the old domain, or the session save path is invalid on the new account. Clear cookies for the new domain and retry. If it persists, add a small .user.ini in the TCExam document root so PHP writes sessions inside your own account rather than an inherited path:

session.save_path = "/home/newuser/tmp"
session.cookie_secure = 1
upload_max_filesize = 64M
post_max_size = 64M

Create that tmp directory in your home folder through File Manager first. Because .user.ini is read per request under LiteSpeed's PHP handler, allow a couple of minutes or the configured TTL before it takes effect. Pair this with a minimal .htaccess in the same directory if you want to canonicalize the domain and force HTTPS after the certificate is confirmed live:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://exam.newdomain.com/$1 [R=301,L]

Finish with an end-to-end test that touches every layer you changed. Log into the TCExam admin area at /tcexam/admin/, open a stored question that contains an image to confirm media URLs resolve, then run a short test as a candidate account to exercise session handling and answer storage. Generate a PDF result to confirm the cache path and TCPDF path are correct. If any step fails, do not guess — open the account-level error_log that appears in the affected directory via File Manager. TCExam surfaces missing constants, database authentication failures, and unwritable paths as explicit PHP warnings there, which pinpoints exactly which of the three layers still references the old location. Once all three agree, the migration is complete and your question banks, candidate records, and historical results carry over unchanged.