Use a launch script to configure your Amazon Lightsail instance when it starts up
Last updated: October 16, 2017
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 useapt-get
. WordPress and other application images useapt-get
because they run Ubuntu as their operating system. FreeBSD and openSUSE require additional user configuration to use custom tools such asfreebsd-update
orzypper
(openSUSE).
Example: Configure an Ubuntu server to install Node.js
On the Create an instance page, choose Ubuntu on the OS Only tab.
Scroll down and choose Add launch script.
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.Choose Create instance.
The following example updates the package list and then installs Node.js through the
apt-get
command.
Example: Configure a WordPress server to download and install a plugin
On the Create an instance page, choose WordPress.
Choose Add launch script.
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
Choose Create instance.
The following example updates the package list, and then downloads and installs the BuddyPress plugin for WordPress.