Using cPanel to manage my website

Using cPanel to create a new website, the example of WordPress installation

Unlike with Plesk panels cPanel creates your webspace directly from a panel which is above your cPanel. This above panel is named “WHM” panel. It manages all the webspaces hosted on the server, which each one attached to a domain name. So, if you are using a shared hosting, the cheapest ones, you may not have an access to this “WHM” panel but your provider yes.

So in a case of a shared hosting, your hosting provider creates the webspace for you and attaches it to your domain name. When you enter your cPanel, your webspace, the space in which you host the files of your website or your web application, is ready and configured.

Installing WordPress

First, to install WordPress, you have to download the CMS from https://wordpress.org/

Uploading the files

Two options here:

  • you want to use your main domain
  • you want to use a subdomain

Using your main domain:

Just click on the file manager of your panel:

screen-shot-2016-12-12-at-16-53-31

As you can see you are directed to the root of your domain webspace, the “public_html” folder:

screen-shot-2016-12-12-at-17-22-20

 

Then, from the top menu, click on “Upload”, and upload the zip file of WordPress.

Select the file, right-click on it and choose “extract”.

You may see a “wordpress” folder created with all the files in it.

Enter this “wordpress” folder with a double click.

Select all the files and folders which are listed.

Click on “Move” from the top menu and choose the destination folder (public_html if you are using your main domain, or public_html/folder if you are using a subdomain – change “folder” to the name of your subdomain folder).

So all the files and folders are going to be moved one level up at the root of your webspace folder.

Using a subdomain:

In case you want to use a subdomain, the webspace of your subdomain will be located within the webspace of your main domain. You just have to go in the “Domain” section and click on “Subdomain”. Then choose the subdomain you want to use, like test.yourdomain.com:

screen-shot-2016-12-12-at-17-06-13

 

As you can see cPanel is creating the webspace itself. In this example, all the files of your website/web application for your subdomain test.yourdomain.com will be located in the folder public_html/test. cPanel creates the “test” folder automatically for you.

Then you can check the installation on a main domain, that’s barely the same except you will have to enter the public_html/test folder (or the name of your own folder) rather than keep using the “public_html” folder as the root of your main domain.

Creating the database

Click on “MySQL Databases”:

screen-shot-2016-12-12-at-17-35-33

Unlike on Plesk panels, all your databases have a suffix and you cannot remove it. That has absolutely no consequences on your usage.

Then in the “Create database” section, enter the name you want for your database and click on “Create Database”:

screen-shot-2016-12-12-at-17-50-36

 

Of course the final name of your database will be the suffix + the name you have chosen. So in our example the name is “yourdoma_wpdb”.

Then you have to create a user for this database. On the same page, scroll down on the page to the section “MySQL users” > “Add new user”. Like the database creation, create a user for your database. It’s a virtual user which has some rights on your database. So enter a username and a password, and click “Create user” to save.

Then you have to associate this user to your database. On the same page, go to the section “Add User to Database”. Select your user and your database in the lists and click “Add”, and you will be sent to a new screen to define the rights of this user. Give this user all privileges:

screen-shot-2016-12-12-at-17-57-24

Then click on “Make Changes”.

Installation

You’re mostly done now. Your files are ready, your database is ready, you can now install.

To install, just enter the chosen domain name for your webspace in your browser.

You should start with the WordPress installation. Just follow the steps.

Troubleshooting:

There may be a big number of issues due to a big number of reasons! The first one may be that your server configuration doesn’t meet the requirements of WordPress. But the servers are nowadays largely compatible with WordPress requirements.

So due to the large number of reasons, Google is your best friend! Or not, in this case choose another search engine 😉and copy and paste the error displayed on your browser when you try to reach your website or when you have an error. You may not be the only person in the world with this issue and you may find a solution on the web.

A classical issue concerns your domain name. You may have entered a domain name when creating your webspace whereas this domain name is not yet associated to your server. This is often the case when you buy your domain name and your server separately, or from two separated providers. So what’s happening here? You enter your domain name in your browser, your browser asks the Internet to display the files related to this domain name, the Internet looks for the computer (server) on which there are the files for this domain name, and (several options):

  • fails to retrieve the server (the DNS settings are not set)
  • shows the wrong files (your domain is associated to another server on which there are some default files for your domain)
  • shows another website than it should be: you don’t have yet bought this domain and it’s already owned by someone. Don’t forget to buy a domain name before trying to use it!

