This guide explains how to "host PHP application cPanel" sites: upload the files to the website's document root, create a database, import your SQL file, then update the app's connection settings. Your hosting account provides the web server, PHP runtime, and database tools, so you don't need to set up a separate web server.

The trick is getting each piece in the right place. A project that's still buried in an extracted folder, or a user that hasn't been connected to its data store, can stop an otherwise good deployment.

Prepare the PHP environment before deployment

Before uploading files, check what your application needs. An application may require a specific PHP version, extension, or loader, and package availability on a cPanel server can vary by host. The hosting server must support those requirements.

Know what cPanel's PHP packages include

cPanel & WHM includes PHP 8.4 and its PHP modules as packages, along with PEAR and PECL modules and PHP loaders. Common modules include bcmath, curl, gd, intl, mysqli, pdo_mysql, pdo_pgsql, and zip. The PHP binary also links to PostgreSQL and SQLite libraries. You can review the package details in cPanel's PHP documentation.

cPanel & WHM includes the ionCube and SourceGuardian loaders. These let PHP run encoded applications while keeping the application's source code from being read. If your app requires one, the server must have the correct loader available. cPanel lists both under its PHP loader options.

Keep the PHP configuration files straight

The cPanel & WHM php.ini file and EasyApache 4 php.ini files are separate. Edits to a php.ini file at the cPanel & WHM level are overwritten, so make server-level changes in WHM » Home » Server Configuration » Tweak Settings. The EasyApache 4 PHP overview covers its PHP setup.

Most website owners work inside their cPanel account, not WHM. If you don't have WHM access, don't try to change a server-wide setting by editing a file you found on the server. cPanel interfaces and available controls vary by host, so ask your hosting provider which PHP settings you can change.

A server rack with blue network cables stands in a bright, clean server room.

Upload the PHP project in File Manager

Your website's PHP source files belong in its document root. For the main domain on many cPanel accounts, that folder is public_html. If your account assigns a different document root to the domain, upload the files there instead.

Upload and extract the project folder

Sign in to cPanel and open Files » File Manager. To upload project files together, compress the PHP project into a ZIP archive, then select it and choose Extract. This keeps the files grouped and makes them easier to place correctly.

After extraction, open the new project folder. Many archives create a nested folder, so the actual application files may be one level below the directory you expected. Move the project's contents into the document root, then remove the empty folders.

Check the application's required file and directory permissions after extraction. Follow your host's guidance, and avoid broad permissions such as 777.

Check the folder that opens your site

The document root should contain the application's entry point, often a file named index.php, along with the PHP code and folders the app needs. If index.php is still inside a nested project folder, your domain may show the wrong page or return a 404.

Don't place the main website files in cgi-bin. That directory is separate from the normal web document root. Files placed in public_html or cgi-bin can still return 404 Not Found errors if the domain points to a different document root, so confirm the domain's actual document root and where the extracted files ended up.

Create and import the application database

If your application stores accounts, orders, posts, or settings, it needs a place to store that information and a user with permission to access it. Set up both in cPanel before importing the application data.

Create the database and user in cPanel

Open the Databases section and select Manage My Databases. Create database access by adding a database, then create a user and password. cPanel adds your account name as a prefix, so the full name and username may include more than the names you entered.

Assign the user to the new database before the application connects. Grant the privileges it requires, then save the complete name, username, and password securely. For a more detailed walkthrough, see how to create a MySQL database in cPanel.

Use cPanel's tools to create and manage this resource. After it exists, use phpMyAdmin to import and manage data. This keeps account and database management in sync.

A stack of paper, a storage drive with a coiled cable, and a closed laptop on a wooden desk.

Import the SQL file through phpMyAdmin

Once setup is complete, open phpMyAdmin from cPanel. Select the database you created, choose Import, and select the SQL file that came with your project. Start the import and wait for the tool to confirm it finished.

A large or damaged SQL file may not import cleanly, so keep an original copy before working with it. We also recommend making a backup before major changes. For more on safe database work, see our guide to phpMyAdmin security in cPanel.

Update the app's connection settings and test it

The app needs the new connection credentials, not the ones from local development. If it supports environment variables, update them using the controls available from your host. These controls vary by host. Otherwise, find the app's connection file, often named db.php, and change the values there.

Set the database name, user, and password

In db.php, enter the full database name and username shown in cPanel, including any account prefix. Replace the old password with the one you set for the user. On cPanel, the server is typically localhost.

Keep the connection details consistent. A correct password paired with a name that's missing its cPanel prefix still won't connect. Save the file and upload the updated version if you edited it on your computer.

Test the parts that use the database

Load the site through its domain and try the application's login and registration features. These checks confirm the app can read from and write to the imported data.

If the home page loads but a form or login fails, check the full database name, username, password, and user assignment. Avoid changing several settings at once. One careful correction makes it easier to see what fixed the connection.

