Understanding the Plesk Command Line Interface (CLI)
The Plesk Command Line Interface (CLI) stands as a powerful and essential tool for server administrators, enabling direct management of a Plesk server through text-based commands. This extensive guide offers a thorough exploration of the Plesk CLI, covering its fundamental structure, frequently used commands, and practical applications of bin utilities to streamline server management tasks. Gaining proficiency in the Plesk CLI can significantly enhance the efficiency of server administration, providing a more granular level of control over your hosting environment.
This tutorial serves as a detailed introduction to the Plesk Command Line Interface (CLI). We will commence by defining what the Plesk CLI is and highlighting its benefits for server administrators. Subsequently, we will guide you through the process of accessing the Plesk CLI on both Linux and Windows servers. Our discussion will then progress to cover crucial Plesk CLI commands, illustrating how to perform routine operations such as managing domains, email accounts, and databases. Furthermore, we will delve into the bin directory, showcasing several valuable Plesk bin utilities designed for task automation and troubleshooting. To conclude, we will provide practical examples and expert tips to help you master the Plesk CLI for effective server management. By the end of this guide, you will possess a solid understanding of the Plesk CLI and be equipped to use it to optimize your server administration workflow.
Accessing the Plesk Command Line Interface (CLI)
Accessing the Plesk Command Line Interface (CLI) is straightforward and can be achieved via SSH on Linux systems or through the command prompt or PowerShell on Windows servers, following a successful login to your server.
- Linux: Establish an SSH (Secure Shell) connection to your server using an account with appropriate administrative privileges, such as the root user.
- Windows: Launch the Command Prompt or PowerShell application with administrator rights.
- Plesk Environment: It is crucial to navigate to the correct directory where the Plesk CLI tools reside. On Linux, this is typically
/usr/local/psa/bin, while on Windows, it is usuallyC:\Program Files\Plesk\admin\bin. - Verification: Once you are logged in and positioned within the correct directory, you can confirm the accessibility of the CLI by executing a simple Plesk command, such as
plesk version.
Essential Plesk CLI Commands for Domain Management
Key Plesk CLI commands for effective domain management include domain, site, and subscription. These commands empower administrators to create, modify, and delete domains, as well as manage their various settings and configurations.
- Creating a domain:
plesk bin domain --create example.com -ip 192.0.2.1 -webspace example_webspace - Listing domains:
plesk bin domain --list - Changing a domain’s PHP version:
plesk bin site --update example.com -php_handler_id plesk-php74 - Suspending a domain:
plesk bin domain --disable example.com - Removing a domain:
plesk bin domain --remove example.com
Managing Email Accounts Using the Plesk CLI
The Plesk CLI offers robust capabilities for managing email accounts through the mail command. This allows administrators to create, modify, and delete email accounts, alongside managing critical email settings like passwords and storage quotas.
- Creating an email account:
plesk bin mail --create [email protected] -passwd "SecurePassword" -mailbox true - Changing an email account password:
plesk bin mail --update [email protected] -passwd "NewSecurePassword" - Listing email accounts for a domain:
plesk bin mail --list example.com - Deleting an email account:
plesk bin mail --remove [email protected]
Exploring Plesk bin Utilities and Their Usage
Plesk bin utilities are specialized executable files located in the /usr/local/psa/bin directory on Linux or C:\Program Files\Plesk\admin\bin on Windows. These utilities are designed to perform specific administrative functions and can be directly invoked from the command line, providing a powerful way to interact with Plesk’s core functionalities.
- Directory Location:
- Linux:
/usr/local/psa/bin - Windows:
C:\Program Files\Plesk\admin\bin
- Linux:
- Example Utilities: These utilities cover a broad range of management tasks:
php_handler(Linux/Windows): Used for managing PHP handlers, allowing you to configure different PHP versions for your websites.domain(Linux/Windows): Essential for comprehensive domain management, including creation, modification, and deletion.mail(Linux/Windows): Facilitates the management of email accounts, including password resets and quota adjustments.database(Linux/Windows): Provides tools for managing databases, such as creating new databases and users.
- Using Utilities: To utilize these powerful tools, navigate to the
bindirectory within your terminal and execute the utility with the appropriate options. For instance:
This particular command will display a list of all currently available PHP handlers on your server, offering insight into your current configurations.plesk bin php_handler --list
Automating Tasks with the Plesk CLI
One of the most significant advantages of the Plesk CLI is its ability to automate repetitive tasks. This can be achieved by developing scripts that combine multiple CLI commands, which are then scheduled to run automatically using cron jobs on Linux or Task Scheduler on Windows.
- Create a Script: Begin by writing a script (e.g., a Bash script on Linux or a PowerShell script on Windows) that contains the sequence of Plesk CLI commands you wish to automate.
- Example Linux Script (
backup_domains.sh): This example demonstrates a simple script to back up all domains on your server.
This script iterates through each domain listed and creates a backup of its subscription data.#!/bin/bash for domain in $(plesk bin domain --list) do plesk bin subscription_backup -d $domain -output-file /var/www/vhosts/$domain/backup.tar done - Schedule the Script:
- Linux (Cron): To schedule your script on Linux, use the
crontab -ecommand to add a new cron job. For example, to execute the script every day at 2 AM, you would add the following line:0 2 * * * /path/to/backup_domains.sh - Windows (Task Scheduler): On Windows, you can create a new task within the Task Scheduler utility, configuring it to run your script at specified intervals.
- Linux (Cron): To schedule your script on Linux, use the
- Testing: It is paramount to thoroughly test all your scripts in a controlled environment before deploying them into a live production setting. This ensures they function as expected and do not introduce unintended issues.
Frequently Asked Questions
How to find the Plesk version using the CLI?
To determine the installed Plesk version, simply execute the command plesk version within the CLI. This command will promptly display the current version details of Plesk running on your server.
How to restart the Plesk service from the command line?
On Linux systems, you can restart the Plesk service by using the command service psa restart. For Windows environments, the command plesk bin service –restart can be used within the command prompt or PowerShell to achieve the same result.
Is it possible to manage databases using the Plesk CLI?
Indeed, databases can be fully managed using the Plesk CLI through the versatile database command. This command provides functionalities to create, modify, and delete databases, as well as to manage associated database users and their respective permissions.
Conclusion
The Plesk Command Line Interface (CLI) is an exceptionally valuable and indispensable tool for efficiently managing your Plesk server. By cultivating a strong understanding of its fundamental commands and utilities, server administrators can significantly enhance their operational capabilities. This includes the power to automate routine tasks, effectively troubleshoot complex issues, and gain a more profound and comprehensive control over their hosting environment. Mastering the Plesk CLI will not only augment your server administration skills but also lead to a more streamlined and productive workflow. We encourage you to begin practicing these techniques today to unlock the full potential of your Plesk server and elevate your administrative expertise.
