Saucy Salamander Cookbook

0027-fiCanonical recently released Ubuntu Desktop 13.10, also known as “Saucy Salamander.” This article provides a recipe for building a LAMP (Linux, Apache, MySQL, PHP) development environment on Ubuntu Desktop. We’ll also install OpenJDK and the NetBeans IDE. The entire environment will be housed in a VirtualBox VM running on Windows 7. We’ll finish up by cloning the VM for a particular project.

The following components will be installed:

  • Oracle VirtualBox 4.3.4
  • Ubuntu Desktop 13.10
  • Apache HTTP Server 2.4.6
  • PHP 5.5.3
  • MySQL 5.5.34
  • phpMyAdmin 4.0.6
  • MySQL Workbench 5.2.47
  • OpenJDK 1.7.0
  • NetBeans IDE 7.1

Ingredients

  1. Download VirtualBox. Download the latest version of VirtualBox from virtualbox.org. Click the Downloads link in the left menu. Click the x86/amd64 link beside VirtualBox 4.3.4 for Windows hosts. Save the installer in a convenient location.
  2. Download Ubuntu Desktop. Download the latest release of Ubuntu Desktop from ubuntu.com. From the menu, choose Download→Desktop, select 64-bit from the drop-down, and click the Ubuntu 13.10 button. Contribute to the effort or select the Not now, take me to the download link. Save the ISO file (ubuntu-13.10-desktop-amd64.iso) in a convenient location.

Preparation

  1. Install VirtualBox. Run the VirtualBox installation program downloaded earlier. On the Setup Wizard Welcome screen, click Next. Confirm the installation location and click Next. Decide if you want shortcuts and to register file associations and click Next. Click Yes and then Install to install the software. Click Finish to complete the installation.
  2. Create the VM. Start VirtualBox and create a new virtual machine by clicking the New button in the toolbar. Give it the name Ubuntu Desktop 13.10 Master, select Linux in the Type dropdown, and Ubuntu (64-bit) in the Version drop-down. Set the memory size to 2048 MB. Elect to create a virtual hard drive now with a hard drive type of VDI, dynamically allocated with default filename and location, and a size of 20GB. Start the virtual machine by selecting it and clicking the Start button in the toolbar. Select the ISO file that you saved in the Ingredients section as the startup disk.
  3. Install Ubuntu. When the installer starts select your language and click the Install Ubuntu button. Select Download updates while installing and Install this third-party software. Leave the Erase disk and install Ubuntu radio button selected and click Install Now. Select your timezone and keyboard layout. Enter your name, computer name, password, and email address. Click the Log in later button. After the installation restart the VM and press Enter when prompted.
  4. Install Guest Additions. Log in to Ubuntu and select Devices→Insert Guest Additions CD Image… from the VirtualBox menu. Click the Run button, enter your password, and click Authenticate. Restart the VM to enable Guest Additions.
  5. Create a VM Snapshot. If you would like to have the option to roll back the VM to this point, you can create a snapshot. Exit from all applications, shutdown the VM, select the VM from the VirtualBox Manager, and click the Snapshots button. Click the camera icon and give your snapshot a name, such as Ubuntu Desktop with Guest Additions. You can also enter a description if you like. Restart the VM and log in to Ubuntu.
  6. Install Apache HTTP Server and Documentation. In a Terminal window enter the command:
       sudo apt-get install apache2 apache2-doc
  7. Install PHP 5. In a Terminal window enter the command:
       sudo apt-get install php5
  8. Install MySQL Server. In a Terminal window enter the command:
       sudo apt-get install mysql-server
    Enter a password for the root user when prompted.
  9. Create Another VM Snapshot. You might want to create another snapshot at this point with a name such as Ubuntu Desktop with Guest Additions and LAMP Stack.
  10. Install phpMyAdmin. In a Terminal window enter the command:
       sudo apt-get install phpmyadmin
    Select apache2 when prompted to choose the web server which should be automatically configured to run phpMyAdmin. Select No when prompted to configure a database.
  11. Install MySQL Workbench. In a Terminal window enter the following command:
       sudo apt-get install mysql-workbench
  12. Install OpenJDK. In a Terminal window enter the command:
       sudo apt-get install openjdk-7-jdk
  13. Install NetBeans. From within the VM launch Firefox and navigate to netbeans.org. Click NetBeans IDE and then Download. At the bottom of the All column click Download. When the dialog box displays, select Save File and click OK. In a Terminal window change to the Downloads directory (in your home directory) and enter the following commands (substitute the filename for the actual name of the file that was downloaded):
       chmod u+x netbeans-7.4-linux.sh
       sudo ./netbeans-7.4-linux.sh
    When the NetBeans installer starts click Next. Accept the terms and conditions and click Next. Do the same for JUnit and click Next. Accept the default directories and click Next (twice). Leave Check for Updates selected and click Install. Click Finish.
  14. Create Another VM Snapshot. You might want to create another snapshot at this point with a name such as Ubuntu Desktop with Guest Additions, LAMP Stack, and Development Tools.

Season to Taste