Fix common 404 and temporary URL problems

A newly uploaded site can be hard to test if its domain hasn't been pointed to the server yet. A shared IP can also behave differently from a dedicated domain, so use the right address for the situation.

Why a PHP site may return 404 Not Found

Start by confirming that the files are in the document root assigned to the domain. Then check that the application's entry file isn't still inside the nested folder created during extraction. A folder named public_html alone doesn't guarantee the files are in the correct location if the domain uses another document root.

Also check the exact file name and path you're opening. For example, a file inside a subfolder needs that subfolder in its URL. If the files are in cgi-bin, move the normal website files to the domain's document root instead.

Access a site before the domain points to it

On a server with a shared IP address, opening the IP directly may send you to http://IP/cgi-sys/defaultwebpage.cgi, the server's default page. The preview address is http://IP/~cpanel_user, with your server IP and cPanel username in place of the examples. cPanel explains the temporary URL format for mod_userdir.

This address won't work if mod_userdir is enabled without excluding the default host, or if the server uses mod_ruid2. In those cases, the hosting provider needs to address the server configuration. Use this address for an early preview and your normal domain for the live site.

When ready, point your domain name's DNS records to the host. Configure SSL using the options your provider offers, then test the site over HTTPS. Domain, SSL, and cPanel features vary by host.

Key takeaways for a clean cPanel deployment

  • Put the application files in the domain's document root, commonly public_html for the main domain.
  • Extract the project, move its contents out of the nested folder, and remove the empty folders.
  • Create the database and user through cPanel, then import the SQL file in phpMyAdmin.
  • Update db.php with the full prefixed database name, username, password, and localhost.
  • Test login and registration to confirm the app can read and write records.

Frequently asked questions

Can I host a PHP project on cPanel without setting up a separate web server?

Yes. cPanel hosting provides a web server and PHP environment managed through the hosting account. Upload your files to the correct document root, set up the data store if the app needs one, and update its connection settings.

Where should I put PHP files so they open in a browser?

Place them in the document root assigned to your domain. For many main domains, that folder is public_html. A PHP file in a nested folder needs to be opened through that folder's path.

Why doesn't the temporary URL work?

It depends on the server's mod_userdir setup. It may fail if the default host isn't excluded or if the server uses mod_ruid2. Contact your hosting provider if the domain isn't ready and the temporary address still won't load.

Get your PHP application online

A working deployment comes down to three things: files in the right document root, a data store the app can access, and PHP settings that match the application. Follow the steps in order, then test the features that rely on stored data.

If you're choosing a cPanel account for your project, explore ZADiC cPanel hosting or view our cPanel hosting products. With the right setup, you can spend less time chasing folder paths and more time building your site.

We use cookies so you can have a great experience on our website. View more
Cookies settings
Accept
Decline
Privacy & Cookie policy
Privacy & Cookies policy
Cookie name Active

Who we are

Our website address is: https://zadic.net.

Comments

When visitors leave comments on the site we collect the data shown in the comments form, and also the visitor’s IP address and browser user agent string to help spam detection. An anonymized string created from your email address (also called a hash) may be provided to the Gravatar service to see if you are using it. The Gravatar service privacy policy is available here: https://automattic.com/privacy/. After approval of your comment, your profile picture is visible to the public in the context of your comment.

Media

If you upload images to the website, you should avoid uploading images with embedded location data (EXIF GPS) included. Visitors to the website can download and extract any location data from images on the website.

Cookies

If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year. If you visit our login page, we will set a temporary cookie to determine if your browser accepts cookies. This cookie contains no personal data and is discarded when you close your browser. When you log in, we will also set up several cookies to save your login information and your screen display choices. Login cookies last for two days, and screen options cookies last for a year. If you select "Remember Me", your login will persist for two weeks. If you log out of your account, the login cookies will be removed. If you edit or publish an article, an additional cookie will be saved in your browser. This cookie includes no personal data and simply indicates the post ID of the article you just edited. It expires after 1 day.

Embedded content from other websites

Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website. These websites may collect data about you, use cookies, embed additional third-party tracking, and monitor your interaction with that embedded content, including tracking your interaction with the embedded content if you have an account and are logged in to that website.

Who we share your data with

If you request a password reset, your IP address will be included in the reset email.

How long we retain your data

If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue. For users that register on our website (if any), we also store the personal information they provide in their user profile. All users can see, edit, or delete their personal information at any time (except they cannot change their username). Website administrators can also see and edit that information.

What rights you have over your data

If you have an account on this site, or have left comments, you can request to receive an exported file of the personal data we hold about you, including any data you have provided to us. You can also request that we erase any personal data we hold about you. This does not include any data we are obliged to keep for administrative, legal, or security purposes.

Where your data is sent

Visitor comments may be checked through an automated spam detection service.
Save settings
Cookies settings