How to Install Plesk on Ubuntu and AlmaLinux

Posted on

How to Install Plesk on Ubuntu and AlmaLinux

How to Install Plesk on Ubuntu and AlmaLinux

Plesk is a leading web hosting control panel designed to streamline the management of websites, domains, and hosting services. It’s a boon for web hosting providers, web developers, and server administrators alike. Plesk offers a user-friendly yet robust interface for handling routine hosting tasks, including website and domain creation and management, email configuration, database administration, DNS settings adjustments, and much more.

This comprehensive guide provides step-by-step instructions for installing the latest version of Plesk on two popular Linux distributions: Ubuntu and AlmaLinux.

Prerequisites

Before initiating the installation process, ensure the following prerequisites are met:

  • A clean installation of either Ubuntu 20.04/22.04 or AlmaLinux 8/9.
  • Root access to the server.
  • A valid Plesk license key.
  • A stable internet connection.

Without further ado, let’s proceed with the installation of Plesk!

Step 1 – Install Required Packages

The initial step involves ensuring all necessary packages are installed on the server.

On Ubuntu

Log in to your Ubuntu server as root and execute the following commands:

$ sudo apt update
$ sudo apt install unzip curl wget perl libnet-ssleay-perl ntp ntpdate apache2 apache2-utils apache2-suexec-custom libapache2-mod-ruid2 libapache2-mod-fcgid libmysqlclient-dev libpq-dev rsync git sudo

On AlmaLinux

On AlmaLinux, execute these commands:

$ sudo yum update -y
$ sudo yum install unzip curl wget perl-libwww-perl perl-Net-SSLeay perl-Archive-Tar ntp ntpdate httpd httpd-tools mod_ssl mod_fcgid mod_ruid2 mysql-devel postgresql-devel rsync git sudo -y

These commands will install all the prerequisite packages.

Step 2 – Configure NTP

Plesk necessitates accurate system date and time. To ensure this, we’ll configure NTP:

$ sudo ntpdate pool.ntp.org
$ sudo systemctl enable ntpd.service
$ sudo systemctl start ntpd.service

Verify the NTP synchronization status using:

$ sudo ntpstat

Step 3 – Configure Firewall

Open the required ports in the firewall.

For Ubuntu, allow the following ports:

21, 22, 25, 80, 110, 143, 443, 465, 993, 995, 8443, 8447

On AlmaLinux, run:

$ sudo firewall-cmd --permanent --add-port={21,22,25,80,110,143,443,465,993,995,8443,8447}/tcp
$ sudo firewall-cmd --reload

This will open the necessary ports for Plesk.

Step 4 – Disable SELinux (AlmaLinux only)

On AlmaLinux, disable SELinux by editing /etc/sysconfig/selinux:

$ sudo sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux

Reboot the system for the changes to take effect.

Step 5 – Create Plesk User

Create a user called psaadm for Plesk:

$ sudo useradd psaadm

And set a password:

$ sudo passwd psaadm

This user will be used to run Plesk services.

Step 6 – Download and Install Plesk

Now we’re ready to install Plesk.

Go to the Plesk downloads page and grab the Plesk installer for Linux:

$ sudo cd /tmp
$ wget https://download.plesk.com/plesk/plesk-installer/plesk-installer

Make the installer executable:

$ sudo chmod +x /tmp/plesk-installer

Finally, run the installer as root, providing your license key:

sudo /tmp/plesk-installer --with-panel bind --license-key YOUR_LICENSE_KEY_HERE

This will install Plesk with all components and apply the license key. Follow the on-screen instructions.

Once the installer finishes, Plesk will be installed and ready!

Step 7 – Configure Apache for Plesk (Ubuntu only)

On Ubuntu, we need to configure Apache for Plesk.

Open /etc/apache2/apache2.conf and add/edit the following lines:

<Directory /var/www/>
  AllowOverride All
</Directory>
Include /etc/plesk-apache.conf

Save and exit. Then enable required modules:

$ sudo a2enmod rewrite actions include proxy_fcgi setenvif

Finally, restart Apache:

$ sudo systemctl restart apache2

That’s it! Apache is now configured for Plesk.

Step 8 – Configure PostgreSQL for Plesk

Plesk requires access to a PostgreSQL database. We’ll configure a postgres user and database for Plesk.

Connect to PostgreSQL:

$ sudo su - postgres
$ sudo psql

Create a user called psa and set a password:

CREATE USER psa WITH ENCRYPTED PASSWORD 'strongpassword';

Create a database psa owned by user psa:

CREATE DATABASE psa OWNER psa;

Allow the user to connect remotely:

ALTER USER psa WITH LOGIN;

