Main Page
 The gatekeeper of reality is
 quantified imagination.

Stay notified when site changes by adding your email address:

Your Email:

Bookmark and Share
Email Notification
Project LAMP
Purpose
The purpose of this tutorial is to set-up a base LAMP server - CentOS 6.4 - in a VM environment (VMWare Workstation 9x). Once that base server is setup, you will be able to perform many things with it such as cloning it (easy task to further refine a server for a specific objective/client), not to mention making the server portable. The days of using a physical server to put LAMP on are long over and plagued with issues like dealing with failed updates, lengthy restores, non-portability, and hardware maintenance in general. A VM (one that you can clone) gives you greater flexibility and with the snapshot capability, allows you to quickly roll-back among other things.

NOTE: This is Part 1 of a larger tutorial of creating a development environment from scratch to installing Zend Server (the defacto web development platform for PHP and mobile applications). Please go to the Main Page -> Programming -> Linux for the whole series.


(Enlarge)
  1. After intalling VMWare Workstation on your computer, select "Create a new virtual machine".

(Enlarge)
  1. Since we need to make some specific changes for Amazon cloud AMI (Amazon Machine Image) compatibility, select "Custom". If you have no interest in moving or using the cloud at a future point in time you don't need to worry about this; however, if you will be, save yourself the heartache of having to build a new VM now.

(Enlarge)
  1. Select "I will install the operating system later".

(Enlarge)
  1. On the next step select "Linux" for "Guest operating system".
  2. For Version select "CentOS 64-bit" (if your system is 64-bit compatible). Don't know if your system is 64-bit compatible? There is a small utility available "VMWare 64-bit Compatibility Check" which will tell you if your system is 64-bit compatible.

(Enlarge)
  1. While I'm sure you organize your content (in this case, "\Websites\SandboxVMWareWebsites") it is important to note that VMWare will not create a new folder called "Sandbox-CentOS-64-bit" and dump all files into it so you have a directory path of "\Websites\SandboxVMWareWebsites\Sandbox-CentOS-64-bit".
  2. In this case, to preserve clear separation of VMs in the folder "SandboxVMWareWebsites", I created a folder called "CentOS6_4" and then pointed the location to that folder.

(Enlarge)
  1. Next, specify the number of processors / cores.

(Enlarge)
  1. Now select the amount of RAM; for a development VM 2048 should be sufficient.

(Enlarge)
  1. Now select the network configuration type; NAT is okay for now (you can always change it later).

(Enlarge)
  1. Hang with the recommended SCSI controller type of "LSI Logic".

(Enlarge)
  1. For the disk selection, check "Create a new virtual disk".

(Enlarge)
  1. Remember what I had mentioned earlier about compatibility with Amazon AMI? Here it is. If you want to be compatible with that, you will need to select "IDE" here; otherwise you can select "SCSI". The reason for pointing this out is due to disk bit differences.

(Enlarge)
  1. Here, specify the size of the disk (you can alter later as needed).
  2. As indicated earlier, I like flexibility, so "Split virtual disk into multiple files" is checked to make moving the VM easier.

(Enlarge)
  1. Click "Next".

(Enlarge)
  1. This is just an opportunity for review. Click "Finish" to actually create.

(Enlarge)
  1. With the VM created, let's go through a couple of Settings by right-clicking on the VM and selecting "Settings".

