cPanel Tutorial

cPanel is one of the most widely used web hosting control panel. It has a vast number of utilities and tools for website and server management. For example, you can manage and publish your websites, create email and FTP accounts, install applications like WordPress, secure your website with SSL certificates.

cPanel is based on the Linux operating system, and it currently supports Centos 7, Cloud Linux 6 and 7, Red Hat Enterprise Linux version 7.  Amazon Linux 1 was previously supported but has now been abandoned.

cPanel requires a new server for installation. It may be because it requires different services running on a different port; thus, it tries to avoid any port conflict with previously installed services.

Ports Used By cPanel

cPanel has several services for website hosting and server management. Some of these require a specific port to be open for functioning correctly. Hence it would be best if you allowed them through your firewall. A brief list of services and the ports they listen upon is given below:

cPanel Ports and Services
Service Ports
cPanel 2082
cPanel SSL 2083
WHM 2086
WHM SSL 2087
SSH 22
SMTP 25, 26, 465
DNS 53
HTTPD 80, 443
Webmail 2095

Ports Modification in cPanel

cPanel provides many services running on different ports, and sometimes it is required to change the default port of a service. The reason for this may be port conflicts or some security issues. Whatever the reason be, we will show how to modify the port number of specific services of cPanel like Apache (HTTPD), SSH, and SMTP. Some port numbers may require you to contact your hosting provider, whereas specific port numbers can no longer be changed, such as cPanel port.

Note: Before adding any new port, configure the firewall to allow the new port traffic. Also, check if some other service does not already use the new port.

Changing Apache Port Number on a cPanel Server.

Step 1: Login to your WHM account and go to tweak settings as follow:

Home >> Server Configuration >> Tweak Settings

Now go to the “System” menu and change both Apache HTTP (80) and SSL HTTPS (443) port number

Changing SSH Port Number on a cPanel Server.

Step 1: Login to your server via SSH as a root user.

Step 2: Once you are logged in, look for ssh_config file and open it with any text editor like nano or vi.

# vi /etc/ssh/ssh_config

Tip: It is always a good idea to back up a file before modifying it.

Step 3: Now, look for a line in the sshd_config file similar to “#Port 22”. Here 22 is the default port on which sshd daemon listens for connections. Uncomment this line by removing the ‘#’ symbol at the start of the line. Now insert any new privileged port number between 1 – 1023. the privileged port is those port that is accessible only by the root user.

# Port 20 changed to Port 69

Step 4: Now restart SSH service using the following command:

# service sshd restart

In case you have misconfigured the file, you can fix the original SSH configuration file by browsing the following link in a web browser:

This script will try to assign an additional SSH configuration file for port 23. Now you can access and modify the original SSH config file.

Changing SMTP Port Number on a cPanel Server.

Some providers block access to port 25 for sending mail. But this port is required for communicating with users using other mail services. For changing the SMTP port, navigate through:

Login to WHM > Service Configuration > Service Manager. Inside “Exim Mail Server (on another port),” change the port number to your desired value.

Even though cPanel offers the option to change the port of Exim SMTP, but it is useless. This is because it breaks the communication as other mail servers are not configured to work with non-standard ports. The solution for this is to use a “smart host” or third-party service option in cPanel.

Using Let’s Encrypt with cPanel

Let’s Encrypt is a free and most widely used TLS encryption service. cPanel has made it very easy to install and manage the SSL certificate provided by Let’s Encrypt. To use the Let’s Encrypt SSL service, you need to install the cPanel Let’s Encrypt plugin. The Auto SSL feature of cPanel and the Let’s Encrypt Plugin for cPanel fetches the certificates provided by Let’s Encrypt™. Follow the steps below to install the Let’s Encrypt plugin:

  1. Log in to your server with the root user credential.
  2. Now run the following command to install the plugin:

    If you want to uninstall the plugin, simply run the below command:

  3. Now activate the Let’s Encrypt provider in WHM. This login to WHM and go to the “Manage Auto SSL” page under “SSL/TLS.” The path is shown below:
    WHM > Home > SSL/TLS > Manage Auto SSL.
  4. Now, in the Providers tab, select the option Let’s Encrypt; after accepting the terms of service, save the file. From now on, Auto SSL will use Let’s Encrypt while replacing a certificate.After Auto SSL has been enabled in WHM, it’s time to add the certificates to your account. Follow the steps below to accomplish this:
    1. Log in to your WHM account.
    2. Under the Manage Auto SSL path, select the Manage Users tab.
    3. Inside the Manage Users tab, you can configure which individual cPanel users can use Auto SSL.
    4. Select the required domain and click “install” to add the Certificate.
    5. After the installation is complete, click the link “Return to SSL Manager” at the bottom of the page.

Let’s Encrypt for Shared Hosting

