Installing CyberPanel on Ubuntu and CentOS

Posted on

Installing CyberPanel on Ubuntu and CentOS

Installing CyberPanel on Ubuntu and CentOS

CyberPanel is an open-source web hosting control panel designed for ease of use and efficient web server management. It provides a user-friendly GUI to handle various aspects of web hosting, including domains, websites, databases, DNS zones, email accounts, and more. Its intuitive interface simplifies complex server tasks.

CyberPanel is compatible with both Ubuntu and CentOS servers. While the installation process is generally straightforward, it involves several steps. This guide provides a comprehensive walkthrough of the entire installation process on both Ubuntu and CentOS operating systems.

Prerequisites

Before you begin the installation process, ensure that your server meets the following prerequisites:

  • A server running either Ubuntu or CentOS.
  • Root access or a user with sudo privileges.
  • A stable internet connection.
  • At least 1 GB of RAM (2 GB recommended).
  • At least 10 GB of free disk space.
  • A fully qualified domain name (FQDN) pointed to your server’s IP address (optional, but recommended for SSL certificates).

Once your server meets these requirements, you can proceed with the installation steps.

Step 1 – Prepare the Server

Log in to your server via SSH as the root user or a user with sudo privileges.

For Ubuntu, execute the following commands:

$ sudo apt update
$ sudo apt upgrade -y

For CentOS, run:

$ sudo yum update -y

These commands will update all installed packages to their latest versions, ensuring you have the most recent security patches and bug fixes.

Next, on CentOS, verify that SELinux is disabled using the following command:

$ sudo sestatus

If the output displays "SELinux status: disabled," you can proceed. If SELinux is enabled, disable it temporarily using:

$ sudo setenforce 0

To permanently disable SELinux, edit the /etc/selinux/config file and set the SELINUX parameter to disabled.

Finally, reboot your server to ensure that all changes take effect.

$ reboot

The server is now prepared and ready for the CyberPanel installation process.

Step 2 – Install Dependencies

CyberPanel requires several additional dependencies to be installed beforehand. These dependencies provide essential functionality for the control panel and its associated services.

On Ubuntu:

$ sudo apt install wget curl lscpu python3 git redis-server python3-pip python3-virtualenv python3-dev build-essential libssl-dev libcurl4-openssl-dev libsodium-dev libjpeg-dev libffi-dev memcached dnsutils -y

On CentOS:

$ sudo yum install wget curl lscpu python git redis MariaDB-server MariaDB-client memcached chrony libjpeg-devel libcurl-devel rpm-build python3 python3-devel python3-pip python3-virtualenv gcc policycoreutils-python -y

These commands will install all the necessary dependencies and packages.

Step 3 – Install CyberPanel

Now, you can finally install CyberPanel itself!

Execute the following command to download and run the installer script:

$ sudo su - -c "sh <(curl https://cyberpanel.net/install.sh || wget -O - https://cyberpanel.net/install.sh)"

The installer will now prompt you with a series of questions to customize your installation.

Select LiteSpeed Version

Choose whether you want to install CyberPanel with OpenLiteSpeed or LiteSpeed Enterprise. If you select Enterprise, you will need to enter your license key when prompted. OpenLiteSpeed is the free and open-source version, while LiteSpeed Enterprise offers enhanced performance and features but requires a commercial license.

Select Options

You will be asked if you want to install various components, including:

  • Full installation (recommended): Installs all recommended components, including the web server, database server, mail server, and DNS server.
  • Install Stunnel: Stunnel creates secure SSL/TLS tunnels.
  • Install Memcached: Memcached is a high-performance, distributed memory object caching system.
  • Install Redis: Redis is an in-memory data structure store, used as a database, cache and message broker.

Select Version

Select the latest version of CyberPanel when prompted. It is generally recommended to use the latest stable version to benefit from the latest features and security updates.

Set Admin Password

Create a strong and unique password for the CyberPanel admin console. This password will be used to access and manage your server through the CyberPanel interface.

The installer will then automatically install CyberPanel and all the components you selected. This process may take 5-10 minutes to complete.

