Use a launch script to configure your Lightsail instance when it starts up - Amazon Lightsail

Use a launch script to configure your Lightsail instance when it starts up

When you create a Linux/Unix-based instance, you can add a launch script that does things like add software, update software, or configure your instance in some other way. To configure a Windows-based instance with additional data, see Configure your new Lightsail instance using Windows PowerShell.

Note

Depending on the machine image you choose, the command to get software on your instance varies. Amazon Linux uses yum, while Debian and Ubuntu both use apt-get. WordPress and other application images use apt-get because they run Ubuntu as their operating system. FreeBSD and openSUSE require additional user configuration to use custom tools such as freebsd-update or zypper (openSUSE).

Example: Configure an Ubuntu server to install Node.js

The following example updates the package list and then installs Node.js through the apt-get command.

  1. On the Create an instance page, choose Ubuntu on the OS Only tab.

  2. Scroll down and choose Add launch script.

  3. Type the following:

    # update package list apt-get –y update # install some of my favorite tools apt-get install –y nodejs
    Note

    Commands you send to configure your server are run as root, so you don't need to include sudo before your commands.

  4. Choose Create instance.

Example: Configure a WordPress server to download and install a plugin

The following example updates the package list, and then downloads and installs the BuddyPress plugin for WordPress.

  1. On the Create an instance page, choose WordPress.

  2. Choose Add launch script.

  3. Type the following:

    # update package list apt-get –y update # download wordpress plugin wget "https://downloads.wordpress.org/plugin/buddypress.2.7.0.zip" apt-get –y install unzip # unzip into wordpress plugin directory unzip buddypress.2.7.0.zip -d /var/wordpress/plugins
  4. Choose Create instance.