HOW TO BUILD A VMWARE APPLIANCE: A CASE STUDY

Size: px
Start display at page:

Download "HOW TO BUILD A VMWARE APPLIANCE: A CASE STUDY"

Transcription

1 HOW TO BUILD A VMWARE APPLIANCE: A CASE STUDY INTRODUCTION Virtual machines are becoming more prevalent. A virtual machine is just a container that describes various resources such as memory, disk space, processor, and network card, and allocates them from a physical machine. As with a physical machine, it's the software bits (the operating system and applications) that make a virtual machine usable. When you mix a virtual machine with real software you get a virtual appliance. Virtual appliances are pre-built, ready to deploy files that contain both an operating system and in some cases, an application. These appliances can be "run" on a variety of hypervisors and allows you to view and manipulate operating systems and applications. Virtual appliances allow you to get a better look into how a software program or operating system actually looks and feels - without having to set up a complex, separate test environment. Also, these appliances provide much greater flexibility than a flash type demo that guides you through a console. Several software vendors distribute their products as ready-to-roll appliances. Additionally there are lots of Web sites that host virtual appliances of popular apps and distros. The popular place to look for appliances is VMware's virtual marketplace. A majority of the appliances listed there are available as free downloads. Drupal Appliance Drupal is an Open Source, web content management (WCM) system. It provides a simple, intuitive interface that allows an individual or a community of users to easily publish, manage and organize a wide variety of content on a website without programming skills. The Drupal Apps for Drupal lowers the learning curve a little by giving users a Drupal installation that s ready to run in just minutes allowing users to focus on using Drupal rather than getting it installed. This Drupal Apps is for the Drupal 5.x series of releases. Setting up for the Build Physical Machine The physical system used for this project is an MPC ClientPro 365, Pentium 4, 3.20 GHz, 1GB RAM, 60GB HDD with Windows XP SP3 running on it. It is important that the physical system that the appliance will be built on be a system with just basic hardware resources. This will enable the appliance to be run on both high-end and low-end machines. Appliances built on a system with high hardware resources may not easily run on machines with fewer resources. Virtual Machine VMware workstation was downloaded and installed. A virtual machine was created and Ubuntu Linux 8.04 installed. The resources assigned to the virtual machine are the basic resources needed to run Ubuntu. In this case the virtual machine had 512MB RAM and 4GB HDD. NAT was selected for the virtual machine networking. This will allow the virtual machine obtain an IP address from the network. This can be changed by users. Ubuntu was selected as the OS because it is open source and free. Using an OS from the Microsoft platform will involve some licensing issues.

