<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ray Heffer &#187; Linux</title>
	<atom:link href="http://www.rayheffer.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rayheffer.com</link>
	<description>Enterprise Technologies</description>
	<lastBuildDate>Sat, 04 Feb 2012 17:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>VMware ESXi 4.1 Kickstart Scripted Deployment with UDA (PXE BOOT)</title>
		<link>http://www.rayheffer.com/1369/vmware-esxi-4-1-kickstart-scripted-deployment-with-uda-pxe-boot/</link>
		<comments>http://www.rayheffer.com/1369/vmware-esxi-4-1-kickstart-scripted-deployment-with-uda-pxe-boot/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 15:32:57 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[ESX]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts & Commands]]></category>
		<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[Virtualisation]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[home lab]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://www.rayheffer.com/?p=1369</guid>
		<description><![CDATA[If you are looking to deploy multiple ESX/ESXi servers then there are plenty of methods and tools out there, some more complex than others. There are vendor specific deployment products available such as HP Rapid Depuployment Pack (RDP) which uses Altiris, or alternatively there are free deployment tools such as ESX Deployment Appliance (EsleeDA) and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F1369%2Fvmware-esxi-4-1-kickstart-scripted-deployment-with-uda-pxe-boot%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F1369_2Fvmware-esxi-4-1-kickstart-scripted-deployment-with-uda-pxe-boot_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F1369%2Fvmware-esxi-4-1-kickstart-scripted-deployment-with-uda-pxe-boot%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you are looking to deploy multiple ESX/ESXi servers then there are plenty of methods and tools out there, some more complex than others. There are vendor specific deployment products available such as HP Rapid Depuployment Pack (RDP) which uses Altiris, or alternatively there are free deployment tools such as ESX Deployment Appliance (EsleeDA) and Ultimate Deployment Appliance (UDA). UDA is my favorite tool for the job as it offers great flexibility such as the use of subtemplates (discussed later), and therefore this will be the basis of this article. It was created by <a href="http://www.ultimatedeployment.org/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.ultimatedeployment.org/?referer=');">Carl Thijssen</a> and thanks to <a href="http://www.rtfm-ed.co.uk/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.rtfm-ed.co.uk/?referer=');">Mike Laverick of RTFM</a>, it also supports ESX/ESXi deployments, and the latest build supports ESX/ESXi 4.1.<br />
<span id="more-1369"></span><br />
I aim to share the basics of getting the UDA configured for your environment and not delve into anything too complicated here. The best way of learning to perform some of the more complex deployments are to grasp the basics first then experiment with other functionality in your own environment for yourself. Mike Laverick has an excellent <a href="http://www.rtfm-ed.co.uk/docs/vmwdocs/uda20-beta.pdf " target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.rtfm-ed.co.uk/docs/vmwdocs/uda20-beta.pdf?referer=');">guide</a> on deploying and configuring UDA 2.0 beta.</p>
<p>For the purposes of this guide a number of assumptions have been made. You will have already deployed vCenter and at least one ESX/ESXi host running with some storage. If you are going to be testing this in a home lab then bear in mind that we’ll need to configure DHCP options 66 and 67, see the end of this article for details. You can do this with an existing DHCP server or use UDA as a DHCP server. Most deployments will be using an existing DHCP server.</p>
<p>Let’s get started&#8230;</p>
<p><strong>Step 1: Download &amp; Deploy the Ultimate Deployment Appliance</strong></p>
<p>1) Download UDA from: <a href="http://www.rtfm-ed.co.uk/vmware-content/ultimate-da/" target="_blank" onclick="pageTracker._trackPageview('/outgoing/www.rtfm-ed.co.uk/vmware-content/ultimate-da/?referer=');">http://www.rtfm-ed.co.uk/vmware-content/ultimate-da/</a> then extract it to your hard disk.<br />
2) Import the appliance using your vSphere client (<code>File &gt; Deploy OVF Template...</code>)<br />
3) Prior to powering on the appliance, add a second disk that we’ll use to store your ISO images. I’d recommend at least a 20GB disk, and use thin to conserve disk space.<br />
4) Power on and proceed to the next step.</p>
<p><strong>Step 2: Installation and Setup</strong></p>
<p><a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-001.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Setup"><img class="alignnone size-thumbnail wp-image-1385" title="Ultimate Deployment Appliance (UDA) Setup" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-001-150x150.png" alt="Ultimate Deployment Appliance (UDA) Setup" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-002.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Setup"><img class="alignnone size-thumbnail wp-image-1386" title="Ultimate Deployment Appliance (UDA) Setup" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-002-150x150.png" alt="Ultimate Deployment Appliance (UDA) Setup" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-003.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Setup"><img class="alignnone size-thumbnail wp-image-1387" title="Ultimate Deployment Appliance (UDA) Setup" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-003-150x150.png" alt="Ultimate Deployment Appliance (UDA) Setup" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-004.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Setup"><img title="Ultimate Deployment Appliance (UDA) Setup" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-004-150x150.png" alt="Ultimate Deployment Appliance (UDA) Setup" width="150" height="150" /></a></p>
<p><a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-003.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Setup"></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-005.png" rel="lightbox[1369]"><img class="alignnone size-thumbnail wp-image-1389" title="Ultimate Deployment Appliance (UDA) Setup" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-005-150x150.png" alt="Ultimate Deployment Appliance (UDA) Setup" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-006.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Setup"><img class="alignnone size-thumbnail wp-image-1390" title="Ultimate Deployment Appliance (UDA) Setup" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-setup-006-150x150.png" alt="Ultimate Deployment Appliance (UDA) Setup" width="150" height="150" /></a></p>
<p>1) Click OK at the welcome screen<br />
2) Enter the hostname (I recommend that you also add the hostname into your DNS server)<br />
3) Enter the IP address configuration<br />
4) Select the services you require (as a minimum I would just leave TFTP, HTTP and SSH selected)<br />
5) Enter the root password.<br />
6) Select Yes to apply the changes.</p>
<p>Once it has finished you will then be able to access your UDA from a web browser. Log in with admin and the password you set during the setup.</p>
<p><strong>Step 3: UDA Configuration</strong></p>
<p>When you first log into the appliance you will be presented with a welcome page. The first thing to configure is the additional disk space we need to store our ISO images. If you haven’t added a second hard disk, then shutdown the UDA (System &gt; Shutdown), then add the additional disk and power on.</p>
<p>UDA has two partitions; <code>systemlv</code> and <code>localv</code>. ISO images are stored on the <code>localv</code> partition, so we’ll extend that.</p>
<p>1) Go to System and click Diskspace.<br />
2) Select localv and then click Extend.<br />
3) Select the device and then click Apply.</p>
<p>It may take a little while depending on how large the new disk is, but once that is complete we’ll load the ISO image for ESXi 4.1 Update 1 on to the UDA.</p>
<p>1) Go to System and click Upload.<br />
2) Click Choose File, select your ISO then click Upload.</p>
<p>It will store the ISO on the localv partition in <code>/local</code>.</p>
<p><strong>Step 4: Add an OS &amp; Deployment Template for ESXi 4.1</strong></p>
<p><a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-001.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img class="alignnone size-thumbnail wp-image-1392" title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-001-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-002.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img class="alignnone size-thumbnail wp-image-1393" title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-002-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-003.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img class="alignnone size-thumbnail wp-image-1394" title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-003-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /> </a><a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-004.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-004-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /></a></p>
<p><a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-005.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img class="alignnone size-thumbnail wp-image-1396" title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-005-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-006.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img class="alignnone size-thumbnail wp-image-1397" title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-006-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-007.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance (UDA) Configuration Steps"><img title="Ultimate Deployment Appliance (UDA) Configuration Steps" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-config-007-150x150.png" alt="Ultimate Deployment Appliance (UDA) Configuration Steps" width="150" height="150" /></a></p>
<p>Now for the exciting bit. We’ll add our OS (ESXi) and template for deployment which will also create the basics of our Kickstart script which we’ll add to later. The OS section allows us to tie an ISO image to a Flava name, in this case we’ll call it ESXi41. I’d recommend using a better naming convention for your environment though.</p>
<p>1) Go to OS and click New.<br />
2) Enter ESXi41 for the Flava Name.<br />
3) From the dropdown, choose VMware ESXi 4.1 Installable and click Next.<br />
4) Select the ESXi 4.1 ISO you uploaded and then click Finish.</p>
<p>Next, the template which contains our Kickstart script. The template also contains a subtemplate which allows us to define our own variables, such as IP address and hostnames for each ESXi host we are deploying. This is why I like using UDA so much, because it avoids having to create a separate Kickstart script for each ESXi host.</p>
<p>1) Go to Templates and click New.<br />
2) Enter a Template Name. For example: esxi-build and give it a meaninful description.<br />
3) From the Operating System dropdown choose VMware ESXi 4.1 Installable and click Next.<br />
4) From the Flava dropdown choose your OS (Flava), ESXi41 and click Next then Finish.</p>
<p>The next stage is to perform the configuration of our Kickstart script and subtemplate. Go to Templates, select your template (esxi-build) and click Configure. You’ll see three tabs here; General, Subtemplates and Advanced. Click on Advanced. This is where our Kickstart script lives, and you’ll see it contains a basic configuration.</p>
<p>Here is a breakdown with explanations for each line:</p>
<p><code><br />
# Accept the VMware EULA - The script will fail without this.<br />
accepteula</code></p>
<p><code># Set the root password using MD5 crypt<br />
rootpw secret</code></p>
<p><code># Auto partition the disk<br />
autopart --firstdisk --overwritevmfs</code></p>
<p><code># Location of the install media<br />
install url http://[UDA_IPADDR]/[OS]/[FLAVOR]</code></p>
<p><code># Configure IP address and hostname. --addvmportgroup=0 will disable creation of the VM Network portgroup<br />
network --bootproto=static --ip=192.168.178.200 --gateway=192.168.178.1 --nameserver=192.168.178.1 --netmask=255.255.255.0 --hostname=esx41i --addvmportgroup=0</code></p>
<p><code># Reboot the host when the installation is complete<br />
reboot</code></p>
<p>The first thing we need to change is the root password which by default is set to <code>secret</code> and is in plain text. We can use a crypted MD5 password here using <code>rootpw --iscrypted</code> followed by the crypt.</p>
<p>1) Log into your UDA with PuTTY (SSH) and log in as root (same password you set during the initial setup).<br />
2) Type <code>grub-md5-crypt</code><br />
3) Enter your password and it’ll generate an MD5 string for you.<br />
4) Go back to the Advanced view in the web interface and change the rootpw line to (replacing the crypt with the one you generated):</p>
<p><code>rootpw --iscrypted  $1$3vkd233f/wksSo$fhniM3fdcV6hr0</code></p>
<p>Now we need to change the network configuration to use the appropriate IP address, gateway, subnet mask and hostname. We could just replace the default IP address configuration here, but a better method is to use variables which we can set in subtemplates. Variables are set inside square brackets, such as <code>[IPADDR], [FQDN]</code> and so on. The variable names are up to you. Change the network configuration, replacing the IP address and hostname with variables as follows:</p>
<p><code>network --bootproto=static --ip=[IPADDR] --gateway=192.168.4.1 --nameserver=192.168.4.1 --netmask=255.255.255.0 --hostname=[FQDN] --addvmportgroup=0</code></p>
<p>Select Subtemplates and click on Edit. The first line we will create contains the word <code>SUBTEMPLATE</code> then the variable names that we want to use (separated by semi-colons). Subsequent lines contain the values for each host. See my example below:</p>
<p><code>SUBTEMPLATE;IPADDR;FQDN;VMKIPADDR<br />
ESX01;192.168.4.11;esx01.home.lab;192.168.4.211<br />
ESX02;192.168.4.12;esx02.home.lab;192.168.4.212<br />
ESX03;192.168.4.13;esx03.home.lab;192.168.4.213<br />
ESX04;192.168.4.14;esx04.home.lab;192.168.4.214</code></p>
<p>You’ll notice in my example I’ve added a VMkernel IP address that in the case of our ESXi deployment we will use for VMotion.</p>
<p>Click on the Advanced tab. After the network configuration line we need to add the following command which allows us to run our <code>esxcfg</code> commands on first boot:</p>
<p><code>%firstboot --unsupported --interpreter=busybox</code></p>
<p>Now add the following commands to the Kickstart script (Advanced), which will add a VMotion portgroup and IP address. You can leave the <code>#</code> comments in if you wish:</p>
<p><code># Setup VMotion portgroup on vSwitch0<br />
esxcfg-vswitch -A VMotion vSwitch0</code></p>
<p><code># Setup VMotion IP address<br />
esxcfg-vmknic -a VMotion -i [VMKIPADDR] -n 255.255.255.0</code></p>
<p><code># Wait for previous command to finish before enabling VMotion<br />
sleep 10</code></p>
<p><code># Enable VMotion (ESX uses vmware-vim-cmd and ESXi is vim-cmd)<br />
vim-cmd hostsvc/vmotion/vnic_set vmk1<br />
vim-cmd hostsvc/net/refresh<br />
</code></p>
<p>Notice in the <code>vim-cmd</code> command above that it sets VMotion on <code>vmk1</code>. <code>vmk0</code> will be the management IP address used in the network command at the top of our script. This is fairly straightforward to work out, but if anyone knows of a better method then feel free to comment!</p>
<p>Finally click on Save.</p>
<p><strong>The Deployment</strong></p>
<p>Now we have the UDA configured and ready to roll with our ESXi installation all we have to do now is PXE boot our hosts and providing you have configured DHCP options 66 &amp; 67 (see the end of this article) you should be presented with the UDA menu (see first screenshot).</p>
<p><a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-001.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance Menu - Installing VMware ESXi"><img class="alignnone size-thumbnail wp-image-1427" title="Ultimate Deployment Appliance Menu - Installing VMware ESXi" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-001-150x150.png" alt="Ultimate Deployment Appliance Menu - Installing VMware ESXi" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-002.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance Menu - Installing VMware ESXi"><img class="alignnone size-thumbnail wp-image-1428" title="Ultimate Deployment Appliance Menu - Installing VMware ESXi" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-002-150x150.png" alt="Ultimate Deployment Appliance Menu - Installing VMware ESXi" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-003.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance - Installing VMware ESXi"><img class="alignnone size-thumbnail wp-image-1429" title="Ultimate Deployment Appliance - Installing VMware ESXi" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-003-150x150.png" alt="Ultimate Deployment Appliance - Installing VMware ESXi" width="150" height="150" /></a> <a href="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-004.png" rel="lightbox[1369]" title="Ultimate Deployment Appliance - Installing VMware ESXi"><img class="alignnone size-thumbnail wp-image-1430" title="Ultimate Deployment Appliance - Installing VMware ESXi" src="http://www.rayheffer.com/wp-content/uploads/2011/03/uda-boot-004-150x150.png" alt="Ultimate Deployment Appliance - Installing VMware ESXi" width="150" height="150" /></a></p>
<p>The rest is easy, just select the host from the menu (we set this in SUBTEMPLATE) and it will install and configure ESXi with no user intervention. Using a scripted installation can be very powerful and a lot more can be configured than I&#8217;ve included here. Even if you don&#8217;t have mass ESXi deployments, this is a good way of ensuring that your ESXi hosts maintain your standard build. If you have an Enterprise Plus license then you can also use Host Profiles.</p>
<hr />
<p><strong>Kickstart script:</strong></p>
<p><code>accepteula<br />
rootpw --iscrypted $1$3vkd233f/wksSo$fhniM3fdcV6hr0<br />
autopart --firstdisk --overwritevmfs<br />
install url http://[UDA_IPADDR]/[OS]/[FLAVOR]<br />
network --bootproto=static --ip=[IPADDR] --gateway=192.168.4.1 --nameserver=192.168.4.30 --netmask=255.255.255.0 --hostname=[FQDN] --addvmportgroup=0<br />
reboot</code></p>
<p><code>## THE FOLLOWING IS OUR FIRSTBOOT CONFIGURATION ##</code></p>
<p><code># Configure additional commands at first boot.<br />
%firstboot --unsupported --interpreter=busybox</code></p>
<p><code># Setup VMotion portgroup on vSwitch0<br />
esxcfg-vswitch -A VMotion vSwitch0</code></p>
<p><code># Setup VMotion IP address<br />
esxcfg-vmknic -a VMotion -i [VMKIPADDR] -n 255.255.255.0</code></p>
<p><code># Wait for previous command to finish before enabling VMotion<br />
sleep 10</code></p>
<p><code># Enable VMotion (ESX uses vmware-vim-cmd and ESXi is vim-cmd)<br />
vim-cmd hostsvc/vmotion/vnic_set vmk1<br />
vim-cmd hostsvc/net/refresh</code></p>
<hr />
<p><strong>SUBTEMPLATE:</strong></p>
<p><code>SUBTEMPLATE;IPADDR;FQDN;VMKIPADDR<br />
ESX01;192.168.4.11;esx01.home.lab;192.168.4.211<br />
ESX02;192.168.4.12;esx02.home.lab;192.168.4.212<br />
ESX03;192.168.4.13;esx03.home.lab;192.168.4.213<br />
ESX04;192.168.4.14;esx04.home.lab;192.168.4.214</code></p>
<hr />
<p><strong>Configuring DHCP Options</strong></p>
<p>1) Set option 66 to the IP address of your UDA<br />
2) Set option 67 to pxelinux.0</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/1369/vmware-esxi-4-1-kickstart-scripted-deployment-with-uda-pxe-boot/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>8.3 VCAP-DCA Study Guide &#8211; Configuring vMA for Logging</title>
		<link>http://www.rayheffer.com/1296/6-1-8-3-logging-vmware-vma-configuring-vma-as-a-syslog-server/</link>
		<comments>http://www.rayheffer.com/1296/6-1-8-3-logging-vmware-vma-configuring-vma-as-a-syslog-server/#comments</comments>
		<pubDate>Mon, 07 Mar 2011 12:36:02 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[ESX]]></category>
		<category><![CDATA[ESXi]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts & Commands]]></category>
		<category><![CDATA[VCAP-DCA]]></category>
		<category><![CDATA[Virtualisation]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[esx]]></category>
		<category><![CDATA[esxi]]></category>
		<category><![CDATA[vcap]]></category>
		<category><![CDATA[vma]]></category>
		<category><![CDATA[vsphere]]></category>

		<guid isPermaLink="false">http://www.rayheffer.com/?p=1296</guid>
		<description><![CDATA[In this article I detail the steps required to configure your vMA as a Syslog server, and configure your ESX/ESXi hosts to send logging information to the vMA. Logging is often overlooked, but when managing multiple hosts it is far easier to send your logs to a Syslog server. I&#8217;m studying for the VCAP-DCA exam, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F1296%2F6-1-8-3-logging-vmware-vma-configuring-vma-as-a-syslog-server%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F1296_2F6-1-8-3-logging-vmware-vma-configuring-vma-as-a-syslog-server_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F1296%2F6-1-8-3-logging-vmware-vma-configuring-vma-as-a-syslog-server%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>In this article I detail the steps required to configure your vMA as a Syslog server, and configure your ESX/ESXi hosts to send logging information to the vMA. Logging is often overlooked, but when managing multiple hosts it is far easier to send your logs to a Syslog server. I&#8217;m studying for the VCAP-DCA exam, and using vicfg-syslog is a requirement of the exam (Section 6.1) and the vMA is also essential to understand (Section 8.1). I hope my notes help you as they have helped me.<br />
<span id="more-1296"></span></p>
<h4><strong>Configuring your VMware vMA as a Syslog server is very easy to do, just follow these steps</strong></h4>
<p>Log on to your vMA as vi-admin and enter the following commands:</p>
<p><code>sudo service rsyslog stop<br />
sudo vi /etc/sysconfig/rsyslog<br />
sudo service rsyslog start<br />
sudo iptables -I INPUT -i eth0 -p udp --dport 514 -j ACCEPT<br />
sudo service iptables save</code> (this will save the new firewall rule and ensure it doesn&#8217;t disappear after a reboot)</p>
<p>Job done! The vMA server is now ready to accept syslog connections on UDP port 514.</p>
<h4><strong><br />
Configuring your ESXi host to send logging information to the Syslog server</strong></h4>
<p>You can do this via the vSphere client (Configuration &gt; Advanced &gt; Syslog, syslog.remote.hostname), but for the VCAP-DCA exam it might be useful to know how to do this using vMA.</p>
<p><strong>Using vMA:</strong></p>
<p>First ensure your have your ESXi host set as the fast-pass target, then use <code>vicfg-syslog</code>:</p>
<p><code># vifptarget -s &lt;ESXI_HOSTNAME&gt;<br />
# vicfg-syslog -s &lt;VMA_IP_ADDRESS&gt;</code></p>
<h4><strong><br />
Configuring your ESX host to send logging information to Syslog server</strong></h4>
<p>You can&#8217;t use the vSphere client or vMA to configure Syslog on an ESX host, so we need to edit <code>/etc/syslog.conf</code> and add the following line to the very bottom:</p>
<p><code>*.* @&lt;SYSLOG_IP_ADDRESS&gt;</code></p>
<p>In this example, replace &lt;SYSLOG_IP_ADDRESS&gt; with the IP address of the vMA.</p>
<p>Next we need to allow UDP port 514 out from your ESX host. To do this run the following command (make sure you are logged in, or <code>su -</code> as root):</p>
<p><code># esxcfg-firewall -o 514,udp,out,syslog</code></p>
<p><strong>Note:</strong> If you log in to your ESX hot then su as root make sure you type (<code>su -</code>) with the hyphen and that will load the environment variables of the root account. Otherwise you may find that you get the error &#8216;<code>bash: esxcfg-firewall: command not found</code>&#8216;.</p>
<p>Finally, restart the syslog service:</p>
<p><code># service syslog restart</code></p>
<h4><strong><br />
Checking the ESX logs on vMA</strong></h4>
<p>Now for the fun bit!  Log on to your vMA server as vi-admin, and type:</p>
<p><code># sudo tail -f /var/log/messages</code></p>
<p>This will tail the messages file, and -f will output data as it is added to the file.</p>
<p>To send a test message, log on to the ESX host that you configured for syslog (above) and type:</p>
<p><code># logger syslog test message</code></p>
<p>You should see your test message output on the vMA. Cool huh!</p>
<h4><strong><br />
Checking ESXi logs on vMA</strong></h4>
<p>The logger command isn&#8217;t available with ESXi, so another way of checking that your Syslog is working for an ESXi host is to filter the results to show the IP address of your ESXi host:</p>
<p><code># sudo tail -f /var/log/messages | grep &lt;ESXI_IP_ADDRESS&gt;</code></p>
<p>It shouldn&#8217;t take long to see messages from your ESXi host, and filtering on the IP address using grep is a really neat way of finding results for a particular host.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/1296/6-1-8-3-logging-vmware-vma-configuring-vma-as-a-syslog-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New WordPress site for 2010</title>
		<link>http://www.rayheffer.com/132/new-wordpress-site-for-2010/</link>
		<comments>http://www.rayheffer.com/132/new-wordpress-site-for-2010/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 08:05:39 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[vps]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.rayheffer.com/?p=132</guid>
		<description><![CDATA[Just in time for the start of the new year I decided to ditch the old RayHeffer.com site and replace it with a brand spanking new WordPress site running on my virtual Linux server in London. I have spent the past few nights up late tweaking the new site and adding content, so please look [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F132%2Fnew-wordpress-site-for-2010%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F132_2Fnew-wordpress-site-for-2010_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F132%2Fnew-wordpress-site-for-2010%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Just in time for the start of the new year I decided to ditch the old RayHeffer.com site and replace it with a brand spanking new WordPress site running on my virtual Linux server in London. I have spent the past few nights up late tweaking the new site and adding content, so please look around and don&#8217;t forget to leave me a comment!</p>
<p>It&#8217;s snowing outside as I write this here in the south east UK, so what better time to develop your Linux skills and build your own virtual Linux server by following my new LAMP guide based on CentOS 5?</p>
<p>Happy New Year!</p>
<p>Ray</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/132/new-wordpress-site-for-2010/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a secure web server with CentOS 5, part 1</title>
		<link>http://www.rayheffer.com/36/building-a-secure-web-server-with-centos-5-part-1/</link>
		<comments>http://www.rayheffer.com/36/building-a-secure-web-server-with-centos-5-part-1/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 23:20:49 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[secure]]></category>
		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://wp.rayheffer.com/?p=36</guid>
		<description><![CDATA[Part 1 &#124; Part 2 &#124; Part 3 &#124; Troubleshooting Introduction This is an updated version of my original LAMP (Linux Apache MySQL and Perl/PHP) guide that was based on CentOS 4. Now updated and tweaked for CentOS 5, I will take you through the steps required to build a secure Linux web server (LAMP) [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F36%2Fbuilding-a-secure-web-server-with-centos-5-part-1%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F36_2Fbuilding-a-secure-web-server-with-centos-5-part-1_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F36%2Fbuilding-a-secure-web-server-with-centos-5-part-1%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Part 1</strong> | <a href="http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/">Part 2</a> | <a href="http://www.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/">Part 3</a> | <a href="http://www.rayheffer.com/117/troubleshooting-your-centos-5-web-server/">Troubleshooting</a></p>
<p><strong>Introduction</strong><br />
This is an updated version of my original LAMP (Linux Apache MySQL and Perl/PHP) guide that was based on CentOS 4. Now updated and tweaked for CentOS 5, I will take you through the steps required to build a secure Linux web server (LAMP) on CentOS 5.</p>
<p>I have a background working for an ISP, so I’ve based this build on the same configuration many hosting providers use. It supports virtual hosts (multiple websites), secure FTP access, locked down SSH access, and a sensible directory structure.</p>
<p>If you follow this guide, you will get a web server up and running within a couple of hours depending on whether you follow it step by step, or prefer to experiment first. If you are new to Linux then give it a try and learn something new, you never know you may surprise yourself!</p>
<p>Good luck!<br />
<span id="more-36"></span><br />
<strong>A word on web hosting</strong></p>
<p>Before you get started with your server build, I&#8217;d like to talk about where you are going to host this server. There have been a number of developments in the past few years in regards to people hosting websites on their home ISP broadband connection.</p>
<p>Firstly, did you know that many of the major search engines will not crawl your website if it&#8217;s hosted on a residential IP address? What I mean by residential is an IP address provided by the likes of an ADSL or broadband provider (e.g. Virgin Media, BT, PlusNet, here in the UK). It will depend on the ISP whether you get a &#8216;fixed&#8217; IP address or not, and even if you do your site will simply be ignored by the major search engines as they will recognise the IP address in a residential (non ISP) range. Don&#8217;t get me wrong, running web servers at home is great fun but I would recommend you avoid it unless it is purely for testing.</p>
<p>So, where is the best place to host your shiny new CentOS web server?</p>
<p>I would highly recommend getting a VPS (Virtual Private Server). There are plenty of hosting companies offering Virtual Private Servers, and VPS hosting is getting cheaper.</p>
<p>I would personally recommend <a href="http://www.linode.com/?r=6af02fe4285827f3bb09d52875f71dfa026d21f1" onclick="pageTracker._trackPageview('/outgoing/www.linode.com/?r=6af02fe4285827f3bb09d52875f71dfa026d21f1&amp;referer=');">Linode</a>, I have been using them since 2006 and recently they have started hosting virtual servers in the London, UK as well as the USA. They provide a generous amount of bandwidth, starting at around 200GiB per month with 16GB+ of disk space depending on which option you go for. You can choose from a massive list of Linux distro&#8217;s, including CentOS 5! They use Xen virtualisation and they have an excellent web interface for accessing your server stats, server controls, DNS, and console access.</p>
<p><strong>Getting Started</strong></p>
<p>CentOS 5 is completely free and developed by a team of core developers at a North American Enterprise Linux vendor. In turn the core developers are supported by an active user community including system administrators, network administrators, enterprise users, managers, core Linux contributors and Linux enthusiasts from around the world.</p>
<p>CentOS has numerous advantages over some of the other clone projects including: an active and growing user community, quickly rebuilt, tested, and QA&#8217;ed errata packages, an extensive mirror network, developers who are contactable and responsive, multiple free support avenues including IRC Chat, Mailing Lists, Forums, a dynamic FAQ. Commercial support is offered via a number of vendors.</p>
<p>CentOS 5 is distributed on six CD&#8217;s, all of which are available for download from the <a href="http://www.centos.org" onclick="pageTracker._trackPageview('/outgoing/www.centos.org?referer=');">CentOS </a>website.</p>
<p><strong>Download phpMyAdmin</strong></p>
<p>This is optional, but I would highly recommend this excellent web interface for administering your MySQL databases. I have used this in the past to provide customers with their own phpMyAdmin login username, so they can manage their databases easily.</p>
<p><a href="http://www.phpmyadmin.net" onclick="pageTracker._trackPageview('/outgoing/www.phpmyadmin.net?referer=');">http://www.phpmyadmin.net</a></p>
<p><strong>Installing CentOS</strong></p>
<p><strong>NOTE:</strong> If you are using a virtual private server (VPS) provided by a hosting company such as <a href="http://www.linode.com/?r=6af02fe4285827f3bb09d52875f71dfa026d21f1" onclick="pageTracker._trackPageview('/outgoing/www.linode.com/?r=6af02fe4285827f3bb09d52875f71dfa026d21f1&amp;referer=');">Linode</a>, and CentOS is already installed then skip ahead to the next section.</p>
<ul>
<li>Insert CD of the CentOS 5 installation CD and boot your server.</li>
<li>At the installation menu, just press ENTER for the graphical installation wizard.</li>
<li>When prompted for an installation type select custom installation and de-select all options for bare install.</li>
<li>Use automatic partitioning for the disks.</li>
<li>Remove all partitions from system (make sure you are happy to wipe all existing data!!).</li>
<li>Boot Loader: Leave default settings.</li>
<li>Network Configuration: Configure this with an internal IP address and DNS name.</li>
<li>Firewall: Select ‘No firewall’ as this will be installed and configured later.</li>
<li>SELinux: Set to ‘Disabled’. This is still very experimental so I would leave this switched off unless you really know what you are doing.</li>
<li>Authentication: Set a secure root password using random characters and numbers (upper an lower case).</li>
<li>Package Selection: Choose minimal configuration (Other packages can be installed at a later stage according to the server role).</li>
</ul>
<p>WARNING!! – The server should not be connected to the internet until the configuration is completed and secure!</p>
<p><strong>Updating the System</strong></p>
<p>Now that you have CentOS 5 installed, we need to make sure it&#8217;s up to date and then do some basic security configuration with SSH. Unlike CentOS 4, you no longer have to import the RPM key to update and install software. It does this for you.</p>
<p>To check for updates type the following:</p>
<p><code># yum check-update</code></p>
<p>Now perform the update process. Note, the -y is to accept all updates which I recommend as it&#8217;s a clean installation.</p>
<p><code># yum –y update</code></p>
<p><strong>Setting the clock</strong><br />
I strongly advise that you setup the timezone and clock correctly. First, you set /etc/localtime to link to the correct timezone, then either set the time manually or configure NTPD to syncronise with an internet time server such as pool.ntp.org.</p>
<p>Example of setting the timezone to GMT:</p>
<p><code># ln -sf /usr/share/zoneinfo/GMT /etc/localtime</code></p>
<p><strong>Setting the hardware clock:</strong></p>
<p><code># vi /etc/sysconfig/clock</code></p>
<p><strong>System Services Configuration</strong></p>
<p>As this is going to be a finely tuned web server, we don&#8217;t want uneccessary daemons running! Firstly, lets list all the daemons that have been configured to run at startup.</p>
<p><code># chkconfig –list|grep on</code></p>
<p>You should now get an output similar to the following:</p>
<p><code>anacron 0:off 1:off 2:off 3:off 4:off 5:off 6:off<br />
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off<br />
crond 0:off 1:on 2:off 3:on 4:on 5:on 6:off<br />
cups 0:off 1:on 2:off 3:on 4:on 5:on 6:off<br />
haldaemon 0:off 1:on 2:off 3:off 4:on 5:on 6:off<br />
messagebus0:off 1:on 2:off 3:off 4:on 5:on 6:off<br />
network 0:off 1:on 2:off 3:off 4:on 5:on 6:off<br />
syslog 0:off 1:on 2:off 3:off 4:on 5:on 6:off</code></p>
<p>Your list will probably be a lot longer as this is just an example, but what you can see here is the different run levels and their on/off status. Most daemons start at run level 3. Now lets switch off the daemons that aren&#8217;t needed. I&#8217;ve listed a few more here that you are likely to find.</p>
<p><code># chkconfig cups off<br />
# chkconfig apmd off<br />
# chkconfig netfs off<br />
# chkconfig pcmcia off<br />
# chkconfig smartd off<br />
# chkconfig anacron off<br />
# chkconfig mdmonitor off<br />
# chkconfig isdn off</code></p>
<p><strong>NOTE:</strong> If you are using <a href="http://www.linode.com/?r=6af02fe4285827f3bb09d52875f71dfa026d21f1" onclick="pageTracker._trackPageview('/outgoing/www.linode.com/?r=6af02fe4285827f3bb09d52875f71dfa026d21f1&amp;referer=');">Linode</a> then you should also switch off Kudzu (hardware detection) as this serves no purpose on a virtual UML system.</p>
<p><strong>Host Access (TCP_WRAPPERS)</strong></p>
<p>There are two host access files (/etc/hosts.allow and /etc/hosts.deny), that are part of the TCP_WRAPPER package. This makes it possible to allow or deny access to certain services based on the IP.</p>
<p>Edit the hosts.allow and hosts.deny files:<br />
<code># vi /etc/hosts.allow</code></p>
<p><code>sshd:&lt;IP ADDRESS&gt;<br />
vsftpd:ALL<br />
sendmail:ALL</code></p>
<p><code># vi /etc/hosts.deny</code></p>
<p><code>ALL:ALL</code></p>
<p>The <code>&lt;IP ADDRESS&gt;</code> above is the internet IP you are connecting from (don&#8217;t include <code>&lt;</code> or <code>&gt;</code>). You can enter multiple IP address here (separated by spaces) or to allow SSH from any IP just replace with <code>ALL</code>.</p>
<p>The root account should never be able to login via SSH (without first logging in as a user). You must change this, so edit /etc/ssh/sshd_config and ensure the following is set:</p>
<p><code># vi /etc/ssh/sshd_config</code></p>
<p>Change the following lines as follows:</p>
<p><code>PermitRootLogin no<br />
Protocol 2</code></p>
<p><strong>Note: </strong>Some of these lines may already exist but will be commented out using #. To enable these commands the # needs to be removed.</p>
<p><strong>Add Default Accounts</strong></p>
<p>Before proceeding with any of the steps below, first create a user account that you will use to log in to this server. This account will be used for SSH connections.</p>
<p><code># adduser <em>&lt;username&gt;</em><br />
# passwd <em>&lt;username&gt;</em></code></p>
<p>You should now have access to the server via SSH. Download <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" onclick="pageTracker._trackPageview('/outgoing/www.chiark.greenend.org.uk/_sgtatham/putty/download.html?referer=');">PuTTY</a> and make sure it works.</p>
<p>When you are ready proceed to <a href="http://wp.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/" onclick="pageTracker._trackPageview('/outgoing/wp.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/?referer=');">part 2</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/36/building-a-secure-web-server-with-centos-5-part-1/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Building a secure web server with CentOS 5, part 2</title>
		<link>http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/</link>
		<comments>http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 20:44:02 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[http.conf]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpmyadmin]]></category>
		<category><![CDATA[secure]]></category>
		<category><![CDATA[vsftp]]></category>
		<category><![CDATA[web server]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://wp.rayheffer.com/?p=91</guid>
		<description><![CDATA[Part 1 &#124; Part 2 &#124; Part 3 &#124; Troubleshooting Part 2: Configuring the Server Configuring CentOS Edit /etc/hosts and /etc/sysconfig/network with hostnames Install Packages Example of /etc/hosts: # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost 67.34.32.11 www.mydomain.com Example of /etc/sysconfig/network NETWORKING=yes HOSTNAME=www.mydomain.com Installing Packages # yum [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F91%2Fbuilding-a-secure-web-server-with-centos-5-part-2%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F91_2Fbuilding-a-secure-web-server-with-centos-5-part-2_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F91%2Fbuilding-a-secure-web-server-with-centos-5-part-2%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.rayheffer.com/36/building-a-secure-web-server-with-centos-5-part-1/">Part 1</a> | <strong>Part 2</strong> | <a href="http://www.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/">Part 3</a> | <a href="http://www.rayheffer.com/117/troubleshooting-your-centos-5-web-server/">Troubleshooting</a></p>
<p><strong>Part 2: Configuring the Server</strong></p>
<p><strong>Configuring CentOS</strong></p>
<ul>
<li>Edit <code>/etc/hosts</code> and <code>/etc/sysconfig/network</code> with hostnames</li>
<li>Install Packages</li>
</ul>
<p><strong>Example of /etc/hosts:</strong></p>
<p><code># Do not remove the following line, or various programs<br />
# that require network functionality will fail.<br />
127.0.0.1 localhost<br />
67.34.32.11 www.mydomain.com</code></p>
<p><strong>Example of /etc/sysconfig/network</strong></p>
<p><code>NETWORKING=yes<br />
HOSTNAME=www.mydomain.com</code></p>
<p><strong>Installing Packages</strong></p>
<p><code># yum -y install httpd openssl-devel openssl mod_ssl vsftpd rpm-build rpm-devel autoconf automake lynx gcc<br />
# yum -y install mysql mod_auth_mysql mysql-devel mysql-server<br />
# yum -y install mod_python python python-devel<br />
# yum -y install perl mod_perl mod_perl-devel openssl-perl perl-Convert-ASN1 perl-Date-Calc perl-DateManip perl-HTML-Parser perl-libwww-perl perl-CPAN perl-DBD-MySQL perl-XML-Parser<br />
# yum -y install php-devel php php-domxml php-gd php-mbstring php-mysql php-ncurses php-pear<br />
# yum -y install webalizer<br />
# yum -y install sendmail sendmail-cf</code><br />
<span id="more-91"></span><br />
<strong>Creating Directory Structure</strong></p>
<p>All websites will be held in <code>/home/.sites/</code>. The first site that needs to be created is the <code>_default</code> site, which will be used as this servers default website.</p>
<p><code># mkdir /home/.sites<br />
# cd /home/.sites<br />
# mkdir _default<br />
# cd _default<br />
# mkdir logs private cgi-bin web<br />
# cd web<br />
# mkdir stats</code></p>
<p>Now change the ownership of these directories to adminftp as follows:</p>
<p><code># cd /home/.sites<br />
# chown adminftp _default -R</code></p>
<p>Configure the required system services sto start at boot:</p>
<p><code># chkconfig httpd on<br />
# chkconfig mysqld on<br />
# chkconfig vsftpd on<br />
# chkconfig sshd on</code></p>
<p><strong>Configuring Apache</strong></p>
<p>Apache runs as the httpd service, and it’s configuration file is contained in <code>/etc/httpd/conf</code>. To run in a ‘virtual’ hosting environment, we will now configure the httpd.conf file. But first things first, lets backup the httpd.conf file!</p>
<p><code># cd /etc/httpd/conf<br />
# cp httpd.conf httpd.conf.backup</code></p>
<p>Now edit httpd.conf (<code>vi /etc/httpd/conf/httpd.conf</code>) and make the following changes (substituting <code>mydomain.com</code> for your own domain).</p>
<p>The first section should be inside the httpd.conf file by default, so you just need to search for each line. You can easily do this using Vi by typing a forward slash then the keyword followed by enter (E.g. /ServerAdmin) and this will skip to that section if it is found. A bit like using Find in Windows.</p>
<p><code>ServerAdmin admin@mydomain.com<br />
ServerName www.mydomain.com:80<br />
NameVirtualHost *:80<br />
DirectoryIndex index.html index.htm index.html.var</code></p>
<p>Next, skip to the very bottom of the httpd.conf file and you should see something similar to this:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
ServerAdmin webmaster@dummy-host.example.com<br />
DocumentRoot /www/docs/dummy-host.example.com<br />
ServerName dummy-host.example.com<br />
ErrorLog logs/dummy-host.example.com-error_log<br />
CustomLog logs/dummy-host.example.com-access_log common<br />
&lt;/VirtualHost&gt;</code></p>
<p>Make sure that this section isn&#8217;t commented out (with #) on each line, and then change the ServerAdmin, DocumentRoot, ServerName, ErrorLog and CustomLog . See the following example:</p>
<p><code>&lt;VirtualHost *:80&gt;<br />
ServerAdmin admin@mydomain.com<br />
DocumentRoot /home/.sites/_default/web<br />
ServerName www.mydomain.com<br />
ScriptAlias /cgi-bin/ /home/.sites/_default/cgi-bin/<br />
ErrorLog /home/.sites/_default/logs/error_log<br />
TransferLog /home/.sites/_default/logs/access_log</code></p>
<p><code>Options FollowSymLinks<br />
Options +Includes<br />
AllowOverride All<br />
<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">&lt;/VirtualHost&gt;</span></code></p>
<p><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;">You can host multiple websites by adding further VirtualHost sections, and each website is identified using the <code>ServerName</code> line. If your website has multiple domain names (E.g. www.mydomain.com www.mydomain.net mydomain.biz) then just add each one on a new line after <code>ServerName </code>with <code>ServerAlias</code>.</span></p>
<p>Save and exit the httpd.conf file and then restart the httpd service.</p>
<p><code># /etc/init.d/httpd restart</code></p>
<p><strong>Configuring VSFTP</strong></p>
<p>VSFTP stands for Very Secure File Transfer Protocol. However using the installation defaults isn&#8217;t actually that secure as it allows anonymous access and doesn&#8217;t restrict which users can access the servers FTP service. In order to harden the security of VSFTP, several configuration changes must be made. Please note that some of these lines may be commented out by default, with a #, so remember to remove this if required.</p>
<p><code># vi /etc/vsftpd/vsftpd.conf</code></p>
<p><code>anonymous_enable=NO<br />
xferlog_file=/var/log/vsftpd.log<br />
idle_session_timeout=600<br />
nopriv_user=nobody<br />
ascii_upload_enable=YES<br />
ftpd_banner= **** WARNING - Your actions are being logged ****</code></p>
<p><code>pam_service_name=vsftpd<br />
userlist_enable=YES<br />
listen=YES<br />
tcp_wrappers=YES<br />
chroot_local_user=YES<br />
userlist_deny=NO</code></p>
<p>Next, we need to configure <code>vsftpd.userlist</code> and specify which users can FTP to the server. This compliments the <code>userlist_deny</code> setting in vsftpd.conf. When set to <code>NO</code>, this makes the <code>vsftpd.userlist</code> file a list of users that ARE allowed to log in.</p>
<p><code># vi /etc/vsftpd/user_list</code></p>
<p>Remove all of the users that are listed in this file by default, and add ONLY the users that require access to the FTP server.</p>
<p><strong>Configuring MySQL</strong></p>
<p>MySQL is configured using /etc/my.cnf, but prior to any configuration this configuration file has only the bare minimum required to start the MySQL daemon. However there are 5 templates that we can base the configuration on; <code>my-huge.cnf</code>, <code>my-innodb-heavy-4G.cnf</code>, <code>my-large.cnf</code>, <code>my-medium.cnf</code>, and <code>my-small.cnf</code>. These are each configured depending on the RAM and the priority that MySQL has on this server.</p>
<p>We will use my-medium.cnf as this has been based on a web server where MySQL is not the primary role of the server but could have frequent use. If you are hosting a few sites with light use then use <code>my-small.cnf</code>.</p>
<p><code># cd /usr/share/doc/mysql-server-<br />
# cp my-medium.cnf /etc/my.cnf</code></p>
<p>Once this has overwritten my.cnf, the mysqld service must be restarted.</p>
<p><code># /etc/init.d/mysqld restart</code></p>
<p>Now the root password for MySQL must be set using the following command. Do NOT use the same root password as the Linux root password.</p>
<p><code># mysqladmin -u root password </code></p>
<p><strong>Setting up phpMyAdmin</strong></p>
<p>Administration of MySQL is carried out using phpMyAdmin which is a free open source software package licensed under the GNU. Nearly all hosting providers use this, and is pretty much the de-facto standard these days.</p>
<p>1) Download <a href="http://www.phpmyadmin.net" onclick="pageTracker._trackPageview('/outgoing/www.phpmyadmin.net?referer=');">phpMyAdmin</a>,<br />
2) Extract the contents to a directory called phpMyAdmin (case sensitive)<br />
3) Transfer the phpMyAdmin directory to /home/.sites/_default/web (Use FTP and login using the user you setup previously, as described in the Configuring FTP using VSFTPD section).</p>
<p>Now we need to configure the <code>confic.inc.php</code> file as follows:</p>
<p><code># vi /home/.sites/_default/web/phpMyAdmin/config.inc.php</code></p>
<p>Look for:</p>
<p><code>$cfg['Servers'][$i]['auth_type'] = 'config’;</code></p>
<p>Change ‘<code>config</code>’ to ‘<code>http</code>’ then restart MySQL.</p>
<p><code># /etc/init.d/mysqld restart</code></p>
<p>You should now be able to log into phpMyAdmin by going to http://www.mydomain.com/phpMyAdmin. Log on using ‘root’ and the password you specified for MySQL. You will now be presented with the phpMyAdmin web control panel. By default, MySQL contains a test database which is not required, so as a security measure, this needs to be deleted. To do this, click on ‘Databases’, then tick test. Click ‘Drop’ and then click ‘Yes’ to confirm.</p>
<p>When you are ready proceed to <a href="http://wp.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/" onclick="pageTracker._trackPageview('/outgoing/wp.rayheffer.com/106/building-a-secure-web-server-with-centos-5-part-3/?referer=');">part 3</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/91/building-a-secure-web-server-with-centos-5-part-2/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>Linux commands and tips</title>
		<link>http://www.rayheffer.com/125/linux-commands-and-tips/</link>
		<comments>http://www.rayheffer.com/125/linux-commands-and-tips/#comments</comments>
		<pubDate>Thu, 07 Jul 2005 12:41:30 +0000</pubDate>
		<dc:creator>Ray Heffer</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Scripts & Commands]]></category>
		<category><![CDATA[Tech Tips]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[history]]></category>
		<category><![CDATA[hosts]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[makemap]]></category>
		<category><![CDATA[nameserver]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[resolv]]></category>
		<category><![CDATA[sendmail]]></category>
		<category><![CDATA[uname]]></category>

		<guid isPermaLink="false">http://wp.rayheffer.com/?p=125</guid>
		<description><![CDATA[Checking kernel &#38; CentOS version To check which kernel version you are running use uname -r # uname -r To find out which CentOS (or RedHat) release is installed have a look at /etc/redhat-release # cat /etc/redhat-release Checking Disk Space To check disk space used / free use the df command and it will display [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.rayheffer.com%2F125%2Flinux-commands-and-tips%2F" onclick="pageTracker._trackPageview('/outgoing/api.tweetmeme.com/share?url=http_3A_2F_2Fwww.rayheffer.com_2F125_2Flinux-commands-and-tips_2F&amp;referer=');"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.rayheffer.com%2F125%2Flinux-commands-and-tips%2F&amp;source=rayheffer&amp;style=normal&amp;service=TinyURL.com&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong><img class="size-full wp-image-376 alignright" title="Linux Tips" src="http://www.rayheffer.com/wp-content/uploads/2010/02/Programming.png" alt="" width="128" height="128" />Checking kernel &amp; CentOS version</strong></p>
<p>To check which kernel version you are running use <code>uname -r</code></p>
<p><code># uname -r</code></p>
<p>To find out which CentOS (or RedHat) release is installed have a look at <code>/etc/redhat-release</code></p>
<p><code># cat /etc/redhat-release </code></p>
<p><strong>Checking Disk Space</strong></p>
<p>To check disk space used / free use the <code>df </code>command and it will display each volume. The <code>-h</code> switch turns the bytes reading into GB to make it more readable.</p>
<p><code># df -h</code></p>
<p>If you want to check the size of a particular directory then use:</p>
<p><code># du -sh /</code><br />
<span id="more-125"></span></p>
<p><strong>Configuring DNS Settings</strong></p>
<p>To configure which DNS servers your Linux server will use you need to edit <code>/etc/resolv.conf</code></p>
<p><code># vi /etc/resolv.conf</code></p>
<p>Just add each name server as a new line as in the following example:</p>
<p><code>nameserver<br />
nameserver </code></p>
<p><strong>Changing the hostname</strong></p>
<p>You&#8217;ll find the hostname of the server in two places: <code>/etc/hosts</code> and <code>/etc/sysconfig/network</code>.</p>
<p><code># vi /etc/hosts</code></p>
<p>and</p>
<p><code># vi /etc/sysconfig/network</code></p>
<p><strong>Show Processor &amp; Memory Usage</strong></p>
<p>This is equivilant to the Windows Task Manager, and will show each process and the consumed CPU and RAM usage. Very useful!</p>
<p><code># top</code></p>
<p><strong>Show Processor Information</strong></p>
<p>This command will display the processor type and speed.</p>
<p><code># cat /proc/cpuinfo</code></p>
<p><strong>Search command history for old commands you have forgotten!</strong></p>
<p>Use the history command with <code>grep</code> to find previously entered commands.</p>
<p><code># history | grep <em>command</em></code></p>
<p><strong>Compiling sendmail.mc</strong></p>
<p><code># m4 /etc/mail/sendmail.mc &gt; /etc/mail/sendmail.cf</code></p>
<p><strong>Updating virtusertable.db from /etc/mail/virtusertable</strong></p>
<p><code># makemap hash /etc/mail/virtusertable.db &lt; /etc/mail/virtusertable</code></p>
<p><strong>Saving IPTABLES to /etc/sysconfig/iptables</strong></p>
<p><code># iptables-save &gt; /etc/sysconfig/iptables</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rayheffer.com/125/linux-commands-and-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
