Once we are done with the initial installation of JeOS and our virtual machine is now waiting with a login prompt, we now have to prepare our operating to accommodate our application. It is generally a good time to make a snapshot of your clean VMware image, so that if a mistake is made later on, it will be possible to revert to a blank page without having to reinstall everything.
The very first thing to do after install of the system is to check that it is up to date. This is done by running:
sudo apt-get update && sudo apt-get upgrade
VMware Tools will allow to have a better control of our appliance by the VMware environment, so it is a pretty good idea to set it up.
-
First setup our environment by installing the build tools:
sudo aptitude install build-essential linux-headers-$(uname -r)
-
Next ask VMware to mount the VMwareTools CD by clicking on VM > Install VMware Tools… in the VMware Server menu.
-
Mount the cdrom:
mount /media/cdrom0
-
Copy the tools to the tmp directory and uncompress them:
sudo cp -a /media/cdrom0/VMwareTools*.gz /tmp/ cd /tmp/ sudo tar -xzvf VMwareTools*.gz
-
Run the vmware-install.pl script accepting all the defaults:
cd vmware-tools-distrib/ sudo ./vmware-install.pl
Also available for VMware is the open-vm-tools package, an Open Source implementation of VMware Tools. If using KVM at this time there is no equivalent package, however.
To install open-vm-tools from a terminal prompt enter:
sudo apt-get install open-vm-tools
In this example we will be installing a very simple application consisting of a web page that accesses a MySQL database. We will therefore require our OS to provide us with:
-
Apache
-
PHP
-
MySQL
Which is in the end a basic LAMP stack that we will pull in one single step using the apt-get command:
sudo tasksel install lamp-server
Note that at this point we could easily install any additional packages that we might need using, for example, the aptitude command line utility. |
Once we are done installing our base packages, it is another good time to do a snapshot our virtual machine. We also can save the intermediary steps by doing a full copy of the virtual machine by issuing the following command on our host after powering it down (you will have to adapt it to your particular environment):
cp -rf /var/lib/vmware/Virtual\ Machines/JeOS /var/lib/vmware/Virtual\ Machines/JeOS-basePackages/
-
OpenSSH
Another convenient tool that we want to have on our appliance is OpenSSH, as it will provide our admins to access to access the appliance remotely. However, pushing in the wild an appliance with a pre-installed OpenSSH server is a big security risk as all these server will share the same secret key, making it very easy for hackers to target our appliance with all the tools they need to crack it open in a breeze. As for the user password, we will instead rely on a script that will install OpenSSH the first time a user logs in so that the key generated will be different for each appliance.
However, it might be simpler during the set-up to access our appliance using ssh, so we still install it at this time, but we will need to make sure that fully removed by the time we ship our appliance, which is described in the last part of this tutorial. To install it, simply run:
sudo apt-get install openssh-server
-
MySQL
When we ran apt-get to install the lamp-server^, the only question we were asked was to provide a default password for MySQL. It would not be wise to have all our deployed appliances to use the same password, so we will have to have it changed as well the first time a user logs in our appliance.