How to Host a Core PHP Website on Cpanel

Modupe LadeleModupe Ladele
3 min read

Hosting a core PHP website on a server for the world to see, is actually an easier task than you'd think.

With desktop screenshots from a Lenovo ThinkPad, with a windows 10 operating system installed and clear explanations on what I did and why I did what I did, I will be teaching you how to host your PHP website on a shared hosting server.

Let's begin.

The first thing to do is to go to where the folder you want to upload is located, then you compress the folder to a zip file.

Selecting all the file to be compressed

Compressing the file to a .zip file

After compressing the file to a zip file you upload it to the cpanel hosting server

About to upload the file

Uploading of the file is now completed

To login into the cpanel is easy, go to the login in page and enter your login details

Logging into your cpanel shared Hosting server

After logging in, navigate to the file manager, and open the public_html, then you upload

Shared hosting dashboard

Clicking on File Manager

Locating public_html

Inside the public_html directory

After uploading the file, you return back to the file manager of the shared hosting platform you are using so you can unzip it.

You should make sure the file is compressed in .zip format if not, you could get an error similar to what is below.

Eroor caused by uploading a non-zipped compressed file

The error above is caused by uploading an unsupported type of compressed file (in this case, the file was a .rar file)

The next thing to do is to uncompress the zip file, which would give the result found in the image below.

Zip file successfully extracted into the public_html directory

Open your website link, to check for any errors

Database errors on my website domain

Debug any error you find. For example to debug this error, I will create a database name and a database user on my cpanel, upload my database to the database I created via PHPmyAdmin, then I will link my user to my database. I will then update the changes to my database.php settings file.

Images below illustrate in a better way how to smoothly do the process.create

create a database name

Create a user

Uploading my sql file

Successful uploading

Uploading successfully

database configuration file

After editing the database configuration file which usually looks like this

<?php

$servername = "your_servername";

$username = "your_username";

$password = "your_password";

$dbname = "your_database";

// Create connection

$conn = new mysqli($servername, $username, $password, $dbname);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

}

echo "Connected successfully";

// Close connection

$conn->close();

?>

Or Like this

<?php

$servername = "your_server_name";

$username = "your_username";

$password = "your_password";

$database = "your_database_name";

// Create connection

$conn = mysql_connect($servername, $username, $password);

// Check connection

if (!$conn) {

die("Connection failed: " . mysql_error());

}

// Select the database

mysql_select_db($database, $conn);

// Now you can perform database operations using this connection

// Close connection

mysql_close($conn);

?>

After that your website should be fully ready

Deranenergy.com

0
Subscribe to my newsletter

Read articles from Modupe Ladele directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Modupe Ladele
Modupe Ladele

Dev + Writer = Devwriter