2 Drupal Installation and Configuration 1. Drupal runs best on the LAMP stack (Linux, Apache, MySQL, PHP). a. Install Apache sudo aptitude install apache2 apache2-threaded-dev b. MySQL install sudo aptitude install mysql-server During the MySQL install, you will be asked for a root password for MySQL, make sure you provide one c. PHP install (including PHP5's image handling (gd) and its connection to MySQL) sudo aptitude install php5 php5-gd php5-mysql Finally, install a few packages that would allow the installation of things from PHP's PECL and PEAR repositories. This would make installing apc and xdebug far easier than doing that from source. sudo aptitude install php5-dev php-pear make 2. Optional: Install APC If this is a live server, it is recommended that you install APC to boost PHP's performance. sudo pecl install apc 3. Create a config file for it named /etc/php5/conf.d/apc.ini sudo vi /etc/php5/conf.d/apc.ini (when asked for password, enter the password for the ubuntu user account you created Put the following lines in it: extension=apc.so apc.shm_size=40

3 4. Increase the memory for PHP Ubuntu 8.04 default for PHP s maximum memory size for script is 16MB. While this is adequate for Drupal s core, installing several contributed modules will often exhaust that. It is good to start with 32MB. Edit the /etc/php5/apache2/php.ini sudo /etc/php5/apache2/php.ini Change the memory_limit line to: Memory_limit = 32M 5. Configure Apache's mod_rewrite Drupal's Clean URLs are a very useful feature. It requires the Apache mod_rewrite. a. enable the Apache module by executing this command: sudo a2enmod rewrite b. edit the file /etc/apache2/sites-enabled/000-default sudo vi /etc/apache2/sites-enabled/000-default and change this section: <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> So the line will be: AllowOverride All 6. More Apache Configuration There are a few Apache modules that are not really needed. We better disable them to save some memory. sudo a2dismod cgi sudo a2dismod autoindex We may also get better performance if we compress the HTML before we send it to the browser. For this we enable the deflate module. sudo a2enmod deflate Finally, restart Apache sudo /etc/init.d/apache2 restart

4 7. Download and Extract Drupal cd /tmp/ sudo wget Then extract the tarball cd /var/www/ sudo tar xzvf /tmp/drupal-6.2.tar.gz Move the files to the web root of the system sudo mv drupal-6.2/* /var/www And don't forget the hidden file... sudo mv drupal-6.2/.htaccess /var/www Remove the file index.html, so Drupal's index.php will be the one that is executed by Apache sudo rm index.html Then change the permissions of the directory to the user that Apache runs as: www-data sudo chown -R www-data:www-data /var/www 3. Create the Drupal database The following command will create a database for Drupal: sudo mysqladmin -u root -p create dbname sudo mysql -u root -p mysql At the mysql prompt, type the following commands: GRANT ALL PRIVILEGES ON db.* TO user@localhost IDENTIFIED BY something ; FLUSH PRIVILEGES; (You need to substitute real values for dbname, username and password) Press Ctrl+d to exit mysql when you're done 4. Installing Drupal We are now ready to install Drupal. Point your browser to the system (e.g. and you should be greeted by Drupal's installer You will need to use the following values: Database name: dbname Database user name: user Database password: something

5 Drupal Modules Every part of drupal is modular. Modules add functionality to your site. They also add lots of menu options and access control permissions. There are several modules that come with Drupal, and these are referred to as core modules. All of the other modules are known as contributed modules. Adding Contributed Modules Many contributed modules were created by the same people who maintain Drupal core, but others are not well maintained or stable. Whenever possible, it's usually a good idea to only run the released versions of a module. Use matching versions. - On the Drupal Home page - Under item 2, Enable additional functionality, select Drupal modules download section - Select a category (example CCK) - Scroll down and select a module to install and click Download. (For example, select the module Addnode) - At the opening addnode-5.x-1.2.tar.gz dialog-box, select save file and click OK - Open a terminal (Applications, Accessories, Terminal) - Type cd Desktop - Type ls (To list items on the desktop). You should see the addnode that you just downloaded. - Type sudo tar xvzf addnode-5.x-1.2.tar.gz (or any module that you downloaded) - Type ls to display the contents of Desktop again. You should see a new directory (addnote) - Type sudo mv addnode /var/www/modules - At the Drupal Home Page, under item 2, click on module list - If you scroll down, you will see Add Node Widget. Select it - Scroll down to the bottom of the page and click Save configuration Deploying The Drupal Appliance Set up a virtualized environment The drupal virtual appliance will run in a virtualized environment. If you don t already have a VMware virtualization solution installed, download either VMware Player or VMware Server for free to get your virtualization environment up and running in minutes. Find and download the drupal appliance Once you have set up your virtualized environment, find the drupal appliance. This could be stored on a server or distributed from portable storage media. After locating the drupal appliance, click on the appropriate download link or copy the appliance folder to a location on your system. Installing the Drupal Appliance Installing the drupal virtual appliance is easy. Open the drupal virtual appliance folder you just copied and find the file ubuntu.vmx. Double click on the file to open the virtual appliance (in VMware Player or VMware Server). Allow the virtual appliance to boot and go through the entire initial boot. Start your browser to begin using the appliance.