Once the installation is complete, you will see a completion message containing your credentials and important details, such as the URLs to access CyberPanel.

Your CyberPanel installation is now ready!

Step 4 – Finalize Installation

Although CyberPanel is installed, you need to perform a few additional steps to finalize the setup.

Restart Server

Restart your server to ensure that all changes take effect.

$ sudo reboot

Wait a minute or two for the server to start up again before proceeding.

Add CyberPanel Firewall Rules

For CyberPanel to function correctly, the following ports must be open in your firewall:

  • 80: HTTP (Web server)
  • 443: HTTPS (Secure web server)
  • 20, 21: FTP
  • 22: SSH (optional, but recommended to change the default port for security)
  • 25, 587, 465: SMTP (Email)
  • 110, 995: POP3 (Email)
  • 143, 993: IMAP (Email)
  • 53: DNS (if using CyberPanel’s DNS server)
  • 8090: CyberPanel Admin Console

Add rules to allow these ports if needed. You can use ufw on Ubuntu or firewalld on CentOS.

Ubuntu (ufw):

sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 20
sudo ufw allow 21
sudo ufw allow 22
sudo ufw allow 25
sudo ufw allow 587
sudo ufw allow 465
sudo ufw allow 110
sudo ufw allow 995
sudo ufw allow 143
sudo ufw allow 993
sudo ufw allow 53
sudo ufw allow 8090
sudo ufw enable

CentOS (firewalld):

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --permanent --add-port=20-21/tcp
sudo firewall-cmd --permanent --add-port=22/tcp
sudo firewall-cmd --permanent --add-port=25/tcp
sudo firewall-cmd --permanent --add-port=587/tcp
sudo firewall-cmd --permanent --add-port=465/tcp
sudo firewall-cmd --permanent --add-port=110/tcp
sudo firewall-cmd --permanent --add-port=995/tcp
sudo firewall-cmd --permanent --add-port=143/tcp
sudo firewall-cmd --permanent --add-port=993/tcp
sudo firewall-cmd --permanent --add-port=53/tcp
sudo firewall-cmd --permanent --add-port=8090/tcp
sudo firewall-cmd --reload

Install Let’s Encrypt SSL Certificate

Access the CyberPanel Admin Console and navigate to "Let’s Encrypt Settings." Here, you can generate and install free SSL certificates for your domains. This will enable HTTPS on your websites, providing secure communication between your server and your visitors.

Test CyberPanel

Create a new domain, host a simple HTML website under it, and test access to it. Also, create some email accounts and test sending/receiving emails. This will verify that your installation is fully functional.

Congratulations! Your CyberPanel control panel is now ready to manage your web hosting server.

Accessing and Configuring CyberPanel

Once installed, you can access the CyberPanel admin dashboard using:

URL: https://serverIP:8090/

Username: admin

Password: The password you set during installation

On the dashboard, you can:

  • Manage websites and domains.
  • Create and manage email accounts.
  • Manage databases.
  • Configure DNS zones.
  • Monitor server resources.
  • Install SSL certificates.

Refer to the CyberPanel documentation to understand all the features in depth. It provides guides on how to use and configure every aspect of managing your server through CyberPanel.

Some important things you should do initially:

  • Change the default admin password.
  • Configure your firewall.
  • Set up automatic backups.
  • Install an SSL certificate.

Also, keep your CyberPanel updated to the latest version regularly for security updates and new features.

Troubleshooting Common Issues

Following are some common issues faced during CyberPanel installations:

Stuck on "Loading…" on Admin Dashboard

This is likely caused by SELinux being enabled on CentOS. Temporarily disable it by running:

$ sudo setenforce 0

If this resolves the issue, you can permanently disable SELinux by editing /etc/selinux/config and setting SELINUX=disabled.

503 Service Unavailable Error

If you get a 503 error when trying to access a domain, restart the lscpd service:

$ sudo systemctl restart lscpd

Also, activate virtualenv by running:

$ source /usr/local/CyberCP/bin/activate

Firewall Blocking Access

Make sure all the required ports are open in your network firewall. Refer to the ports list given earlier in the guide.

