Have you ever wanted a feature in Plesk that doesn’t exist yet? Or do you want to earn some money by selling a really valuable Plesk Extension to thousands of Plesk users? In this article, you will learn how to quickly code your first extension for Plesk and adapt it to your needs. And if you do this Open Source – even better! This will help others to contribute and make your new extension really stand out.
I will cover all aspects, beginning with installing Plesk locally, setting up your development environment, writing your first extension and submitting it to the official Plesk Extension Catalog.
Every part will contain tips and tricks and related links. Additionally, I will create a short screencast for each part of the series that will make it easier for you to dive into this topic. I hope you enjoy coding your first Plesk Extension and I’m looking forward to receiving your feedback!
Part 1 – Install a local version of Plesk
Note: I’m using a Mac OS as my development system. If you are using a PC with Windows, then some parts of the tutorial could potentially differ.
What do we need to run a Plesk instance locally?
- Plesk ISO image
- Virtual Box to run the image
- Plesk license key
First of all, we will download a Plesk ISO image from here. On this page you will also find a form to request a free trial license key. We will need the license key later once Plesk is configured properly to run on our local machine. You can already request the license key in this step as long as the ISO image is downloaded.
Look at the bottom of the page for the ISO images. We take the Ubuntu 14.04 64-bit with Plesk 12.5 image for our local development constellation. This is the latest, stable version that is available at the moment. There will be updates of Plesk frequently, so you should take the latest available version that is offered on this page. The ISO image always tries to install the latest available stable Plesk version, this means that Plesk Onyx will be installed with the Plesk 12.5 image. If you encounter issues with this image, feel free to try another one, preferably an Ubuntu image because we will use this Linux distribution throughout our complete tutorial.
Our next step is to download and install the software Virtual Box. Virtual Box by Oracle is a free virtualizer (virtualization application) that makes virtualization (e.g. running multiple operating systems) possible on our local machine. Go here and download the latest version for your operating system. In my case I opted for the OS X version.
Configure the network settings of the virtual machine properly
After the successful installation of Virtual Box, we need to configure the global and (later) local Network settings to be able to communicate with the virtual machine via the browser and SSH. Open the global
Preferences and select the button
Network. Select the Host-only Networks tab and click on the
+ symbol. You will see a new entry
Click on this entry. The IP address will be pre-configured to a private IPv4 address space. The Host-only networking setting provides connectivity among virtual machines and the host (your machine). For the connection of the virtual machine to the web we will use the so-called Network Address Translation (NAT) adapter.
Note: You don’t need to add a NAT network, it is sufficient to attach the virtual machine to the NAT adapter. I will explain it later once we’ve created our virtual machine with the Plesk image. For more information to the networking modes, please see this.
To create our local development image, we click on the
New button, enter the name of the machine, select the correct type and version of the operating system. In my case, it is Linux and Ubuntu (64-bit). Click through the creation process with your preferred settings to the end. When the virtual machine was created successfully, you will see a new entry in the list of available machines.
Set the correct Port Forwarding rules for your image
Don’t start the machine yet but select it and click on
Settings. In the settings go to the
Network tab, then the
Adapter 1 tab and select the checkbox
Enable Network Adapter. Under
Attached to you select NAT. Afterwards, click on
Advanced and then the
Port Forwarding button. Here we will define the port rules which are important to access the virtual machine via the browser and SSH. For instance, we can set the first rule to
Host Port 2225 and Guest Port 22 (for SSH), a second rule to
Host Port 80 and Guest Port 80.
You should map all required ports:
443, 8443, 8447 and 8880 (see screenshot). For all rules we select the TCP protocol.
After the network is configured, start the virtual machine. In the first run, you will be asked for the image to boot from. Select the Plesk ISO image and finish the installation process of the operating system. Please define the username and password that you want to use for the root user. This is important because we will utilize this user to access the machine via SSH. Be patient, the installation process takes some minutes.
Tip: Use your own Terminal (such as iTerm) to manage the virtual server by using SSH.
Connect the virtual machine once it was booted with:
$ ssh [email protected] -p 2225
Replace NAME with the username that you’ve defined during the installation process and the port that you’ve mapped in the Virtual Box image settings.
Don’t interrupt the installation process of Plesk after first boot
After the first login into the virtual machine, you have to wait until Plesk was installed completely. Remember not to interrupt the installation process, or else you will have to recreate the complete virtual machine. The progress of the installation is documented in a special log file.
To see the status, you can type:
$ sudo tail -f var/log/plesk/install/autoinstaller3.log
in your terminal. Now it’s time to get a coffee as this can take a while! You will see a
Congratulations message after the installation and you can verify it by typing:
$ plesk version
into the console. You should see some information such as the product version, build date or the OS version. The default username is
admin, to retrieve the password of your Plesk instance, use for Plesk Onyx:
$ plesk login
$ plesk bin admin --get-login-link // alternative call
and for Plesk 12.5:
$ sudo plesk bin admin --show-password
--show-password command is no longer available in Plesk Onyx due to security reasons. In Plesk Onyx you will get a URL with a secret key (https://domain:8443/login?secret=X) which will allow you to log in to the Plesk instance and set an own password.
Note: For help on password retrieval, go here.
Check the correct installation of Plesk in your browser
We are almost there! Now open your browser and type the address
http://localhost:8880 into the address bar (use the port that you’ve defined in the NAT forwarding rules!). If you did everything properly, you will see the login screen of Plesk. Login with the default credentials, accept the license and select the type
Power User. The last step is to enter your (trial) license key and you are ready to go!
In the next part of the blog series I will show you how to create a default Plesk extension as a starting point of the development, add this extension into your IDE (we will use the great IDE PhpStorm), sync it with the copy that runs in the local Plesk instance and add auto-completion to make our life easier.
Ready for Part 2? Create extension stub and IDE project