How to Install cPanel & WHM on AlmaLinux 9: A Comprehensive Guide

Setting up a web hosting environment can seem daunting, but with the right tools and a clear guide, it becomes a streamlined process. This guide will walk you through the installation of cPanel & WHM (Web Host Manager) on AlmaLinux 9, providing you with the power to manage your server and host websites with ease. At Its Foss, we aim to simplify complex tasks. This guide is meticulously crafted to ensure a smooth installation.

Prerequisites for cPanel & WHM Installation on AlmaLinux 9

Before we dive into the installation process, ensuring you have met all the necessary prerequisites is crucial. This will prevent potential roadblocks down the line.

  • A Fresh AlmaLinux 9 Installation: It’s highly recommended to install cPanel & WHM on a fresh AlmaLinux 9 installation. This minimizes conflicts with existing software and ensures a clean environment. We understand that rebuilding a server from scratch might be inconvenient, however, doing so is in alignment with cPanel’s officially supported configuration.
  • A Valid cPanel License: cPanel & WHM requires a valid license. You can obtain a license directly from cPanel or through an authorized reseller. Without a license, your installation will function in trial mode for a limited time. Make sure to factor the cPanel licensing cost into your overall operational budget for your website at Its Foss.
  • A Static IP Address: Your server needs a static IP address. This is essential for consistent DNS resolution and accessibility. Most hosting providers offer the option to assign a static IP during server setup.
  • Root Access: You must have root access to your server to perform the installation. This can be achieved through SSH or a direct console connection.
  • Sufficient Resources: Ensure your server meets the minimum hardware requirements for cPanel & WHM. These requirements can be found on the official cPanel website and typically include a minimum amount of RAM, disk space, and CPU cores. It is advisable to allocate more resources than the minimums in order to ensure peak performance.
  • Hostname Configuration: A properly configured hostname is critical. The hostname should be a Fully Qualified Domain Name (FQDN).
  • Firewall Configuration: While AlmaLinux 9 comes with a firewall (firewalld), you might need to adjust it to allow necessary ports for cPanel & WHM.

Step-by-Step Guide to Installing cPanel & WHM on AlmaLinux 9

Now that we have covered the prerequisites, let’s get started with the installation process. These steps are detailed and easy to follow, even for beginners.

Step 1: Update Your AlmaLinux 9 System

Before installing any new software, it is essential to update your system to the latest packages. This ensures you have the latest security patches and bug fixes. Open your terminal and run the following commands:

sudo dnf update -y
sudo dnf upgrade -y

These commands will update the package lists and upgrade any outdated packages on your system. The -y flag automatically confirms any prompts during the update process, saving you time.

Step 2: Set the Hostname

A properly configured hostname is vital for cPanel & WHM to function correctly. Set the hostname using the following command, replacing yourhostname.example.com with your desired FQDN:

sudo hostnamectl set-hostname yourhostname.example.com

Verify the hostname by running:

hostnamectl

This command will display the current hostname and other system information. Make sure the “Static hostname” reflects the FQDN you set.

Step 3: Disable NetworkManager (If Necessary)

In some cases, NetworkManager can interfere with cPanel & WHM. If you encounter issues, disabling NetworkManager might resolve them. First, stop the NetworkManager service:

sudo systemctl stop NetworkManager

Then, disable it from starting automatically on boot:

sudo systemctl disable NetworkManager

Next, enable and start the network service:

sudo systemctl enable network
sudo systemctl start network

Step 4: Install Perl

cPanel & WHM requires Perl to function correctly. Install Perl and its dependencies using the following command:

sudo dnf install perl -y

This command will install the Perl interpreter and any necessary modules.

Step 5: Download the cPanel Installation Script

Navigate to your /home directory and download the latest cPanel installation script:

cd /home
curl -o latest -L https://securedownload.cpanel.net/latest

This command downloads the installation script and saves it as latest in your /home directory.

Step 6: Run the cPanel Installation Script

Execute the installation script with root privileges:

sudo sh latest

The installation script will begin downloading and installing cPanel & WHM. This process can take anywhere from 30 minutes to several hours, depending on your server’s resources and network speed. It is crucial to be patient and avoid interrupting the installation process.

The installer will display progress updates in the terminal. We recommend monitoring these updates to ensure the installation is proceeding smoothly. Should any errors occur, the installer will usually provide details to assist with troubleshooting.

Step 7: Configure the Firewall

AlmaLinux 9 uses firewalld as its default firewall. You need to allow the necessary ports for cPanel & WHM. Here are some essential ports to open:

  • 2082: cPanel
  • 2083: cPanel (SSL)
  • 2086: WHM
  • 2087: WHM (SSL)
  • 2095: Webmail
  • 2096: Webmail (SSL)
  • 25: SMTP (outgoing email)
  • 110: POP3 (incoming email)
  • 143: IMAP (incoming email)
  • 465: SMTP (SSL)
  • 587: Submission (SMTP)
  • 993: IMAP (SSL)
  • 995: POP3 (SSL)
  • 80: HTTP (web access)
  • 443: HTTPS (secure web access)
  • 21: FTP
  • 20: Passive FTP

