How to Migrate Magento from cPanel to DirectAdmin
Migrating a Magento store from cPanel to DirectAdmin requires more than simply copying website files. A Magento installation depends on its database, media files, configuration, Composer dependencies, cron jobs, PHP settings, cache services, and web-server configuration.
Moving to DirectAdmin can be useful when you want a different hosting environment, better resource management, or a more flexible control panel. With proper preparation, you can migrate Magento while keeping downtime to a minimum.
This guide explains how to migrate a Magento website from cPanel to DirectAdmin step by step.
What You Need Before Starting
Before beginning the migration, make sure you have:
- Access to the old cPanel server
- Access to the new DirectAdmin server
- SSH access to the servers, if available
- Magento Admin access
- Database credentials
- Your Magento domain name
- A complete Magento backup
- Compatible PHP version
- Compatible MySQL/MariaDB version
- Composer installed on the new server
- Required PHP extensions
- SSL support on the DirectAdmin server
It is strongly recommended to perform the migration on a staging or temporary domain first.
Understand What Needs to Be Migrated
A Magento installation generally consists of several important components:
Magento Files
├── app/
├── bin/
├── generated/
├── pub/
├── var/
├── vendor/
├── composer.json
└── composer.lock
Database
├── Products
├── Customers
├── Orders
├── Configuration
├── CMS content
└── Store settings
Server Configuration
├── PHP settings
├── Cron jobs
├── Database credentials
├── Redis/OpenSearch configuration
└── Web server settings
You need to migrate all components that your store depends on.
Step 1: Check the Current Magento Environment
Log in to the cPanel server through SSH and move to your Magento directory.
For example:
cd /home/username/public_html
Check the Magento version:
php bin/magento --version
Check the PHP version:
php -v
Check Composer:
composer --version
You should also check the Magento deployment mode:
php bin/magento deploy:mode:show
Record important information such as:
- Magento version
- PHP version
- Composer version
- Installed modules
- Database type and version
- Redis configuration
- OpenSearch/Elasticsearch configuration
- Cron configuration
- Custom extensions
- Custom themes
This information helps you reproduce the environment on DirectAdmin.
Step 2: Check DirectAdmin Server Compatibility
Before transferring anything, verify that the DirectAdmin server supports your Magento version.
Check:
- PHP version
- PHP extensions
- MySQL/MariaDB version
- Composer
- OpenSearch/Elasticsearch
- Redis
- PHP memory limit
- Maximum execution time
- Upload limits
- Required web-server configuration
Common PHP extensions required by Magento include:
bcmath
ctype
curl
dom
fileinfo
gd
intl
mbstring
openssl
pdo_mysql
simplexml
soap
sodium
xml
xsl
zip
The exact requirements depend on your Magento version.
Do not assume that the PHP version on cPanel should automatically be used on DirectAdmin. Always verify compatibility with the Magento version and extensions installed on your store.
Step 3: Create a Complete Backup on cPanel
Before making changes, create a full backup.
Your backup should include:
- Magento files
- Database
app/etc/env.phpapp/etc/config.php- Media files
- Custom themes
- Custom modules
- Composer files
- Any custom server configuration
You can create a database dump from SSH.
First identify your database credentials from:
cat app/etc/env.php
Look for:
'db' => [
'connection' => [
'default' => [
'host' => 'localhost',
'dbname' => 'database_name',
'username' => 'database_user',
'password' => 'database_password'
]
]
]
Create a database backup:
mysqldump -u database_user -p database_name > magento_backup.sql
Compress the file:
gzip magento_backup.sql
You can also create an archive of the Magento files:
tar -czf magento_files.tar.gz public_html/
Store your backups somewhere safe before continuing.
Step 4: Put Magento Into Maintenance Mode
When you’re ready for the final migration, enable maintenance mode:
php bin/magento maintenance:enable
Verify it:
php bin/magento maintenance:status
Maintenance mode prevents customers from making new changes while you perform the final database and file migration.
For a large store, you can perform most of the migration before enabling maintenance mode and use maintenance mode only during the final synchronization.
Step 5: Prepare the DirectAdmin Account
Create the destination domain or account in DirectAdmin.
For example:
newdomain.com
If you are keeping the same domain, you can create the domain on the new server without changing DNS yet.
The DirectAdmin account should have sufficient resources for Magento.
Configure:
- PHP version
- PHP-FPM
- MySQL/MariaDB
- SSL
- Cron
- Redis, if required
- OpenSearch/Elasticsearch, if required
Step 6: Create a Database on DirectAdmin
Log in to DirectAdmin.
Go to:
Account Manager → MySQL Management
Create:
- Database
- Database user
- Strong database password
Record the following:
Database Host: localhost
Database Name: new_database
Database User: new_database_user
Database Password: strong_password
DirectAdmin may prefix database and user names with the account username.
For example:
username_magento
username_magento_user
Use the actual database name shown in DirectAdmin.
Step 7: Upload Magento Files
The next step is to transfer your Magento files from cPanel to DirectAdmin.
If SSH is available, rsync is usually faster and more reliable than downloading and uploading a large ZIP file.
Example:
rsync -avz /home/olduser/public_html/ user@newserver:/home/newuser/domains/example.com/public_html/
You can also use:
scp magento_files.tar.gz user@newserver:/home/newuser/domains/example.com/
Then extract the archive:
tar -xzf magento_files.tar.gz
The exact DirectAdmin document-root path depends on the server configuration.
Common DirectAdmin paths look similar to:
/home/username/domains/example.com/public_html
Always confirm the actual document root in DirectAdmin before transferring files.
Step 8: Import the Magento Database
Upload your database backup to the DirectAdmin server.
If the backup is compressed:
gunzip magento_backup.sql.gz
Import it into the new database:
mysql -u new_database_user -p new_database < magento_backup.sql
Enter the new database user’s password when prompted.
For large databases, command-line import is generally more reliable than phpMyAdmin.
After importing, verify that tables exist:
mysql -u new_database_user -p
Then:
USE new_database;
SHOW TABLES;
You should see Magento tables such as:
catalog_product_entity
customer_entity
sales_order
quote
cms_page
The exact table set depends on your Magento installation and version.
Step 9: Update Magento Database Credentials
Open:
app/etc/env.php
Update the database configuration:
'db' => [
'connection' => [
'default' => [
'host' => 'localhost',
'dbname' => 'new_database',
'username' => 'new_database_user',
'password' => 'new_database_password'
]
]
],
If the database server uses a different hostname, replace localhost with the appropriate database host.
Do not expose env.php publicly or publish its database credentials.
Step 10: Check Redis Configuration
If your Magento store uses Redis, check:
grep -n "redis" app/etc/env.php
You may find configuration similar to:
'cache' => [
'frontend' => [
'default' => [
'backend' => 'Cm_Cache_Backend_Redis'
]
]
]
If Redis is configured on the old server, make sure Redis is installed and running on DirectAdmin.
Test the service:
redis-cli ping
A working Redis server normally responds:
PONG
If Redis is not available on the new server, do not simply copy the old Redis configuration and expect Magento to work. Configure an appropriate cache backend for the new environment.
Step 11: Check OpenSearch or Elasticsearch
Magento versions may require a search engine such as OpenSearch or Elasticsearch depending on the version and environment.
Check your configuration:
grep -n -E "elasticsearch|opensearch" app/etc/env.php
Make sure the required search service exists on the DirectAdmin server.
After migration, test the connection and reindex Magento:
php bin/magento indexer:reindex
If the search service is unavailable, Magento catalog and search functionality may fail even if the website itself loads.
Step 12: Install Composer Dependencies
If your Magento installation is Composer-managed, move into the Magento directory:
cd /home/newuser/domains/example.com/public_html
Then install dependencies:
composer install
For production environments, you can use:
composer install --no-dev
Do not run a random composer update during a migration unless you intentionally want to change package versions.
The composer.lock file should normally be used to reproduce the existing dependency versions.
Step 13: Set Correct Magento File Permissions
Incorrect permissions are one of the most common causes of Magento errors after migration.
A typical ownership command may look like:
chown -R newuser:newuser /home/newuser/domains/example.com/public_html
Then set directory permissions:
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chmod u+x bin/magento
The exact ownership and permission model depends on how PHP-FPM and the web server are configured on DirectAdmin.
Avoid using:
chmod -R 777
This creates unnecessary security risks and is not a proper solution for Magento permission problems.
Step 14: Configure the DirectAdmin Document Root
Make sure the domain points to the Magento pub directory.
Magento should generally serve the application from:
/home/newuser/domains/example.com/public_html/pub
rather than exposing the entire Magento installation directly.
The exact DirectAdmin configuration depends on the server’s web-server setup.
If the document root is incorrect, you may experience:
- 404 errors
- PHP source code exposure
- Missing CSS/JS
- Broken images
- Magento routing problems
- Security issues
Step 15: Configure Magento Base URLs
If the domain remains unchanged, you may not need to change the Magento URLs.
If the domain is changing as part of the migration, update the URLs accordingly.
For example:
php bin/magento setup:store-config:set --base-url="https://example.com/"
php bin/magento setup:store-config:set --base-url-secure="https://example.com/"
You can also inspect the current values:
php bin/magento config:show web/unsecure/base_url
php bin/magento config:show web/secure/base_url
If the old domain is still stored in the database, update it carefully.
Never perform a blind search-and-replace across the entire Magento database because Magento contains serialized and structured data that can be damaged by improper replacements.
Step 16: Configure SSL
Install an SSL certificate for the domain through DirectAdmin.
For a production store, HTTPS should be working before the final DNS switch.
Test:
https://example.com
Make sure:
- Homepage loads
- Admin loads
- Images load
- CSS loads
- JavaScript loads
- Checkout uses HTTPS
- No mixed-content warnings appear
Step 17: Run Magento Upgrade and Cache Commands
Once files, database, PHP, and configuration are ready, run:
php bin/magento setup:upgrade
Then clean generated files if required:
rm -rf generated/code/*
rm -rf generated/metadata/*
Compile Magento:
php bin/magento setup:di:compile
Deploy static files:
php bin/magento setup:static-content:deploy -f
Flush cache:
php bin/magento cache:flush
Reindex:
php bin/magento indexer:reindex
Check indexer status:
php bin/magento indexer:status
Step 18: Configure Magento Cron Jobs
Magento requires cron jobs for many background tasks.
Check the current cron configuration:
php bin/magento cron:run
In DirectAdmin, create the appropriate cron jobs.
A common Magento cron entry is:
* * * * * /usr/bin/php /home/newuser/domains/example.com/public_html/bin/magento cron:run
Depending on the Magento version and server configuration, Magento’s generated cron configuration may include multiple Magento cron groups.
Make sure the cron runs using the correct PHP binary.
You can find the PHP path with:
which php
If DirectAdmin uses multiple PHP versions, you may need to specify the correct PHP binary explicitly.
Step 19: Test Magento Before DNS Changes
Do not immediately change DNS.
First test the new server.
You can temporarily point a local hosts-file entry to the new server IP.
For example:
203.0.113.20 example.com
Then test the website from your computer.
Check the following:
Storefront
- Homepage
- Categories
- Product pages
- Product search
- Images
- CSS
- JavaScript
- Customer registration
- Customer login
- Cart
- Checkout
Magento Admin
- Admin login
- Dashboard
- Products
- Categories
- Customers
- Orders
- Configuration
- Extensions
Transactions
Test:
- Add to cart
- Checkout
- Payment gateway
- Shipping calculation
- Tax calculation
- Order confirmation
- Customer email
If possible, perform a test order before changing DNS.
Step 20: Perform the Final Database Synchronization
For stores with frequent orders, customers, or product changes, the database may have changed between the initial backup and the final DNS switch.
A safer migration process is:
- Perform the initial migration.
- Test the new server.
- Keep the old server running.
- Enable maintenance mode on the old server.
- Create a fresh database dump.
- Import the final database into DirectAdmin.
- Transfer any files changed since the first migration.
- Run Magento upgrade/cache/index commands if required.
- Perform final testing.
- Change DNS.
This reduces the possibility of losing new orders or customer data.
Step 21: Update DNS
Once the new DirectAdmin server has passed testing, update the domain’s DNS records.
Change the main:
A record
to the new DirectAdmin server IP.
If you use:
www
mail
ftp
or other subdomains, check their DNS records as well.
DNS propagation can take time depending on TTL and resolver caching.
Do not immediately delete the old cPanel account.
Keep the old server available until you have confirmed that the new Magento installation is working correctly.
Step 22: Disable Maintenance Mode
Once the domain is successfully serving the new Magento installation, disable maintenance mode:
php bin/magento maintenance:disable
Verify:
php bin/magento maintenance:status
The store should now be available to customers.
Step 23: Monitor the Store After Migration
For the next several hours, monitor:
- Magento logs
- Web-server logs
- PHP errors
- Checkout
- Orders
- Customer login
- Payment gateways
- Email delivery
- Cron jobs
- Server CPU
- RAM
- Disk usage
- Database performance
- Search functionality
Magento logs are commonly located in:
var/log/
Useful files may include:
system.log
exception.log
Depending on your Magento version and logging configuration, additional log files may also be present.
Common Problems After cPanel-to-DirectAdmin Migration
1. 500 Internal Server Error
Possible causes include:
- Incorrect PHP version
- Missing PHP extension
- Incorrect permissions
- PHP-FPM configuration
- Broken
.htaccess - Composer dependency problems
- Magento compilation errors
Check:
php bin/magento deploy:mode:show
and inspect the Magento and web-server logs.
2. CSS and JavaScript Are Missing
Clear generated files and redeploy static content:
rm -rf pub/static/_cache
rm -rf var/view_preprocessed/*
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush
Also verify that the Magento document root points to the correct pub directory.
3. Database Connection Error
Check:
app/etc/env.php
Verify:
- Database name
- Username
- Password
- Host
- Database server status
Test the credentials directly:
mysql -u new_database_user -p new_database
4. Magento Shows a Maintenance Page
Check:
php bin/magento maintenance:status
If migration is complete:
php bin/magento maintenance:disable
5. Search Is Not Working
Check whether OpenSearch or Elasticsearch is running and configured correctly.
Then run:
php bin/magento indexer:reindex
Also inspect Magento logs for search-engine connection errors.
6. Images Are Broken
Verify that:
pub/media/
was transferred completely.
Check permissions:
ls -ld pub/media
Also verify that the new server has enough disk space.
7. Cron Jobs Are Not Running
Check DirectAdmin’s cron configuration and make sure the correct PHP binary is being used.
Run:
php bin/magento cron:run
Then inspect Magento logs and cron-related processes.
8. Admin Login Redirects to the Old Server
This is usually caused by stale base URLs, DNS, browser cache, or Magento configuration.
Check:
php bin/magento config:show web/secure/base_url
Also clear Magento cache:
php bin/magento cache:flush
cPanel to DirectAdmin Magento Migration Checklist
Before declaring the migration complete, verify:
- Magento backup created
- Database backup created
- Magento version recorded
- PHP version checked
- DirectAdmin server compatibility confirmed
- Database created
- Magento files transferred
- Database imported
env.phpupdated- Composer dependencies installed
- File ownership corrected
- File permissions checked
- Redis configured if required
- OpenSearch/Elasticsearch configured if required
- Magento document root points to
pub - SSL installed
- Base URLs verified
- Magento compilation completed
- Static content deployed
- Indexers completed
- Cron jobs configured
- Storefront tested
- Admin tested
- Checkout tested
- Payment gateway tested
- Emails tested
- DNS updated
- Maintenance mode disabled
- Logs monitored
- Old cPanel server retained temporarily
Best Practices for a Smooth Migration
Keep the Same Magento Version
Avoid combining a server migration with a Magento upgrade unless there is a specific reason to do both simultaneously. Separating the two makes troubleshooting much easier.
Test Before Changing DNS
The new server should be fully tested before customers are directed to it.
Use SSH for Large Stores
SSH, rsync, and command-line database tools are generally much more efficient for large Magento installations than browser-based file managers.
Keep the Old Server Online
Do not immediately terminate the cPanel account. Keep it available until you have verified that all data and functionality are working correctly.
Lower DNS TTL Before Migration
If possible, reduce the DNS TTL before the migration. This can help make the eventual DNS change propagate more quickly.
Take a Final Backup
Always create a final database and file backup immediately before the final cutover.
Do Not Modify Magento’s Database Carelessly
Magento uses structured and serialized data in several areas. Improper SQL search-and-replace operations can corrupt configuration or application data.
Monitor After Cutover
A successful homepage load does not necessarily mean the migration is complete. Test checkout, orders, customer accounts, search, cron jobs, email, and payment processing.
Final Thoughts
Migrating Magento from cPanel to DirectAdmin is primarily an environment migration, not just a file transfer. The Magento application, database, PHP environment, Composer dependencies, cache services, search engine, cron jobs, SSL configuration, and web-server settings all need to work together.
The safest approach is to perform an initial migration, thoroughly test the DirectAdmin server, place the old store into maintenance mode during the final synchronization, update DNS, and closely monitor the new server.
With proper backups, compatibility checks, and testing, you can move a Magento store from cPanel to DirectAdmin with very little downtime and without losing important store data.