Pages

Setting Up A Virtual Linux Web Server : The VMware Server

I started as a webmaster about 13 years working for a small ISP which mainly hosted websites on Linux boxes. At that time, a 128 Kb ISDN link was enough to feed about 5 servers running about 100 websites. Most residential Internet users were connecting through those hot 14,400 bps modem that just came out. The sky was the limit.
Today, I’m still managing a handful of web servers, probably not as many as I once did. Still, most of them are running Linux and I’ve got maybe 2 or 3 web servers running on Windows and IIS. Nowadays, I’m more into dynamic website development. There isn’t a day that I don’t need to test different configurations whether it is to test new versions of PHP, Apache or MySQL or simply to optimize server performance.
As you’ve probably experienced before, testing out new technologies may compromise your server’s stability and performance. That’s where testing servers come in handy. The thing is that you may not have a bunch of computers waiting to be reinstalled over and over just for that purpose. This is why we are going to install our own web server running on a virtual Linux box hosted on a Windows plateform.

Getting VMware Server

Now you can get VMware server for free and it’s a full version! Totally legal! How cool is that? At the time of writing this post, the latest VMware server version is 1.0.3. You can get it here :
 http://register.vmware.com/content/download.html
or you can try this direct link to the binary file :
http://download3.vmware.com/software/vmserver/VMware-server-installer-1.0.3-44356.exe)
Before you go any further, please note that you will need a truckload of resources to run a virtual server, mostly RAM. I run an Intel Dual Core 1.8 Ghz computer with 2 Gb of RAM and 250 Gb of hard disk space.
Now that you’ve downloaded VMware Server, launch the installation and select the custom setup type. When asked to specify what features to install, you may want to disable the “VMware Management Interface”.
vmware-custom-setup-1.jpg


Why? Because this installs a web application through which you can manage your VMware server. Now this may not be a problem but you’ll need IIS to be installed and running if you want that option. For my part, I prefer using the GUI provided with the installation as I already got an Apache HTTP server running locally on my host machine and I don’t want to mess that up. You can pretty much leave all other setup options to default.
The VMware setup will install a virtual NIC (Network Interface Card). You may want to keep that in mind if you eventually run into network problems with other applications such as a VPN or a software firewall.
When done installing, reboot your computer and voila! A brand new VMware server on your PC.
Come back soon as we will continue the installation of our virtual Linux web server.

Note : I am running a french version of Windows so the screenshots may show some french labels.
Now that you’ve got your VMware server running, let’s prepare it to install CentOS 5. This is my favorite free Linux distribution because it’s derived from RedHat’s Enterprise Linux (RHEL). Therefore, it is really easy to find packages and documentation.
Start by launching the VMware Server Console and select Local Host.
vmware-new-virtual-machine-setup1.jpg
Click on New Virtual Machine from the main screen and select the Typical machine configuration. When asked about the guest operating system, select Linux and Red Hat Enterprise Linux 4 as CentOS is not available.
vmware-new-virtual-machine-setup21.jpg
Now enter your virtual machine’s name (this is just for the purpose of managing your virtual machines and will not appear anywhere in the OS’ configuration). You must also specify where the virtual disks will reside. Please note that having a dedicated partition or better, a dedicated hard drive, to store the virtual drives may increase performance significantly.
vmware-new-virtual-machine-setup3.jpg
Select the type of network connection that will be made available for your virtual machine.
vmware-new-virtual-machine-setup4.jpg
For my part, I use « Bridge Networking » as my virtual machine will have an IP address on the external network because I want it to be accessible to my LAN. If you want your virtual machine to be accessible only from your host, you can use « Host Only Networking ».
Now for the virtual hard drive, specify how much space is needed.
vmware-new-virtual-machine-setup5.jpg
Don’t worry about disk space as you will be able to increase later if needed. Make sure you check « Allocate all disk space now » otherwise the file’s size will increased as it’s needed and performance will be affected. You could also choose to split the virtual disk into 2 GB files if more performance is needed.