Use the following commands to open these ports in firewalld:

sudo firewall-cmd --permanent --add-port=2082/tcp
sudo firewall-cmd --permanent --add-port=2083/tcp
sudo firewall-cmd --permanent --add-port=2086/tcp
sudo firewall-cmd --permanent --add-port=2087/tcp
sudo firewall-cmd --permanent --add-port=2095/tcp
sudo firewall-cmd --permanent --add-port=2096/tcp
sudo firewall-cmd --permanent --add-port=25/tcp
sudo firewall-cmd --permanent --add-port=110/tcp
sudo firewall-cmd --permanent --add-port=143/tcp
sudo firewall-cmd --permanent --add-port=465/tcp
sudo firewall-cmd --permanent --add-port=587/tcp
sudo firewall-cmd --permanent --add-port=993/tcp
sudo firewall-cmd --permanent --add-port=995/tcp
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --permanent --add-port=21/tcp
sudo firewall-cmd --permanent --add-port=20/tcp

sudo firewall-cmd --reload

These commands add the specified ports to the firewall and then reload the firewall to apply the changes.

Step 8: Access cPanel & WHM

Once the installation is complete, you can access cPanel & WHM through your web browser.

  • WHM: Open your browser and navigate to https://your_server_ip:2087 or https://your_hostname:2087.
  • cPanel: Navigate to https://your_server_ip:2083 or https://your_hostname:2083.

You will be prompted to log in with your root username and password.

Step 9: Complete the WHM Initial Setup

After logging in to WHM, you will be guided through an initial setup process. This includes:

  • Agreeing to the Terms of Service: Read and agree to the cPanel & WHM Terms of Service.
  • Setting Up Server Contact Information: Provide an email address for important server notifications.
  • Adding Nameservers: Configure your nameservers for DNS resolution. If you do not have your own nameservers, you can use your hosting provider’s.
  • Setting Up the Root Password: Change the root password to a strong, unique password.
  • Setting Up Initial Packages and Features: Configure default packages and features for new cPanel accounts.

Follow the on-screen instructions to complete the initial setup.

Step 10: Verify cPanel Installation

Login to cPanel as a test user using https://your_server_ip:2083 or https://your_hostname:2083. Create a test website and check if you can upload files and access the website.

Troubleshooting Common cPanel & WHM Installation Issues

While the installation process is generally straightforward, you might encounter some common issues. Here are some troubleshooting tips:

  • License Issues: If you encounter license errors, ensure your cPanel license is valid and activated. You can check your license status on the cPanel website or through your license provider.
  • Firewall Issues: If you cannot access cPanel or WHM, double-check your firewall settings to ensure the necessary ports are open.
  • DNS Resolution Issues: If your hostname does not resolve correctly, verify your DNS settings and ensure your nameservers are properly configured.
  • Installation Errors: If the installation script encounters errors, carefully review the error messages and consult the cPanel documentation or support forums for assistance. Often, the error messages provide clues about the cause of the problem.

Securing Your cPanel & WHM Installation

Security is paramount when running a web hosting environment. Here are some essential security measures to implement after installing cPanel & WHM:

  • Enable Two-Factor Authentication (2FA): Enable 2FA for all user accounts, including the root account, to add an extra layer of security.
  • Configure CSF Firewall: CSF (ConfigServer Security & Firewall) is a powerful firewall that integrates seamlessly with cPanel & WHM. Install and configure CSF to protect your server from malicious attacks.
  • Keep Software Up-to-Date: Regularly update cPanel & WHM, AlmaLinux 9, and all other software on your server to patch security vulnerabilities.
  • Monitor Server Logs: Regularly monitor your server logs for suspicious activity.
  • Use Strong Passwords: Enforce strong password policies for all user accounts.

Optimizing cPanel & WHM Performance

To ensure optimal performance, consider the following optimization tips:

  • Optimize Apache and MySQL: Fine-tune Apache and MySQL settings to improve performance and resource utilization.
  • Use a Content Delivery Network (CDN): Use a CDN to distribute your website’s content across multiple servers, improving loading times and reducing server load.
  • Enable Caching: Enable caching mechanisms such as APCu and Memcached to reduce database queries and improve website performance.
  • Monitor Server Resources: Regularly monitor your server’s CPU, RAM, and disk usage to identify potential bottlenecks.

Conclusion: Harnessing the Power of cPanel & WHM on AlmaLinux 9

Installing cPanel & WHM on AlmaLinux 9 is a powerful way to manage your server and host websites with ease. By following this comprehensive guide, you can ensure a smooth installation process and create a secure and optimized web hosting environment. At Its Foss, we’re dedicated to empowering you with the knowledge to navigate the world of Linux and open-source software. We hope this guide makes your server management journey seamless and productive. And remember to regularly update your knowledge with our latest guides at Its Foss.