Emails Not Being Sent/Received

Follow CyberPanel’s email configuration guide to set up and debug Postfix issues. Ensure that your DNS records (MX records) are correctly configured and that your firewall allows traffic on the necessary email ports (25, 587, 465, 110, 995, 143, 993).

Websites Not Loading

Make sure DNS records are properly configured for your domains. And the actual website content is located in the correct directory configured in CyberPanel. Verify that the document root for your website is correctly configured in CyberPanel and that the necessary PHP extensions are installed and enabled.

Feel free to ask questions on the CyberPanel Forum if you need help resolving any other issues during setup.

Alternative Solutions

While CyberPanel offers a convenient GUI for managing web servers, there are alternative approaches to achieving similar results. Here are two such methods:

1. Using Docker and Docker Compose

Docker allows you to containerize your web applications and their dependencies, making them portable and easier to manage. Docker Compose simplifies the process of defining and running multi-container Docker applications.

Explanation:

Instead of installing CyberPanel directly on the server, you can use Docker to run the necessary web server, database, and other services in separate containers. This approach offers several advantages:

  • Isolation: Each container is isolated from the others, preventing conflicts between different applications.
  • Portability: Docker containers can be easily moved between different servers or environments.
  • Scalability: You can easily scale your application by adding more containers.

Code Example:

Here’s an example docker-compose.yml file that defines a web server (using Nginx), a database (using MySQL), and a PHP application:

version: "3.8"
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./app:/var/www/html
    depends_on:
      - app

  app:
    image: php:8.1-fpm
    volumes:
      - ./app:/var/www/html

  db:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: password
      MYSQL_DATABASE: mydb
    volumes:
      - db_data:/var/lib/mysql

volumes:
  db_data:

To run this application, save the file as docker-compose.yml and then run the following command in the same directory:

docker-compose up -d

This will start the web server, database, and PHP application in separate containers. You can then access your application by visiting your server’s IP address in your web browser. This requires configuration of the nginx conf.d file to point to the correct app directory.

2. Using Ansible for Automated Server Provisioning

Ansible is an open-source automation tool that allows you to automate the process of configuring and managing servers.

Explanation:

Instead of manually installing and configuring each component of your web hosting environment, you can use Ansible to automate the entire process. This approach offers several benefits:

  • Idempotency: Ansible playbooks are idempotent, meaning that they can be run multiple times without changing the state of the server if it is already in the desired state.
  • Configuration Management: Ansible allows you to manage the configuration of your servers in a consistent and repeatable way.
  • Scalability: You can easily scale your infrastructure by running Ansible playbooks on multiple servers.

Code Example:

Here’s an example Ansible playbook that installs Nginx, PHP, and MySQL on a server:

---
- hosts: all
  become: true
  tasks:
    - name: Update apt cache
      apt:
        update_cache: yes
      when: ansible_os_family == "Debian"

    - name: Install Nginx
      apt:
        name: nginx
        state: present
      when: ansible_os_family == "Debian"

    - name: Install PHP
      apt:
        name: php-fpm
        state: present
      when: ansible_os_family == "Debian"

    - name: Install MySQL
      apt:
        name: mysql-server
        state: present
      when: ansible_os_family == "Debian"

    - name: Start Nginx
      service:
        name: nginx
        state: started
        enabled: yes

To run this playbook, save it as install.yml and then run the following command:

ansible-playbook -i inventory.txt install.yml

Replace inventory.txt with your inventory file, which lists the servers you want to manage. The user running this command must have the correct ssh keys for each server.

Conclusion

Installing CyberPanel on Ubuntu and CentOS provides a robust and user-friendly hosting control panel to efficiently manage your web servers through a graphical interface.

By following this step-by-step guide during installation and configuration, you can ensure a smoothly running hosting environment. Remember to keep your server and CyberPanel updated and secure.

CyberPanel empowers you to host multiple websites on your servers while minimizing management overhead, making it an excellent choice for small to medium-sized hosting providers, developers, and businesses running their own servers.

Leave a Reply

Your email address will not be published. Required fields are marked *