I like to tweak the environment a little for development. Choose whichever tweaks you like and disregard the rest.

  1. Reduce Launcher Icon Size. I’m usually developing on a laptop so I like to reduce the size of the icons in the Launcher. Click the gear icon in the upper right corner of the workspace. Select System Settings. Click the Appearance icon. Next to the Launcher icon size drag the size all the way to the left (or whatever size you like).
  2. Enable Workspaces. Ubuntu Desktop provides a feature to allow four virtual desktops. I usually have a Terminal window and file manager on one of the desktops, a Firefox browser in another, and NetBeans in a third. If I’m documenting some process I might have a LibreOffice application running in the fourth desktop. Click the Behavior tab at the top of the Appearance dialog. Check the Enable workspaces check box. Dismiss the dialog box. The Workspace Switcher will be shown in the Launcher. Click it and select a virtual desktop.
  3. Reduce the Terminal Text Size. You can adjust the font used for text in the Terminal application. I like to make the text smaller so that I can see more output before scrolling. In the Terminal menu select File→New Profile… Enter Small text in the Name box and click Create. Uncheck Use system fixed width font. Click the Font button and change the size to 8 or whatever you like. Click Close. Right-click on the Terminal window and select Profiles→Small text.
  4. Lock Terminal to the Launcher. You can lock icons for applications that you use often to the Launcher. Right-click on the Terminal icon in the Launcher. Select Lock to Launcher from the menu.
  5. Start Firefox. Click the Workspace Switcher in the Launcher. Select one of the unused workspaces. Click the Firefox Browser icon.
  6. Change Ownership of the Document Root. In order to easily deploy NetBeans projects to the Apache HTTP Server, change the owner and group of the /var/www directory to your username and group with the command below:
       sudo chown $USER:$USER /var/www

Taste Test

We’ll now do a quick test of each of the components.

  1. Test Apache. In the browser, enter the URL http://localhost in the address bar. You should see the It works! page.
  2. Test Apache Documentation. In the browser, enter the URL http://localhost/manual in the address bar. You should see the Apache HTTP Server Version 2.4 Documentation page.
  3. Test PHP. Create a new file in /var/www called phpinfo.php containing the following script:
       <?php phpinfo(); ?>
    Enter the URL http://localhost/phpinfo.php into the browser. You should see the PHP information page. This also tests the integration of PHP with Apache.
  4. Test MySQL. In a Terminal window type:
       mysql -u root -p
    Enter your MySQL root password when prompted. At the mysql> prompt type show databases; You should see a list of the four databases created during the installation: information_schema, mysql, performance_schema, and test. Type quit; to exit.
  5. Test phpMyAdmin. Enter the following URL into the browser: http://localhost/phpmyadmin. Enter your MySQL root password and click Go. You should see the phpMyAdmin home page.
  6. Test MySQL Workbench. Click the Dash icon at the top of the Launcher. Type mysql into the search box. Click the icon for MySQL Workbench. You should see the main screen. Click New Connection. Click the Test Connection button. Enter your MySQL root password and click OK. You should see the message Connection parameters are correct. Click OK, then Cancel. Lock MySQL Workbench to the Launcher if you like. Select File→Exit to exit from MySQL Workbench.
  7. Test NetBeans IDE. Click the Dash icon at the top of the Launcher. Type netbeans into the search box. Click the NetBeans IDE 7.4 icon. The IDE should launch. Lock NetBeans IDE to the Launcher if you like. Select File→Exit to exit from NetBeans.

VM Cookie Cutter

We’ll use the VM created in this article as a template from which we’ll clone identical copies to use for various projects. Like a cookie cutter, the VirtualBox Clone VM feature can be used to to stamp out identical, but independent, VMs. As an example, let’s create a VM clone to be used for an upcoming PHP Tutorial series.

  1. Exit from all running applications such as Terminal, Firefox, MySQL Workbench, and NetBeans.
  2. Shutdown the VM by clicking the gear icon in the top-right corner of the desktop and selecting Shutdown from the menu. Click the Shutdown button to halt the OS and shut down the VM.
  3. From the VirtualBox Manager interface select the Ubuntu Desktop 13.10 Master VM you just created by clicking its name.
  4. Select Machine→Clone… from the menu
  5. Enter PHP Tutorial in the Name field of the Clone Virtual Machine dialog. Click Next.
  6. Select Full Clone as the Clone Type and click Next.
  7. Since we have no need to preserve the snapshots we created in the master, select Current machine state and click Clone.

You now have a complete copy of your master VM. You can create as many cloned VMs as you need for particular projects. If you want add some feature to all of your future clones, create a new snapshot in the master VM and make the change there. Subsequent clones will include the new feature.

In this article we created a development environment running on the Ubuntu 13.10 Desktop (aka Saucy Salamander). We installed a LAMP stack consisting of the Apache HTTP Server, MySQL, and PHP. We also installed some development tools including phpMyAdmin, MySQL Workbench, and NetBeans IDE. We then made a few tweaks to the desktop environment to facilitate software development and tested each of the components. The entire environment is installed within a VM managed by VirtualBox. Finally, we demonstrated the VirtualBox VM cloning feature by making an identical copy of the VM for a particular project.

Speak Your Mind

*