If you are on a shared hosting plan, then to install the Let’s Encrypt Free SSL certificate follow the below steps:

  1. Go to some website that offers free SSL services like SSLFORFREE or ZEROSSL.
  2. Complete the Free SSL Certificate Wizard by entering your domain name and accept the terms of service.
  3. Next, it will ask you to verify your domain ownership. For example, some SSL service providers ask to create TXT records in the DNS server that hosts your domain. They give the details of the TXT records. Later they will query the DNS server for the TXT records.
    The other method is to download two files and upload them to your cPanel account. The upload location of the file on the server will be inside: public_html>. well-known>acme-challenge.
  4. Now, once we have verified the ownership of the domain, it will provide you with a certificate key and an account or domain Key (private Key). Download or copy these files somewhere. The next thing is to set up the SSL for our website.
  5. log in to your cPanel account. Under the “Security” section, select the SSL/TLS option.
  6. Select the “Manage SSL sites” option under Install and Manage SSL for your site (HTTPS).
  7. Select the domain from the drop-down menu you used to register at ZeroSSl or SSLforFree website.
  8. Now, enter the contents of the domain certificate files into the certificate text box. To verify if the file also contains the CA bundle key, see if it has a “–End Certificate–” and “–Begin Certificate–”line in the middle of the random text. If this is the case, then just cut the part starting from the “–Begin Certificate–” line in the middle to the end of the text.
  9. Now paste the remaining part cut from Step 8 in the Certificate Authority Bundle text box.
  10. Now Copy the Private Key, i.e., domain key, and paste it in the “Private Key” field.
  11. At last, click on the “Install Certificate” to install all the certificates.

To check if your site is running on HTTPS protocol, try accessing your site with

Redirect HTTP to HTTPS

To redirect the http request to https, open the file manager in cPanel. Look for a file named “.htaccess,” If it is not there, then look inside hidden contents, else create a new one.

Open the file and add the following lines:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Now test if .htaccess is working by browsing your site with If it is automatically redirected to https then it is working correctly.

The drawback of using Let’s Encrypt is that the Certificate needs to be re-validated after 90 days. Also, it has several domain limits and rate limits.

cPanel Backup

cPanel provides a feature of backing up our databases, emails, files, etc. The backup can be used to keep a local copy of the data, recover the data, move to a new hosting provider, or for other uses. Backups are a necessary task for system administrators to keep their organization safe in any data disaster. In this guide, we will see how to take different backups using cPanel.

Full Backup
Step 1: Log in to your cPanel account and click on the “Backup” utility under the “Files” section.

Step 2: It will show you three types of backup options: Full Backup, Account Backup, Partial Backup. Click the button under Full Backup, which is labeled as “Download a Full Account Backup.” It will create an archive of all the files and configuration settings of your website.

Step 3: On the next page, it will ask you for the destination to keep your backup archive file. You can select to save the backup on the home directory, transfer it to another server via FTP or SCP protocols.

You can also optionally select to receive an email for backup completion.

Step 4: Click the “Generate Backup” button to start the process of the backup. The method may take time as per the size of your data. It will generate a downloadable backup file with extension.tar.gz. The name of the file contains the time and date of the backup and the domain name.

Partial Backup
With this method, we can only take a backup of particular stuff like 1) Home directory 2) MySQL 3) databases 4) Email forwarders 5) Email filters. To take a partial backup, click the link given against each option below the “Partial Backups” heading.

Account Backups
The account backup option is used only when we have to download the full backup file to our local computer.

The other option, “Backup Wizard,” can also create and restore a backup. It will provide you with a step-by-step guide for managing the backup.

Managing PHP versions with cPanel

cPanel’s Software section provides utilities to configure various settings related to PHP. Below we will see how to modify some of these settings.

Changing the version

Step 1: Login to your cPanel account and go to the Software section. Look for an application named “MultiPHP Manager.” If it is not already installed, you can install it from the cPanel’s Software center like “Installatron Applications Installer” or whatever your hosting company provides software installer.

Step 2: Now select the domain for which you want to change the version of PHP. From the right drop-down menu labeled as “PHP Version,” choose the PHP version you want to install.

Step 3: Click the apply button to confirm your selection. Please be aware that things might get broken sometimes when you change the version of PHP.  For example, you may not be able to open your WordPress admin page after changing PHP’s version. If such a thing happens, then revert to your older version of PHP.

MultiPHP INI Editor is a cPanel utility that allows users to make more significant changes to PHP settings. It has two modes of editing:

  1. Basic mode to change several PHP directives with a toggle switch. These directives include allow_url_fopen, allow_url_include, file_uploads etc.
  2. Editor mode allows adding new PHP code to your php.ini configuration file.

Configuring .htaccess file in cPanel

.htaccess or Hypertext Access file is an essential file for manipulating various aspects of a website running on an Apache server. We can add additional functionality and control features to our site with the .htaccess file configuration. The .htaccess file usually resides in the root directory and is hidden.  You can unhide it from File Manager. However, every directory can have its.htaccess file. If you cannot find the .htaccess file, you can create a new one using File Manager in cPanel.