(Enlarge)
  1. When powering off the VM, you can have a snapshot automatically created. I prefer (since I'm not always doing something "make or break"), to be asked if a snapshot should be created or not. Its just a quick prompt that will come up and you don't have to worry about filling up your hard drive pre-maturally.

(Enlarge)
  1. Although having different OS times between the host and client are not really a bad thing (and depending on what you've got going on you have no choice), I prefer to automatically have the time syncrhonized (especially for those long debugging sessions).
  2. Now, we do not yet have VMWare tools installed (because we have no OS installed), but we can set this option now "VMWare Tools Updates -> Update automatically" which will ensure that VMWare tools on the OS is always up to date.

(Enlarge)
  1. Now let's power on the blank VM and get started with the installation of Cent OS!
  2. Unless you are exceptionally confident that a download of the Disk1 and Disk2 ISO from a location on the Internet will work (I tried several and they failed), I would recommend that you download the "CentOS-6.4-x86_64-netinstall" ISO. It will perform the bare-bones install and download everything it needs separately.
  3. You will then need to mount the ISO to a disk on your system. You may already be aware of software that would allow you to do such, but if not, a example application that does this sort of thing is called "Virtual CloneDrive".

(Enlarge)
  1. Select Install since we are, well, installing.

(Enlarge)
  1. Select to test the media. It will detect any issues with the ISO's and save you a lot of time later in the installation process.

(Enlarge)
  1. Select "Test". Don't be shy.

(Enlarge)
  1. If the test went okay, you'll continue forward and can click the button "Next".

(Enlarge)
  1. Now choose your language.

(Enlarge)
  1. Select "Basic Storage Devices" and continue.

(Enlarge)
  1. You may get a warning message. We're building this OS out inside a VM so you've got nothing to worry about. Click the button "Yes, discard any data".

(Enlarge)
  1. For the Hostname you should enter something that looks like a domain name (whether it is valid or not). In this case, because this tutorial is part of a multi-part tutorial on Zend Server, the hostname that was chosen was "localhost.zendserver" (which is not a valid domain name by syntax).

(Enlarge)
  1. The next thing will be network configuration and "eth0" the default network card. It is not needed to configure any of the network settings for this tutorial.

(Enlarge)
  1. Select your time zone.

(Enlarge)
  1. Enter the password that will be for the root account for the server. This should be unintelligible and so obscure even you would have a hard time remembering it...but you should remember it!

(Enlarge)
  1. For installation type, select "Replace Existing Linux System(s)".

(Enlarge)
  1. For the pane "Writing storage configuration to disk" select the button "Write changes to disk".

(Enlarge)
  1. Here, we FINALLY get to some of the meat-and-potatoes of a LAMP server!
  2. For the first selection area "The default installation of CentOS is a minimum install. You can optionally select a different set of software now." you can select "Web Server".
  3. While you do not need to do this now, you can check "Customize now" (at the bottom of the screen) which will give you additional options.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Assuming "Customize now" was chosen for an installation option then...
  2. This screenshot is here to show you some of the options you may or may not want to include.

(Enlarge)
  1. Once you are done going through the packages you can add on, if you click "Next" the installation process will begin.

(Enlarge)
  1. The installation process is now underway.

(Enlarge)
  1. Here you can see the packages as they get installed.

(Enlarge)
  1. If you see this then the ISO (most likely Disk1 or Disk2) was corrupted somewhere, and you'll have to start all over again.
  2. Hopefully you performed a media check and test way back at the beginning of the installation process to avoid this type of message.

(Enlarge)
  1. At the end of the installation process you should get a screen similiar to the following which indicates you will need to reboot.

(Enlarge)
  1. You'll need to login to the CentOS with the root account.

(Enlarge)
  1. If you don't end up getting the GUI (desktop environment, if you selected it), we can get it installed.
  2. Under root, enter "yum -y groupinstall kde-desktop".

(Enlarge)
  1. You'll see the progress of the desktop installation.
  2. Once completed it may be a good time to run an update, enter "yum update".

(Enlarge)
  1. There will probably be a lot of packages to update. You'll need to confirm the update.

(Enlarge)
  1. After the updates have been completed, reboot the machine.

(Enlarge)
  1. The server will shutdown, showing its progress as it goes.

(Enlarge)
  1. If the kde-desktop failed, at reboot you should get a screen similiar to what is shown here.

(Enlarge)
  1. At the root prompt, you can enter the following: yum -y groupinstall "Desktop" "Desktop Platform" "X Window System" "Graphical Administration Tools" "General Purpose Desktop"
  2. After installation has completed, and you've performed an update then enter: "startx" at the prompt.

(Enlarge)
  1. You should see the GUI desktop environment (along with a prompt that you should not be logging in as root).

(Enlarge)
  1. From within the GUI we can access "Konsole" which is similiar to "cmd" in Windows.

(Enlarge)
  1. We need to edit the inittab file, so let's use a GUI (like Notepad) for the job.
  2. Enter "gedit /etc/inittab" at the prompt.

(Enlarge)
  1. Change the run-level from 3 to 5 and then save the file.

(Enlarge)
  1. Then reboot the operating system. You can log off and reboot as well using the GUI, but you could use the existing command-line as well since the window was already open (NOTE: when you do it this way you will get an alert after reboot).

(Enlarge)
  1. Login as root and provide the password.

(Enlarge)
  1. Because you are logging in as root you'll always get this warning message.

(Enlarge)
  1. The next thing that we need to do is to create a non-super user account, so let's open up the command-line.

(Enlarge)
  1. At the prompt, enter "sudo adduser admin" and then "sudo adduser passwd". Then enter the password and reboot the system.

(Enlarge)
  1. After reboot you'll notice that the user "admin" is now able to login.

(Enlarge)
  1. Assuming you would like the admin user to be able to sudo like the root user can, you need to enter "sudo /usr/sbin/visudo" at the prompt.

(Enlarge)
  1. Locate the entry for root and essentially duplicate that on a new line. Press 'a' to insert new text and hit the ESC key when you are done - follow that with pressing the Shift key and ZZ at the same time (to save and exit). Could you have used gedit to do this instead of the more antiquated method used here? Possibly...

(Enlarge)
  1. Reboot and login as the user "admin".

(Enlarge)
  1. Go to the prompt and enter "sudo service httpd start" to see if the admin user can get Apache running.

(Enlarge)
  1. While we're at it, let's get the IP address of eth0 by entering "ifconfig eth0 | grep inet | awk '{ print $2 }'".

(Enlarge)
  1. After opening Firefox, enter the IP address. If Apache is working okay, we should see a test page.

(Enlarge)
  1. Let's return to the prompt and start up mySQL via entering "sudo service mysqld start".

(Enlarge)
  1. Let's clean up mySQL to remove "test" data that may be present. At the prompt enter "su" and then the password for the root user. After that enter "sudo /usr/bin/mysql_secure_installation".

(Enlarge)
  1. Since we've done nothing with mySQL as of yet, choose you want to set the root password, and then provide a long and secure password for the root account for mySQL. Continue following the prompts.

(Enlarge)
  1. More mySQL clean-up steps...

(Enlarge)
  1. More mySQL clean-up steps...

(Enlarge)
  1. More mySQL clean-up steps...

(Enlarge)
  1. Now let's make sure that Apache and mySQL will start at boot. At the prompt enter "sudo chkconfig httpd on" and "sudo chkconfig mysqld on". Yes, there is a GUI to perform this action as well, but we'll get into that later on with the Zend Server installation.

(Enlarge)
  1. Now it's time to focus on getting an FTP server running. At the prompt enter "sudo vi /etc/vsftpd/vsftpd.conf".

(Enlarge)
  1. In this example, allowing anonymous users is disabled.

(Enlarge)
  1. Logging has also been uncommented; this capability can be invaluable when troubleshooting or auditing.

(Enlarge)
  1. The data connection timeout is also uncommented.

(Enlarge)
  1. You can customize the welcome banner that is displayed when someone connects. In this case "Welcome to FTP. Use of this service is limited to authorized personnel only. Unauthorized personnel must disconnect immediately.".

(Enlarge)
  1. You may want to allow local users to be able to FTP to their account's local home folder on the server. If so, uncomment "chroot_local_users".

(Enlarge)
  1. You may also want to provide a default folder that user's may FTP to. In this example, uncommenting "local_root=public_html" resolves FTP users to their "public_html".

(Enlarge)
  1. Although we'll define "adminftp" in a moment (so they can access "/var/www/html"), since we have the file open, let's go ahead and uncomment the line "chroot_list_file=/etc/vsftpd/chroot_list".

(Enlarge)
  1. Since the file does not exist, cd on over to /etc/vsftpd and enter "touch chroot_list" to create a blank file that we will edit.

(Enlarge)
  1. Comment as appropriate and add "adminftp" to the file then save (hit SHIFT : and then press x) and exit (press q).

(Enlarge)
  1. At some point you'll likely need to create an account which is able to FTP, but not be a local account that can login to the server itself.
  2. In this example, a new account is created via "adduser adminftp" and "passwd adminftp". After completion you can modify that account so it cannot be used to login to the system itself via "usermod -s /sbin/nologin adminftp".

(Enlarge)
  1. Now, let's ensure that the ftp service starts when the system is booted. This is accomplished via entering "chkconfig vsftpd on".

(Enlarge)
  1. If you have a website at "/var/www/html" you may want to provide the "adminftp" user with write permissions to that location via "chown -R adminftp:adminftp /var/www/html".

(Enlarge)
  1. Perform a quick review of services that will start at system boot via entering "chkconfig --list".

(Enlarge)
  1. Once it has been verified that services will start at boot (httpd, mysqld, vsftpd) then we're ready to get VMWare tools installed.
  2. Ensure you are logged into the system as "root". Right-click on the VM and select "Install VMWare Tools".

(Enlarge)
  1. You'll notice that a disk becomes available on the system.

(Enlarge)
  1. Enter the prompt on the system. Be sure to follow VMWare KB (1018414) in this case - I found that the RPM KB is invalid for use possibly because Workstation 9x is being utilized.
  2. At the prompt, enter "cp /mnt/cdrom/VMwareTools-9.2.3-1031360.tar.gz /tmp/", then "cd /tmp" followed by "tar -zxvf VMwareTools-9.2.3-1031360.tar.gz".

(Enlarge)
  1. After the data has been extracted, at the prompt enter "cd vmware-tools-distrib" and then "./vmware-install.pl".

(Enlarge)
  1. As the script executes you really don't have any opportunity to change anything.

(Enlarge)
  1. More VMWare Tools installation script prompts...

(Enlarge)
  1. More VMWare Tools installation script prompts...

(Enlarge)
  1. More VMWare Tools installation script prompts...

(Enlarge)
  1. At completion of the installation process according to VMWare KB 1018414, the following commands were entered at the prompt (cleanup): "cd ..", "rm VMwareTools-9.2.3-1031360.tar.gz", "rm -rf vmware-tools-distrib".

(Enlarge)
  1. With VMWare Tools installed, the next thing that we could install and make life working with the mySQL database both modern and intuitive, would be to install mySQL Workbench (you can always disable or remove it later).
  2. Open Firefox on the system and navigate over to "https://dev.mysql.com/downloads/tools/workbench/" so you can grab "Red Hat/Oracle Enterprise Linux ver 6(x86, 64-bit), RPM Package (which links to "https://dev.mysql.com/downloads/mirror.php?id=412158"). You'll have to create an account at mySQL in order to download mySQL Workbench.

(Enlarge)
  1. After download, go to the prompt. If you don't already have it installed, you will need pexpect. You can get it via entering "yum install libzip pexpect".

(Enlarge)
  1. The Firefox download should be located in your account's Downloads folder so you can navigate to it and then enter "rpm -ivh mysql-workbench-gpl-5.2.47-1el6.x86_64.rpm".

(Enlarge)
  1. The installation should go by pretty quick and requires no input.

(Enlarge)
  1. You should be able to get to mySQL Workbench under "Programming" and then "MySQL Workbench".

(Enlarge)
  1. The application should start, allowing you to perform a variety of actions against the mySQL database.
  2. This also wraps up making a LAMP server from within VMWare Workstation 9x!


About Joe
Find Out Now!