A quick solution is to go in your domain name panel, the panel of the provider from whom you have bought your domain name. Then go to the DNS settings, and, in case 1 reset the DNS settings to default (be sure you are not using your domain name or a subdomain already for another website), in case 2, the quickest solution is to create a “A record” from the DNS zone management of your panel, and point this record to the IP address of your server (remember you already have this IP address when you have created the webspace on your Plesk panel). This way your domain name will be associated to your server.

Wait a little bit until these new DNS settings are transferred (it may takes up to 24h/48h) and retry afterwards in your browser. If it keeps not showing the installation of WordPress you may have some cache in your browser. Try with another browser or with the “incognito” mode of your browser.

The PHP settings

At the time we write this article, the recommended PHP version is 7.0. That doesn’t mean it is not working on an earlier version of PHP but it’s better if your hosting supports the 7.0 version. Indeed the operating system on your server may support several versions of the PHP language. Why are there several versions of a language? Because like everything in computer tech, nothing is frozen and things must adapt to its environment evolution. So programming language evolutes also in order to match its environment, offers new capabilities and/or being faster. So it’s always something you will benefit from, but your hosting server must also support these evolutions.

Depending on your version of cPanel you may have another presentation of this section. The tools you may see in your cPanel interface may also depend on what your provider gives you access to. So the list of items you will see in your interface and the options you have may differ. In all cases, the PHP options are located in the “Software” section of your cPanel interface. To adjust the PHP version click on “MultiPHP Manager”:

screen-shot-2016-12-14-at-11-52-30

From here you will be able to set a specific PHP version for your webspace. Just choose the PHP version and save.

As seen in the previous article regarding the Plesk panel, you may want/need to adjust some PHP settings. Let’s look how and why to do these changes. Click on MultiPHP INI editor:

screen-shot-2016-12-14-at-11-56-32

You can see a list of items that you can adjust or enable.

Indeed PHP has some settings set with default values, but these values may block you to perform some actions. For example a setting at 2M for “upload_max_filesize” will block any upload of files that weight over 2Mb. When you create your website you may want to upload images which weight over 2Mb, so you can adjust this setting to a more comfortable value like 16M for example:

screen-shot-2016-12-14-at-11-59-27

Although you have set this item to a suitable value you may still have your files rejected when you try to upload them. If so, do the same with the post_max_size value, this item has the same function than the previous one but the upload is done through another PHP function.

These items, “memory_limit” and “max_execution_time”, can be used if it takes a long time to load your website and fails. You may increase their values and test.

So all of these settings may be involved in the functioning of your website/software and the errors you may encounter. You have to know, all the PHP items are not displayed here, these are only the most used ones. We will see in another article how to access all the PHP settings to change them.

Adding a cron job (scheduled task)

What’s a cron job? It’s an automated task. Sometimes you may need something to be launched every day at a specific time, for example. And so you may want to automate this task. That’s the job of the cron job, launching a specific action at a specific date.
Most of the times, the action required by a CMS or any other kind of web application, is to launch a file periodically. This file will contain a code to execute some specific actions. These actions could be, for example, to send a message to all users every morning at 9am, or to restart a game every night at midnight, etc.

So if your web application asks you to create a scheduled task, a cron job, you can do this from the menu “Cron Jobs” which is located in the “Advanced” section of your cPanel interface:

screen-shot-2016-12-14-at-12-00-49

 

Common Settings

By choosing one of these common settings it will pre-fill all the fields with pre-made settings which are commonly used.

For example, if you want to execute a task every minute, you can choose “once per minute”:

screen-shot-2016-12-14-at-12-16-34

 

Command

Here you have to enter the specific command to execute.

Most of the time it is about launching a file in which a code must be executed. This file can be part of a command like:

/var/www/vhosts/yourdomain.com/httpdocs/file-to-launch.php -f >> /var/www/vhosts/yourdomain.com/httpdocs/logs/error_log.php

In this example, the command asks to run a file named “file-to-launch.php” with an argument “-f” and to send the results to a file named error_log.php (this kind of file is used to record the errors that may happen when launching the file “file-to-launch.php”.

Using a SSL certificate

You may want to use a SSL certificate to make your website accessible only through a secured connection (“https”). To do that you need to set a SSL certificate for your domain. With the latest cPanel versions you just have to go in the “Security” section and click on “SSL/TLS”.

Then click on “Manage SSL sites” in the “Install and Manage SSL for your site (https)” section. Afterwards you just have to choose to install a SSL certificate.