In this guide, we will try to explore some salient features of the .htaccess file.

  1. Custom Error pages: Most often, you have noticed that when we query a web-page on the internet, we receive a “404: Error Not Found” error when the requested web-page is not available. With the .htaccess file, we can customize these error pages from plan text to nice looking and user attracting web pages.First, you need to design a custom error page and put it into your web server’s root document directory. If you have placed it in some other sub-directory, then specify the path of that sub-directory. Open the .htaccess file and put the following code:
    ErrorDocument 404 /PathToDirectory/Error404.html

    Where first 404 is the error number, and Error404.html is your custom error page.
    We can do the same process for other errors like bad-request, internal-server-error, etc.

  2. Redirecting HTTP request to HTTPS: Sometimes, users access a website over HTTP or request a resource over HTTP; they should have been using HTTPS. In such a case, modern browsers generate an insecure connection warning. To make the connection secure, we can use the .htaccess file to redirect the HTTP request to HTTPS automatically. For this, open the .htaccess file and add the following lines:
    RewriteEngine On
    RewriteCond %{HTTPS}! =on
    RewriteRule ^ (/.*)$ https://%{SERVER_NAME}$1 [redirect=301]

    This module will turn on the rewriting of the URL and redirects any HTTP request to HTTPS. For example, any query like will be redirected to

  3. Blocking users from specific IP addresses: We can block users, networks, and sub-networks from accessing our server using the .htaccess file. This is shown below:
    1. To Block a specific IP address, add the following line to the .htaccess file:
      Deny from w.x.y.z
      Where w.x.y.z is any IP address you want to block.
    2. To block multiple IP addresses, specify each one with space between them.
      Deny from w.x.y.z a.b.c.d
      Where w.x.y.z and a.b.c.d are two different IP addresses.
    3. To Block a complete subnet
      Deny from w.x
      For example, w.x can be 123.162 networks.
    4. To Block multiple subnets
      Deny from w.x a.b
    5. To Block an entire network
      Deny from w.x.0.0/24
  1. Restricting Users from accessing folder and sub-folders: With .htaccess, we can prompt users for authentication when accessing a protected folder.
    1. Log in to your cPanel account.
    2. Create a directory to be protected.
    3. Create a .htaccess file and a password file in the same directory and name the password file as .htpasswd.
    4. Create an encrypted password or htpasswd for the directory to be protected. You can use any online service or software to generate one for you.
    5. Open the .htpasswd in the directory and paste the encrypted password here and save the file.
    6. Open the .htaccess file and select the edit option and insert the following lines of code in the file and save the file:
      AuthName "Authrized Users Only"
      AuthType Basic
      AuthUserFile /home/cpanelusername/public_html/ProtectedFolderPath/
      .htpasswd require valid-user

      Replace the “Cpanel username” with the user name of your account. Inside the AuthUserFile directive, give the path of your .htpasswd file in the directory. Now for accessing this folder, an authorization will be required.

How to install a Node.js App in Cpanel

Node.js is one of the most used open-source and server-side programming platform. Developers widely use it for building cross-platform applications. Once developed, a Node.js application can be deployed on your server. To host your Node.js App using cPanel, follow the steps below:

  1. Login to your cPanel account.
  2. Head to the Software section and select the option for the “SetUp Node.js App” application.
  3. Click the Create Application button to start building your app.
  4. Select the application mode as a development mode to test the app before deploying to the production environment.
  5. In the application, the root chooses the location of application files. This location will be added to /home/username to form a complete path for your application files. Set the name as something like: “myapp”
  6. In the application, the URL adds an entry to make a public URL for your application.
  7. The application startup file is the entry file or index file of our project or the application. Took the name of the startup file as app.js.

Creating the package.json file

After creating the Node.js application in cPanel, we need to create a package.json file. Package.json file contains the metadata information of the Node.js project.

  1. Open File Manager in cPanel and go to the folder of your Node.js application, i.e., myapp. If you remember, the myapp folder was created in step 5 above when we worked with the first-time wizard of the node.js application.
  2. Create a file and name it package.json. Now, right-click and select the option edit.
  3. Put the following text inside it:
    "name": "myapp",
    "version": "1",
    "description": "My Node.js App",
    "main": "app.js",
    "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
    "author": "",
    "license": "ISC."
  1. Also, create an index or entry file, as mentioned in step 7 above the first-time wizard. You can put your custom code here or put the simple “hello world” node.js code here.

Installing NPM or Node process manager

NPM uses a packsge.json file to install all the dependencies. To install npm, follow the steps below:

  1. Select the “Setup Node.js App” option in the software section.
  2. Here you can see your application is running on cPanel and some icons in the right corner. Use these icons to stop or restarting the application.
  3. Now click on the pencil icon, and it will show up the button for installing the NPM package. Just click this button to install NPM.
  4. Our NPM package is installed; we can check our application by browsing our application’s public URL.

This completes our quick tour of cPanel, and some of its features. I hope you have enjoyed this guide. Please share it with others.

About the author

Ali Imran Nagori

Ali Imran Nagori

Ali imran is a technical writer and Linux enthusiast who loves to write about Linux system administration and related technologies. You can connect with him on LinkedIn