Dedicated Server

How to Install cPanel on VPS or Dedicated Server (Ubuntu, CentOS, and AlmaLinux)

cPanel is a widely-used web hosting control panel that simplifies server management. Here's a step-by-step guide to installing cPanel on Ubuntu 22.04 LTS, CentOS, and AlmaLinux.


Prerequisites

  1. A fresh server installation (minimal setup).
  2. A public static IP address.
  3. Root access.
  4. Minimum hardware: 2 GB RAM, 20 GB disk space (higher recommended).

For Ubuntu 22.04 LTS (Jammy Jellyfish)

Step 1: Update the System

Make sure your system is up to date:

bash
apt update && apt upgrade -y

Step 2: Set the Hostname

Set an FQDN for the server:

bash
hostnamectl set-hostname server.yourdomain.com

Step 3: Install Perl

cPanel requires Perl to run the installer:

bash
apt install perl -y

Step 4: Install cPanel

Download the cPanel installation script and run it:

bash
cd /home curl -o latest -L https://securedownloads.cpanel.net/latest sh latest

The installation will take some time depending on your server's specifications.

Step 5: Access WHM

Once installed, access WHM (Web Host Manager) at:

arduino
https://your-server-ip:2087

Log in with your root credentials and follow the setup wizard.


For CentOS and AlmaLinux

Step 1: Update the System

Run:

bash
yum update -y

Step 2: Set the Hostname

Set a fully qualified domain name:

bash
hostnamectl set-hostname server.yourdomain.com

Step 3: Disable SELinux

Edit the SELinux configuration file:

bash
nano /etc/selinux/config

Set SELINUX=disabled and save. Then reboot:

bash
reboot

Step 4: Install cPanel

Run the installation script:

bash
cd /home curl -o latest -L https://securedownloads.cpanel.net/latest sh latest

Step 5: Access WHM

Log in via:

arduino
https://your-server-ip:2087

Post-Installation Steps

  1. Activate License: WHM will prompt for license activation.
  2. Set Nameservers: Configure DNS.
  3. Security Hardening: Set up firewalls and other protections.

Key Differences

  • CentOS: Stable but no longer actively developed (CentOS 7 is supported until 2024).
  • AlmaLinux: Actively supported and recommended for new installations.
  • Ubuntu 22.04: A newly supported OS by cPanel, suitable for those familiar with Ubuntu environments.

Conclusion

cPanel installation is now possible on Ubuntu 22.04, making it a versatile choice alongside CentOS and AlmaLinux. Follow the steps above to get started with cPanel on your VPS or dedicated server.

How to Create a New User and Add It to Sudoers

When managing a VPS or Dedicated Server, you might want to create a new user and grant them administrative privileges. This can be helpful when you need to give others access to your server without granting them full root access. Here’s a simple guide to achieve this.

Step 1: Log in to Your Server

To get started, log in to your server via SSH as the root user:

bash
ssh root@your-server-ip

Step 2: Create a New User

You can create a new user by running the following command. Replace newuser with the desired username:

bash
adduser newuser

This command creates a new user and sets up the user’s home directory. You’ll also be asked to provide a password for the new user.

Step 3: Add the User to the Sudo Group

To give the new user sudo privileges, you need to add them to the sudo group. On most distributions, users in the sudo group are granted administrative privileges. Run the following command:

bash
usermod -aG sudo newuser

This command adds the new user to the sudo group, granting them the ability to run commands with elevated privileges.

Step 4: Verify the User’s Access

To verify that the user has sudo privileges, switch to the new user:

bash
su - newuser

Now try running a command with sudo, such as:

bash
sudo ls /root

You should be prompted for the user’s password. If everything is set up correctly, the user will be able to execute the command.

Step 5: Edit the Sudoers File (Optional)

If you need to configure specific sudo privileges or make advanced modifications, you can directly edit the sudoers file by running:

bash
visudo

Make sure to follow the syntax carefully to avoid errors. You can add a line like this to grant full sudo access to the user:

bash
newuser ALL=(ALL:ALL) ALL

Conclusion

That's it! You've successfully created a new user and added them to the sudoers group on your VPS or Dedicated Server. This user now has the ability to execute administrative commands with sudo. You can use this method to add multiple users with administrative rights while maintaining control over your server’s security.

 
STAY TUNED
Image