AutoWordPress with Plesk

This tutorial was originally designed for Plesk 12.5 but is fully compatible with Plesk Onyx!

Undoubtedly you know how to quickly install WordPress (or whatever application) with Plesk, and can educate your customer how to do so.

Let us count the mouse clicks it takes:

  1. Click “WordPress” in Featured applications menu.

 

1

 

 

 

 

 

 

 

 

 

2. Click “Install”.

2

 

3. Hmm… This is actually it. It is fully working with only 2 clicks.

 

3

 

 

 

 

But what if you want to skip pressing any buttons and just give your customers what they want automated? Then we’ve got something for you:

How to automate WordPress installation for new domains

 

We need something to be triggered when the domain is provided by Plesk. As a trigger I used a “physical hosting created” event handler – http://docs.plesk.com/en-US/12.5/administrator-guide/server-administration/event-tracking/event-parameters-passed-by-event-handlers.67897/#o67985. When I tried with “domain created” I came across “unable to find resource” errors – which is quite correct generally speaking, as the domain can be a forwarding page with no real hosting resources underneath. So the “physical hosting created” is our choice for triggering WordPress installation. In the event handler parameter put a script to be executed with root permissions. Let’s assume the script name is domain-created.sh:

 

4

 

A foreword on business logic: In a general scenario we may not want to work with WordPress for every single new domain, but just some of them. The easiest way to say what domain should have WordPress and vice versa is to create 2 service plans. My service plan for WP-enabled domains is called WordPress auto. Essentially it is a clone of a Default domain plan, we just need a distinguishable name here. Of course you are free to limit databases, because as long as it’s a WordPress plan, it’s unlikely more than one database will ever be needed, as well as other things.

And now to the script.

DISCLAIMER: Although the script below was tested and proven to work, the author cannot guarantee its proper functioning on every server or every OS. Under no condition should one copy and use the script on production servers without proper testing, analysis and accommodating for specific conditions. This article it intended to provide you with an idea of how cool things can be with Plesk, rather than a ready-made solution.

Some logging is commented out, as I got feedback it might be insecure to store passwords in plaintext in the handler log.

How it works

 

Create a subscription on WordPress plan.

 

5

Check to see if WordPress instance has been provided:

 

6

 

Yes, sir! It worked.

 

As you can see, my new installation comes without yellow exclamation marks saying “Update is available”, which indicates we indeed installed the latest version.

 

So that’s it, folks. Hope you’ve enjoyed this tutorial. Next time we’ll be looking at how to automate Joomla and an e-commerce app. Stay tuned!

Vladimir Samukov -Senior sales engineer.

Ping me if you need to integrate Plesk into your in-house billing or prepare an image to deploy 300000 VMs on your IAAS platform.

I am the one who Plesks.

  • This looks great!

    Does the event handler trigger when a domain is created using the plesk bin cli tools?

    I’m trying to setup a bash script to create a customer, add a domain and then add a wordpress instance…

    It doesn’t seem to work using the event handler. Nothing shows in the /tmp/event_handler.log file.

    Suggestions?

  • Finally I got my problem solved here !
    Man… Thanks A Ton !

  • sander

    get the following error on ssl -false:

    Unknown option ‘false’: /usr/local/psa/bin/aps –install /tmp/template1.xml -package-id 3 -domain -ssl >>>false<<< -url-prefix wordpress -db-name wp_PN2XVt -db-user admin_UYo_xT -passwd y_V%fRaa_

    Try to fix it 🙂
    keep you posted

    But nice script !!

    gr Sander

  • sander

    First of all, nice script!
    Did all of the above, but the domain is created without wordpress.. it gives me the error about the false or true option in -ssh.

    Unknown option ‘true’: /usr/local/psa/bin/aps –install /tmp/template1.xml -package-id 3 -domain -ssl >>>true<<< -url-prefix wordpress -db-name SOME-DB-NAME -db-user SOME-DB-USER -passwd SOME-DB-PASS

    exit status 1
    Finished installing WordPress for domain
    Notifying user of successful installation
    ————–

    Can you help me a bit, to get this awsome script going ?
    thnx

    Sander

    • Vladimir Samukov

      Hi Sander!

      Make sure your Plesk has WordPress in its application vault (Tools & settings -> Application vault -> My Apps)

      • sander

        Hi Vladimir,

        Shoot, how to forget that.. thanx!
        Site’s created but not with WP, will look further for this issue.
        Nevertheless, script is thumbs up !!

        Keep you posted and thnx again!

        gr Sander

  • Now you can do the same things using our new Plesk extension: https://ext.plesk.com/packages/0e5e13ad-98ad-4e2e-9648-462fa8ba84d2-aps-autoprovision

    It also allows to install Joomla and Drupal.