Skip to content
Deploying apps4 min read

Upload a PHP site and its database to cPanel

Short answer

Compress your site into a ZIP, upload it to public_html with File Manager and extract it. Create a database and a user with all privileges, import your `.sql` export in phpMyAdmin, then put the new database name, user and password in your config file with the host `localhost`. Finally, choose the PHP version your code needs.

ArabyHost teamLast updated: ShareWhatsAppXLinkedIn
Contents
  1. Prerequisites
  2. Step by step
  3. Troubleshooting
  4. On ArabyHost

A typical PHP site is two things: files and a database. You move the files with a ZIP and File Manager, recreate the database, import its contents, and connect the two through the site’s config file. The steps below work for hand-written PHP and for CMSs such as WordPress, OpenCart or a Laravel app with a few extra steps.

Prerequisites

  • All your site files, including hidden ones such as .htaccess.
  • A database export (.sql or .sql.gz).
  • The PHP version and extensions the site needs (check composer.json or the CMS requirements).
  • A domain pointing to your hosting. See connecting a domain to hosting.

Step by step

1. Export the database from the old server

With phpMyAdmin: select the database, open Export, choose Quick and the SQL format, and download. From a terminal:

mysqldump -u root -p --single-transaction --default-character-set=utf8mb4 mydb > mydb.sql
gzip mydb.sql

Compressing first makes the upload much smaller.

2. Compress the files

Create a ZIP of the contents of your site folder, so that index.php sits at the top of the archive and not inside an extra folder.

3. Upload and extract

In cPanel open Files › File Manager and go to public_html (or the addon domain’s folder). Click Upload, choose the ZIP, then go back, right-click the file and choose Extract. Delete the ZIP afterwards. If public_html already has a default index.html, remove it so it doesn’t take priority over index.php. More in the File Manager guide.

4. Create the database and user

Open Databases › MySQL Database Wizard:

  1. Type a database name, for example shop. cPanel saves it as USER_shop.
  2. Create a user and a long, random password.
  3. Tick ALL PRIVILEGES and finish.

Write down the three values. A detailed walkthrough is in creating a MySQL database.

5. Import the .sql file

Open Databases › phpMyAdmin, click your database in the left column, open Import, choose the .sql or .sql.gz file and click Import. If the file is larger than the upload limit shown on that page, see phpMyAdmin import too large. On AI/Developer plans you can import over SSH instead:

gunzip -c mydb.sql.gz | mysql -u USER_shopuser -p USER_shop

6. Update the config file

Every CMS has a file with the database details: wp-config.php for WordPress, .env for Laravel, config.php for many others. For plain PHP with PDO:

<?php
$pdo = new PDO(
    'mysql:host=localhost;dbname=USER_shop;charset=utf8mb4',
    'USER_shopuser',
    'your-strong-password',
    [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);

If the site stores its own address in the database (WordPress siteurl and home, or a base_url setting), update it to the new domain.

7. Choose the PHP version and extensions

Open Software › Select PHP Version (or MultiPHP Manager, depending on the server) and choose 8.1, 8.2 or 8.3. Enable the extensions your code needs, typically pdo_mysql, mysqli, mbstring, intl, gd and zip. Raise limits such as upload_max_filesize or memory_limit from the Options tab or MultiPHP INI Editor. See choosing a PHP version.

8. Check permissions

Folders should be 755 and files 644. PHP runs as your own user, so writable folders such as uploads/ or cache/ don’t need 777.

9. Test

Open the site, log in, submit a form and upload an image. Once the domain points to the server, AutoSSL issues the certificate; then make sure the site loads over https://.

Troubleshooting

  • Access denied for user (1045): the user name or password is wrong, the prefix is missing, or the user wasn’t added to the database in the wizard. See MySQL error 1045.
  • “Error establishing a database connection” (WordPress): check the four DB_ values in wp-config.php, and that DB_HOST is localhost.
  • HTTP 500 or a blank page: read the error_log file in the site folder. Common causes are a PHP version newer than the code supports, a missing extension, or a line in .htaccess the server doesn’t accept.
  • Arabic text appears as ??? or ال: the export and the connection use different charsets. Export as utf8mb4 and set charset=utf8mb4 in the connection.
  • Links and images still point to the old domain or localhost: replace the old URL in the database. For WordPress use a search-and-replace tool that handles serialized data.

On ArabyHost

Every ArabyHost plan runs PHP 8.1-8.3 with MySQL/MariaDB on LiteSpeed, and cPanel, with File Manager and phpMyAdmin, opens with one click from the Araby Panel. AutoSSL issues a free certificate once the domain points to ns1.arabicode.com and ns2.arabicode.com, and JetBackup takes daily backups. Shared plans have no SSH, so large imports go through phpMyAdmin as compressed files; the AI/Developer plans add SSH, Git and Composer. If a step fails, the Araby AI assistant can read the error log and explain the fix, and if you’re moving from another host, free help is available through migration.

FAQ

What database host do I use on cPanel?

Use `localhost`. The database runs on the same server as your site, so you don't need an IP address or a port.

Why do my database and user names start with my username?

cPanel adds your account username and an underscore as a prefix, so `shop` becomes `USER_shop`. Always use the full prefixed names in your config file.

Can I upload with FTP instead of a ZIP?

Yes, FTP or SFTP works. A single ZIP extracted on the server is usually much faster than thousands of small files, and it avoids half-finished uploads.

Useful? Share it with someone who needs it:WhatsAppXLinkedIn

Read next

Ready to put your idea online?

Fast, isolated hosting, support that understands you, and an AI assistant that fixes problems with you.