C4946555a907b03826e1a87a259f5c35cb6f6a6c
By:
saleeh

Wordpress image with custom plugin pre installed

November 25, 2016 88 views
WordPress Ubuntu

Hi all, I am just wondering how to create a custom image that I can share in public with the following things pre-installed.

My use case is that to create an e-commerce site with Woocommerce and an app with Appmaker.xyz .
So that whoever need to setup an e-commerce website and an App with simple steps

4 Answers

You can create a snapshot and send it to users who need it. That's not enough public.

The thing you probably want is User Data - Cloud-Init scripts.
How To Use Cloud-Config For Your Initial Server Setup.
An Introduction to Cloud-Config Scripting.
DigitalOcean User Scripts Library.

For further questions feel free to ask.

A cloud-config file is a special script that is used to define configuration details for your server as it is being brought online for the first time. These are often used for completing common tasks that a user would normally have to log into the server to accomplish. In this guide, we will run through how to do some initial configuration of an Ubuntu 14.04 server using a cloud-config file with our metadata service.
  • @xMudrii Thanks for your quick response, I was looking to make it even easier for users. It will be great if users can add custom images. And other can use it easily

    • You can send your idea to DigitalOcean via their UserVoice page.

      I found out that it was already suggested but it didn't receive positive feedback. Custom One-Click Image is idea you're looking for.
      But yea, problem stated there is that you can't know is image malicious or not. You can build up image and ship with virus or some type of backdoor. That's a big problem and I think it's better without it.

      Cloud-Init script makes it easy. You see what you execute on your sever, in plain text format and it's pretty easy to understand it. Also, it's easy to share it - GitHub, GitHub Gist, whatever you want.

      • Thanks for UserVoice,
        I understand that. It will be great if we can do that like a Dockerfile

Hey @saleeh I'd suggest introducing configuration management to achieve this. Try out packer.io . It's basically a "tool for creating machine images with pre-configured operating systems and installed software from a single source configuration". DigitalOcean has a great tutorial on setting it up: https://www.digitalocean.com/community/tutorials/how-to-install-and-get-started-with-packer-on-an-ubuntu-12-04-vps

When you get into it, packer has more provisioners other than shell for installing and configuring software. Go through the tutorial first to get what I'm talking about here. For example see how I use this ansible provisioner to install software on the machine:

{
  "builders": [{
    "type": "digitalocean",
    "api_token": "YOUR API TOKEN",
    "region": "nyc3",
    "size": "512mb",
    "image": "ubuntu-14-04-x64"
  }],

  "provisioners": [{
   "type": "ansible",
    "playbook_file": "standard.yml"
    ]
  }]
}

It references an ansible playbook: standard.yml which goes through a list of system packages to install that are listed in the vars.yml file.

standard.yml

---
- hosts: all
  vars_files:
    - vars.yml
  tasks:
    - name: Installs required system packages listed in the vars.yml file
      apt: pkg={{ item }} state=installed update_cache=true
      with_items: "{{ system_packages }}"

vars.yml

---
system_packages:
  - apache2
  - git
  - mysql-server
  - php5-mysql
  - php5
  - libapache2-mod-php5
  - php5-mcrypt
  - unzip
  - zip

command:
  - mysql_install_db
  - mysql_secure_installation


Now all you need to do is share this configuration file that anyone can run to create an image on DigitalOcean with your custom setup. Please share if you do :)

by danny.sipos
In this tutorial we will see how to install and get started with Packer on an Ubuntu 12.04 run VPS.

@xelawafs Thanks for your response. Actually, I am looking even simpler solution. Maybe in future digitalocean will support that

Have another answer? Share your knowledge.