Exit PostgreSQL:

q
exit

PostgreSQL is now ready for Plesk.

Step 9 – Configure MariaDB for Plesk (Optional)

If you want Plesk to also use MariaDB, follow these steps.

Log in to MariaDB as root:

$ mysql -u root -p

Create a user psa and database psa:

CREATE USER 'psa'@'localhost' IDENTIFIED BY 'strongpassword';
CREATE DATABASE `psa` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
GRANT ALL PRIVILEGES ON `psa`.* TO 'psa'@'localhost';
FLUSH PRIVILEGES;

Exit MariaDB:

exit

MariaDB is now ready for Plesk.

Step 10 – Access Plesk Web Interface

Plesk should now be installed and ready! You can access the Plesk web UI at:

http://your_server_ip:8443

Log in with:

  • Username: admin
  • Password: The password you set during the installation process or using the troubleshooting steps below.

That’s it! You now have Plesk installed on your Ubuntu/AlmaLinux server. From the web UI, you can create websites, emails, databases, and manage all aspects of your hosting.

Troubleshooting Common Issues

Here are some common issues and fixes while installing or accessing Plesk:

Page not loading

  • Ensure the Plesk service is running: sudo systemctl status plesk
  • Verify that ports 8443 and 8447 are open in the firewall.
  • Check DNS resolution for the server hostname.

Login page accessible but login fails

  • Reset the admin password using the Plesk CLI:
$ sudo /usr/local/psa/bin/admin --set-password admin

Web interface loads but is unstyled

  • Correct ownership issues within the Plesk directory:
$ sudo chown -R psaadm:psaadm /usr/local/psa

Alternative Solutions for Web Hosting Management

While Plesk provides a comprehensive solution, alternative methods exist for managing web hosting environments. Here are two different approaches:

1. Using Docker and Docker Compose:

Instead of installing Plesk directly on the operating system, you can leverage Docker to containerize various services required for web hosting, such as web servers (Nginx or Apache), database servers (MySQL or PostgreSQL), and email servers (Postfix or Dovecot). Docker Compose allows you to define and manage multi-container applications, making it easier to orchestrate these services.

  • Explanation: This approach offers greater isolation, portability, and reproducibility. Each service runs in its own container, preventing conflicts and simplifying upgrades. Docker Compose allows you to define the entire hosting stack in a single YAML file, making it easy to deploy and manage.

  • Code Example (docker-compose.yml):

    version: "3.9"
    services:
      nginx:
        image: nginx:latest
        ports:
          - "80:80"
          - "443:443"
        volumes:
          - ./nginx/conf.d:/etc/nginx/conf.d
          - ./web:/var/www/html
        depends_on:
          - mysql
    
      mysql:
        image: mysql:8.0
        environment:
          MYSQL_ROOT_PASSWORD: your_root_password
          MYSQL_DATABASE: your_database
          MYSQL_USER: your_user
          MYSQL_PASSWORD: your_password
        volumes:
          - ./mysql/data:/var/lib/mysql

    This example sets up a basic Nginx web server and a MySQL database using Docker Compose. You would need to create the necessary configuration files for Nginx (e.g., virtual host configurations) and the web application itself in the ./web directory.

2. Using a Configuration Management Tool (Ansible, Chef, or Puppet):

Configuration management tools like Ansible, Chef, and Puppet allow you to automate the process of configuring and managing servers. You can define the desired state of your servers in code (e.g., playbooks in Ansible, recipes in Chef), and the tool will automatically ensure that the servers match that state.

  • Explanation: This approach is ideal for managing a large number of servers and ensuring consistency across your infrastructure. You can use these tools to automate the installation and configuration of web servers, databases, and other services required for web hosting. They can also be used to update software packages and apply security patches automatically.

  • Code Example (Ansible Playbook – install_nginx.yml):

    ---
    - 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: Start nginx
          service:
            name: nginx
            state: started
            enabled: yes

    This Ansible playbook installs and starts the Nginx web server on Debian-based systems. You would need to configure Ansible to connect to your target servers. Running this playbook would automate the process of installing Nginx across your infrastructure.

These alternative solutions offer different advantages and disadvantages compared to using Plesk. Docker and Docker Compose provide isolation and portability, while configuration management tools offer automation and consistency. The best approach depends on your specific needs and requirements.

Conclusion

With Plesk installed, you now possess a powerful and user-friendly control panel for managing your hosting services. Plesk simplifies the administration of websites, emails, DNS, databases, and more through its intuitive web interface. It’s an excellent choice for web hosts, developers, and server administrators seeking to streamline website management and hosting automation.

Leave a Reply

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