Note : I am running a french version of Windows so the screenshots may show some french labels.
Now that your VMware server is installed and that your virtual machine is ready, let’s install CentOS 5. First of all, you will need to download the six ISO images from http://www.centos.org. At the time of this writing, I’ve downloaded the images from http://ftp.telus.net/pub/centos/5.0/isos/i386/
It is not necessary to burn all those images on CD as VMware can map a virtual CD to an ISO image.
First, let’s click on Edit virtual machine settings from our Red Hat Linux tab.
vmware-installing-centos5-1.jpg
We need to map the virtual CD drive to the first CentOS ISO image.
vmware-installing-centos5-2.jpg
Next we will be giving a little more RAM to our virtual machine. Let’s upgrade it to 512 MB.
vmware-installing-centos5-3.jpg
When done, click OK and start the virtual machine so it will boot from the virtual CD.
At the startup screen, simply press Enter to install in graphical mode.
vmware-installing-centos5-4.jpg
The next steps are really not technical so I’ll go over them quickly. These are the values I’ve selected but feel free to set your own selection if appropriate.
  • Testing Media CD Before Installation : Skip
  • Language to use during the installation process : English
  • Select the appropriate keyboard for the system : U.S. English
The installer will then tell you that the partition table on device SDA is unreadable and will offer you to initialize the drive. Answer “Yes”.
When asked about partitioning the hard drive, simply select “Remove linux partitions on selected drives and create default layout”.
vmware-installing-centos5-5.jpg
Here are some other settings I will quickly go through :
  • Network Devices : DHCP (you can set a static IP address if you prefer)
  • Hostname : automatically via DHCP
  • Miscellaneous Settings : nothing to set unless you’ve set a static IP address.
  • Timezone : America/New_York
  • Root Password : set it to whatever you want the root password to be.
Now for the default installation packages, I’ve just checked the “Server” checkbox as the “Desktop – Gnome” was already selected.
vmware-installing-centos5-6.jpg
If that were to be a full blown production server, I would’ve took the time to set the right package selection but this is only a test server so I won’t spend time on this. Now the installer will verify package dependencies, format the hard drive and then proceed to installation so that leaves you time to get a coffee (or two).
When asked to insert another disc, double-click on the cdrom drive icon at the bottom-right corner of the VMware window. Select the required ISO image and click OK.
vmware-installing-centos5-7.jpg
You should be done installing by the fifth CD (depending on if you’ve selected some other packages). Now reboot your virtual machine, there is still some configuration to do.
vmware-installing-centos5-8.jpg
Here are the settings I’ve used :
  • Firewall : I’ve disabled it since this test machine doesn’t need that much protection.
  • SELinux : Enforcing
  • Date and Time : Self-explanatory
  • Create User : Create a user account
Click “Next” until you’re done. You can now log on your brand new CentOS server with either your root or personnal user account.
Come back soon for more information on how to setup Apache, PHP and MySQL!

It’s been a little while since I posted part 3 of this tutorial so let’s get this thing going. At this point we have a Linux CentOS 5 server running. Now we need to install and configure all the major web services : Apache, PHP and MySQL.
For the most part of this article, I will be using the command line interface through SSH and not the default GUI (Gnome). You can download putty.exe, an SSH client, at http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Starting Apache Web Server
If you followed the previous parts of this tutorial, Apache 2.2 should be installed by default. You only have to make sure the service is started at boot time. To ensure that the httpd service is started automatically, type : chkconfig httpd on . This will add the httpd startup / shutdown scripts in the proper directories.
Now even though we configured the httpd service to start automatically, it is not started unless you rebooted the server. Simply type “service httpd start” to launch the Apache web server.
To make sure the web server is running, open a web browser on your host system (ie. not on your virtual machine) and try to access http://[your virtual machine’s ip]. If you don’t know your virtual server’s ip address, type “ifconfig” at the command prompt. If the web server is installed correctly and running, you should see a “Apache 2 Test Page”.
Installing MySQL Database Server
Great we now have a web server running so let’s install our database server. Again we’ll be using YUM to install MySQL so issue the following commands :
# yum update yum
# yum –y install mysql mysql-server
When the installation is completed, launch the MySQL server service by issuing : service mysqld start
We also want that service to be launched automatically so type the following command :
# service mysqld start
Now that we have our MySQL server running, let’s set the password for the root user :
# mysqladmin –u root password ‘new password
# mysqladmin –u root –p –h your_hostname password ‘new password
Installing PHP
At the command prompt, simply issue:
# yum –y install php
The PHP version available at the time of this writing is 5.1.6.
Now let’s restart the httpd service:
# service httpd restart
We’re now going to test our PHP installation. Create a new file named “index.php” into the folder /var/www/html. In that file, simply copy the following line :

Now again, open a web browser at the address http://[your virtual machine’s ip] and you should see PHP’s information page :
PHP Info Page
Well that’s about it, you got yourself a virtual CentOS 5 web server. I will not go into details about how to configure Apache, MySQL, PHP or even hardening your Linux box but stay tuned for more tutorials on the subject.




 For More Check Related Links :

0 comments:

Post a Comment