WhatsApp Support Reach us instantly via WhatsApp.

Knowledgebase

How to Upload and Run an HTML or PHP Website on cPanel Hosting

To run an HTML or PHP website on cPanel hosting, follow the steps below. If your website does not use a database, you only need to complete the first step. If it uses a MySQL database, continue with the following steps according to your website's requirements.

Step One: Upload the Website Files

  1. Log in to your cPanel account, then go to the Files section and click File Manager.

File Manager option in cPanel

  1. Navigate to the public_html directory, then click Upload.

Uploading website files to the public_html directory in cPanel

  1. Click Select File, then select the ZIP archive containing your website files and directories. Wait until the upload reaches 100%.

Uploading a compressed website archive to the hosting account

  1. Return to File Manager, then right-click the uploaded archive and select Extract.

Extracting website files using the Extract option in cPanel

  1. Make sure the correct extraction path is selected, then click Extract Files.
  2. Make sure your website files are located directly inside the directory assigned to the domain, including the main page file index.html or index.php, rather than inside an additional nested directory.
  3. After the extraction is complete, you can delete the compressed archive from your hosting account.

Website files inside the public_html directory after extraction

Note: The public_html directory is assigned to the primary domain of your hosting account. If you want to run your website on an additional domain or a subdomain, you can find its assigned directory (Document Root) under the Domains section in cPanel, then upload your website files to that directory.

If your website does not use a database, you can now open the domain in your web browser to verify that it is working correctly. You do not need to complete the following steps.

Step Two: Create a MySQL Database

If your website uses a MySQL database, follow the steps below to create the database and its associated user:

  1. Return to the main cPanel page, then go to the Databases section and click Database Wizard.

Database Wizard and phpMyAdmin options in cPanel

  1. Enter a suitable name for the database, such as testdb, then click Next Step.

Creating a MySQL database using Database Wizard in cPanel

  1. Enter a database username, such as testuser, and set a strong password. Re-enter the password to confirm it, or use Password Generator to generate one, then click Create User.

Creating a database user and setting a password in cPanel

  1. Select ALL PRIVILEGES to grant the user all privileges on the database, then click Next Step.

Granting all database privileges to the database user in cPanel

  1. When a confirmation message appears indicating that the user has been successfully added to the database, the creation process is complete.
Note: cPanel adds a prefix associated with your hosting account username to both the database name and the database username. For example:
  • Database Name: kbiqhosting_testdb
  • Database Username: kbiqhosting_testuser
Keep the full database name, username, and password, as you will need them when configuring the database connection.

Step Three: Set Up the Database

The database setup method depends on how your website is developed. Follow the appropriate method below:

Option One: Automatically Create Database Tables Using an Installation Wizard

If your website includes an installation wizard, open the domain or the website's installation URL, then enter the following database connection details when prompted:

  • Database Host: localhost
  • Database Port: 3306 if required.
  • Database Name: The full database name.
  • Database Username: The full database username.
  • Database Password: The database user's password.

Complete the installation according to your website's instructions. The installation wizard will automatically create the required database tables.

Note: If the installation wizard successfully creates the required tables and configures the database connection, you do not need to import the database manually or complete Step Four.

Option Two: Manually Import the Database Using phpMyAdmin

If you have a database file in .sql format, follow the steps below:

  1. Return to cPanel, then go to the Databases section and click phpMyAdmin.
  2. Select the database you created from the sidebar.
  3. Click the Import tab.
  4. Click Browse, then select the database file from your device.
  5. Click Import and wait until the import process is complete and a success message appears.

Importing an SQL database file using phpMyAdmin in cPanel

Once the import is complete, proceed to the next step to connect your website to the database.

Step Four: Connect the Website to the Database

If your website requires manual database connection configuration, follow the steps below:

  1. Open File Manager, then navigate to the directory containing your website files.
  2. Select the database configuration file, then right-click it and choose Edit. If a confirmation window appears, click Edit again.
  3. Update the database connection details as follows:
    • Database Host: localhost
    • Database Port: 3306 if required.
    • Database Name: The full database name.
    • Database Username: The full database username.
    • Database Password: The database user's password.
  4. Click Save Changes to save the changes.

Updating MySQL database connection details in the website configuration file

Note: The name of the database configuration file depends on how your website is developed. It may be named config.php, database.php, .env, or any other filename. If a hidden file, such as .env, is not visible, click Settings in File Manager and enable Show Hidden Files (dotfiles).

Once the configuration is complete, open the domain in your web browser to verify that the website is working correctly.

If the Website Does Not Work

  • Make sure the domain is correctly pointed to the hosting server.
  • Make sure the website files are located inside the directory assigned to the domain rather than inside an additional nested directory.
  • Verify that the database connection details are correct and that the full database name and username are used.
  • Make sure the database user has the required privileges and that all database tables have been imported successfully, if required by the website.
  • Review the Errors section in cPanel or the error_log file, if available, to identify the cause of any errors.
Was this answer helpful?