<?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>Straylight Run &#187; Sysadmin</title> <atom:link href="http://blog.straylightrun.net/category/sysadmin/feed/" rel="self" type="application/rss+xml" /><link>http://blog.straylightrun.net</link> <description>Software, Technology, PHP</description> <lastBuildDate>Wed, 25 Apr 2012 16:11:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>Give Read-Only Access to Your Git Repo via SSH</title><link>http://blog.straylightrun.net/2012/04/25/give-read-only-access-to-your-git-repo-via-ssh/</link> <comments>http://blog.straylightrun.net/2012/04/25/give-read-only-access-to-your-git-repo-via-ssh/#comments</comments> <pubDate>Wed, 25 Apr 2012 16:10:02 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[git]]></category> <category><![CDATA[git-shell]]></category> <category><![CDATA[git-shell-commands]]></category> <category><![CDATA[github]]></category> <category><![CDATA[gitolite]]></category> <category><![CDATA[gitosis]]></category> <category><![CDATA[ssh]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/?p=366</guid> <description><![CDATA[So we took on some vendors to help us out. I wanted to provide these individuals authenticated, read-only access to our git repos so they could stay current with the project, but not commit code directly (they’ll have their own repo). Google yielded these excellent results pages. 8 ways to share your git repository [SO] [...]]]></description> <content:encoded><![CDATA[<p>So we took on some vendors to help us out. I wanted to provide these individuals <em>authenticated</em>, read-only access to our git repos so they could stay current with the project, but not commit code directly (they’ll have their own repo). Google yielded these excellent results pages.</p><ul><li><a
href="http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/">8 ways to share your git repository</a></li><li><a
href="http://stackoverflow.com/questions/1662205/how-to-make-a-git-repository-read-only/1663441#1663441">[SO] How to make a git repository read-only?</a></li></ul><p>When read altogether, I had a few options.</p><ol><li>Run the <a
href="http://schacon.github.com/git/git-daemon.html">git-daemon</a>. The repo would be publicy available over the internet via the git (<code>git://</code>) protocol.&#160; This provides read-only access, but it provides it to the <em>whole world</em>.&#160; Not a solution.</li><li>Run a <a
href="http://github.com">GitHub</a>-like server, like <a
href="http://swik.net/gitosis">Gitosis</a> or <a
href="http://github.com/sitaramc/gitolite">Gitolite</a>.&#160; This was the sledgehammer solution.&#160; Fine-grained access control, plus all the other bells and whistles. But I was not interested in installing and understanding a whole git-hosting server application.</li><li>SSH via <a
href="http://schacon.github.com/git/git-shell.html"><code>git-shell</code></a>.&#160; Each user gets a regular SSH account on the server, but each user gets a <code>git-shell</code> instead of a regular login shell like <code>bash</code>. The <code>git-shell</code> restricts the user to git operations.&#160; Write permissions are restricted using standard Linux permissions on the repo itself.</li></ol><p>So #3 was what I needed. I created an SSH login for each user that needed access to the repo. I set the login shell for each user to <code>/usr/bin/git-shell</code>. I put each user in a group that had read-only file system permissions to the repo.&#160; Testing it out worked well.&#160; Users could git clone and pull, but pushing failed and attempting to SSH directly failed.</p><p>One last note: as the man page mentions, you can create a directory called <code>git-shell-commands</code> in home directories of <code>git-shell users</code>.&#160; <code>git-shell</code> users will be able to run any command in this directory.&#160; If there is a help program in the directory, it is run when a <code>git-shell</code> user logs in.&#160; More details on <a
href="http://serverfault.com/questions/285324/git-shell-not-enabled/325484#325484"><code>git-shell-commands</code> here</a>, including the location of sample <code>git-shell</code> commands on your server.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2012/04/25/give-read-only-access-to-your-git-repo-via-ssh/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>MySQL Tip Of The Day: ~/.my.cnf</title><link>http://blog.straylightrun.net/2010/09/10/mysql-tip-of-the-day-my-cnf/</link> <comments>http://blog.straylightrun.net/2010/09/10/mysql-tip-of-the-day-my-cnf/#comments</comments> <pubDate>Fri, 10 Sep 2010 21:19:34 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[my.cnf]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[tips]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2010/09/10/mysql-tip-of-the-day-my-cnf/</guid> <description><![CDATA[Sometimes, I want to pop onto a database server, check the status of something, and then logout. So, for example, if I want to check on the number query cache free blocks, I run this long command: % mysqladmin -u admin -p extended &#124; grep -i qcache Then I type in the password. Well, I [...]]]></description> <content:encoded><![CDATA[<p>Sometimes, I want to pop onto a database server, check the status of something, and then logout. So, for example, if I want to check on the number query cache free blocks, I run this long command:</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% mysqladmin -u admin -p extended | grep -i qcache</pre></div></div><p>Then I type in the password. Well, I grew tired of typing in the extra options, plus the password. Turns out, MySQL will look for the configuration file <code>.my.cnf</code> in your home directory after it looks in /etc/my.cnf (<a
href="http://dev.mysql.com/doc/refman/5.1/en/option-files.html">it looks in a few other places as well</a>). So I put this in my <code>~/.my.cnf</code>:</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">[client]
user=admin
password=secret</pre></div></div><p>And now I can simply run:</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% mysqladmin extended | grep -i qcache</pre></div></div><p>and it works right away.&#160; Note that the password is stored in the clear.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2010/09/10/mysql-tip-of-the-day-my-cnf/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>HTTP Keep-Alive</title><link>http://blog.straylightrun.net/2010/09/10/http-keep-alive/</link> <comments>http://blog.straylightrun.net/2010/09/10/http-keep-alive/#comments</comments> <pubDate>Fri, 10 Sep 2010 21:13:51 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Performance]]></category> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[config]]></category> <category><![CDATA[headers]]></category> <category><![CDATA[http]]></category> <category><![CDATA[keep alive]]></category> <category><![CDATA[optimization]]></category> <category><![CDATA[subdomains]]></category> <category><![CDATA[virtual host]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2010/09/10/http-keep-alive/</guid> <description><![CDATA[Like most people, I did not know much about HTTP Keep-Alive headers other than that they could be very bad if used incorrectly. So I’ve kept them off, which is the default. But I ran across this blog post which explains the HTTP Keep-Alive, including its benefits and potential pitfalls pretty clearly. It’s all pretty [...]]]></description> <content:encoded><![CDATA[<p>Like most people, I did not know much about <a
href="http://httpd.apache.org/docs/2.2/mod/core.html#keepalive">HTTP Keep-Alive headers</a> other than that they could be <em>very </em>bad if used incorrectly. So I’ve kept them off, which is the default. But I ran across this blog post which <a
href="http://virtualthreads.blogspot.com/2006/01/tuning-apache-part-1.html">explains the HTTP Keep-Alive</a>, including its benefits and potential pitfalls pretty clearly.</p><p>It’s all pretty simple really. There is an overhead to opening and closing TCP connections. To alleviate this, Apache can agree to provide persistent connections by sending HTTP Keep-Alive headers. Then the browser can open a single connection to download multiple resources. But Apache won’t know when the browser is done downloading, so it simply keeps the connection open according to a Keep-Alive timeout, which is set to 15 seconds by default. The problem is the machine can only keep so many simultaneous requests open due to physical limitations (e.g. RAM, CPU, etc.) And 15 seconds is a <em>long</em> time.</p><p>To allow browsers to gain some parallelism on downloading files, without keeping persistent connections open too long, the Keep-Alive timeout value should be set to something very low, e.g. 2 seconds.</p><p>I’ve done this for <em>static content only</em>. Why only static content? It doesn’t really make much sense for the main page source itself since that’s the page the user wants to view.</p><p>I’ve <a
href="http://blog.straylightrun.net/2008/11/16/slides-from-phpworks-2008-part-2/">mentioned before</a> that by serving all static content on dedicated subdomains, we indirectly get the benefit of being able to optimize just those subdomains. So far, this meant:</p><ol><li>disabling <code>.htaccess </code>files</li><li>setting a far-future Expires: header</li><li>avoiding setting cookies on the subdomain</li></ol><p>Now we can add to the list: enabling HTTP Keep-Alive headers. The <code>VirtualHost </code>block might look like this now:</p><div
class="wp_syntax"><div
class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>VirtualHost <span style="color: #339933;">*:</span><span style="color: #cc66cc;">80</span><span style="color: #339933;">&gt;</span>
    ServerName      static0<span style="color: #339933;">.</span>yourdomain<span style="color: #339933;">.</span>com
    ServerAlias     static1<span style="color: #339933;">.</span>yourdomain<span style="color: #339933;">.</span>com
    ServerAlias     static2<span style="color: #339933;">.</span>yourdomain<span style="color: #339933;">.</span>com
    ServerAlias     static3<span style="color: #339933;">.</span>yourdomain<span style="color: #339933;">.</span>com
    DocumentRoot    <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span>www<span style="color: #339933;">/</span>vhosts<span style="color: #339933;">/</span>yourdomain<span style="color: #339933;">.</span>com
    KeepAlive On
    KeepAliveTimeout <span style="color: #cc66cc;">2</span>
    <span style="color: #339933;">&lt;</span>Directory <span style="color: #0000ff;">&quot;/var/www/vhosts/yourdomain.com&quot;</span><span style="color: #339933;">&gt;</span>
        AllowOverride None
        ExpiresActive On
        ExpiresByType text<span style="color: #339933;">/</span>css <span style="color: #0000ff;">&quot;access plus 1 year&quot;</span>
        ExpiresByType application<span style="color: #339933;">/</span>x<span style="color: #339933;">-</span>javascript <span style="color: #0000ff;">&quot;access plus 1 year&quot;</span>
        ExpiresByType image<span style="color: #339933;">/</span>jpeg <span style="color: #0000ff;">&quot;access plus 1 year&quot;</span>
        ExpiresByType image<span style="color: #339933;">/</span>gif <span style="color: #0000ff;">&quot;access plus 1 year&quot;</span>
        ExpiresByType image<span style="color: #339933;">/</span>png <span style="color: #0000ff;">&quot;access plus 1 year&quot;</span>
    <span style="color: #339933;">&lt;/</span>Directory<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;/</span>VirtualHost<span style="color: #339933;">&gt;</span></pre></div></div> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2010/09/10/http-keep-alive/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Throw Away Your Hosts File! Developing Locally With BIND</title><link>http://blog.straylightrun.net/2010/05/10/throw-away-your-hosts-file-developing-locally-with-bind/</link> <comments>http://blog.straylightrun.net/2010/05/10/throw-away-your-hosts-file-developing-locally-with-bind/#comments</comments> <pubDate>Tue, 11 May 2010 03:36:57 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[bind]]></category> <category><![CDATA[dns]]></category> <category><![CDATA[ipconfig]]></category> <category><![CDATA[nameserver]]></category> <category><![CDATA[virtual host]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2010/05/10/throw-away-your-hosts-file-developing-locally-with-bind/</guid> <description><![CDATA[Note the following applies to Windows Vista, but is probably easier on MacOS/Linux. Is your hosts file becoming monstrous?  Do you have an alias or shortcut to your hosts file because you edit it so often?  Tired of manually adding every subdomain and domain you work on? I was too when I thought there must [...]]]></description> <content:encoded><![CDATA[<blockquote><p>Note the following applies to Windows Vista, but is probably easier on MacOS/Linux.</p></blockquote><p>Is your <code>hosts </code>file becoming monstrous?  Do you have an alias or shortcut to your <code>hosts </code>file because you edit it so often?  Tired of manually adding every subdomain and domain you work on?</p><p>I was too when I thought <em>there must be a better way</em>.  And there was.</p><p>The general idea is this: by installing a local DNS nameserver in BIND, we can set up local development domains that look like regular domains on the internet. For real domains, we’ll just forward the requests on to a real nameserver.  This gives us a couple more benefits: 1) we can use the local nameserver as a caching nameserver to speed up DNS queries (in theory, I have not actually done this), and 2) we can choose to use any DNS service we wish, i.e. <a
href="http://www.opendns.com/">OpenDNS</a>, or <a
href="http://code.google.com/speed/public-dns/">Google DNS</a>.</p><p>Here are the steps.</p><ol><li>Follow these instructions on <a
href="http://alex.charrett.com/bind-on-windows-mainmenu-3">installing and configuring BIND</a> and configuring a zone for your local domain.<ol><li>I installed BIND to <code>C:\Windows\system32\dns</code>.</li><li>Here is my <code>named.conf </code>in its entirety.<br/><br/><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">options {
    directory &quot;;c:\windows\system32\dns\zones&quot;;
    allow-transfer { none; };
    forward only;
    forwarders {
        //208.67.222.222; // OpenDNS
        //208.67.220.220;
        8.8.8.8; // Google DNS
        8.8.4.4;
    };
    query-source address * port 53;
};
&nbsp;
/*
logging {
    channel queries_log {
        file &quot;c:\windows\system32\dns\var\queries.log&quot;;
        print-severity yes;
        print-time yes;
    };
    category queries { queries_log ; };
};
*/
&nbsp;
zone &quot;work.local&quot; IN {
    type master;
    file &quot;work.local.txt&quot;;
};
&nbsp;
key &quot;rndc-key&quot; {
    algorithm hmac-md5;
    secret &quot;xxxxxxxxxxxxxxxxxxxxxxxx&quot;;
};
&nbsp;
controls {
    inet 127.0.0.1 port 953
        allow { 127.0.0.1; } keys { &quot;rndc-key&quot;; };
};</pre></div></div></li><li>I created a zone file for my development domain work.local following this <a
href="http://www.xenocafe.com/tutorials/dns_linux/redhat/dns_linux_redhat-part2.php">zone file example</a>. Here is the zone file in its entirety.  Note the <code>CNAME </code>wildcard record.<br/><br/><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">$TTL 86400
@	IN SOA	ns1.work.local.	admin.work.local. (
			2008102403
			10800
			3600
			604800
			86400 )
&nbsp;
@		NS	ns1.work.local.
&nbsp;
	IN A	127.0.0.1
ns1	IN A	127.0.0.1
www	IN A	127.0.0.1
*	IN CNAME	www</pre></div></div></li></ol></li><li>Start or restart the BIND service.</li><li>Configure you network connection to use 127.0.0.1 as your primary nameserver, instead of DHCP.  My IPv4 properties look like this:<a
href="http://blog.straylightrun.net/wp-content/uploads/2010/05/ipconfig.jpg"><br/><br/><img
style="display: inline; border: 0px;" title="Set DNS nameserver to 127.0.0.1" src="http://blog.straylightrun.net/wp-content/uploads/2010/05/ipconfig_thumb.jpg" border="0" alt="Set DNS nameserver to 127.0.0.1" width="499" height="581" /></a></li><li>Flush the Windows DNS cache by running:<br/><br/><div
class="wp_syntax"><div
class="code"><pre class="dos" style="font-family:monospace;">C:\<span style="color: #33cc33;">&gt;</span> ipconfig /flushdns</pre></div></div></li><li>Test BIND by pinging <code>www.work.local</code>.  If you have errors, you can uncomment the logging block in <code>named.conf</code>.</li><li>Once that is working, create a <code>VirtualHost </code>in Apache for your development domain.  Thanks to <a
href="http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html#virtualdocumentroot"><code>VirtualDocumentRoot</code></a>, we can map any number of subdomains to project roots.  Here is my <code>VirtualHost </code>block.<br/><br/><div
class="wp_syntax"><div
class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span>  127.0.0.1&gt;
    <span style="color: #00007f;">ServerName</span> www.work.local
    <span style="color: #00007f;">ServerAlias</span> *.work.local
    <span style="color: #00007f;">VirtualDocumentRoot</span> <span style="color: #7f007f;">&quot;C:/_work/%1&quot;</span>
    &lt;<span style="color: #000000; font-weight:bold;">Directory</span>  C:/_work&gt;
        <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">Indexes</span> <span style="color: #0000ff;">FollowSymLinks</span> <span style="color: #0000ff;">Includes</span> ExecCGI
        <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
        <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div></li><li>Start or restart Apache.</li><li>Create a directory in <code>C:\_work</code>, for example, <code>C:\_work\awesomeapp</code>.  Create a test index.html file in that directory.</li><li>You should now be able to go to <a
href="http://awesomeapp.work.local">http://awesomeapp.work.local</a> in your browser and see your index.html file!</li></ol><p>Now, you should be able to repeat step 8 for any new website you create!  No editing of <code>hosts </code>files, no bouncing the webserver!  Just create the project directory and it’s immediately available.</p><p>One other important note: Firefox has its own DNS cache independent of the OS.  For sanity, restarting Firefox resets its DNS cache. You can also <a
href="http://www.techiecorner.com/225/how-to-disable-firefox-dns-cache/">permanently disable DNS caching in Firefox</a>.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2010/05/10/throw-away-your-hosts-file-developing-locally-with-bind/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Securely Running A Command As Root</title><link>http://blog.straylightrun.net/2010/02/22/securely-running-a-command-as-root/</link> <comments>http://blog.straylightrun.net/2010/02/22/securely-running-a-command-as-root/#comments</comments> <pubDate>Mon, 22 Feb 2010 22:21:19 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[deploy]]></category> <category><![CDATA[root]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[setuid]]></category> <category><![CDATA[sudo]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2010/02/22/securely-running-a-command-as-root/</guid> <description><![CDATA[As much as I wish we deployed builds from our continuous integration server, all but one of our products is deployed with good ol’ `svn up`.&#160; Developers generally have access to only one web server, so I needed an rsync command to propagate new code to the rest of the web servers.&#160; I wanted normal [...]]]></description> <content:encoded><![CDATA[<p>As much as I wish we deployed builds from our <a
href="http://martinfowler.com/articles/continuousIntegration.html">continuous integration</a> server, all but one of our products is deployed with good ol’ <code>`svn up`</code>.&#160; Developers generally have access to only one web server, so I needed an <code>rsync </code>command to propagate new code to the rest of the web servers.&#160; I wanted normal user accounts to be able to run it at any time in any directory with one command.&#160; Then developers would be instructed to run this command after updating any files.</p><p>So I whipped up an shell script that called <code>rsync</code> with some predefined options and targets.&#160; Unfortunately, in order to preserve ownership and permissions in the destination, <code>rsync </code>needed to be run as <code>root</code>.</p><p>At first, I looked at the <code>setuid </code>bit. By changing the ownership of the <code>rsync </code>shell script and running <code>`chmod u+s`</code> on the script, setting the setuid, any user could execute it and it would run as <code>root</code>. Well, it turns out that the kernel will not honor <code>setuid </code>on shell scripts for security reasons. But what if I wrote a C program instead of a shell script? That actually worked, and ran with <code>root </code><em>privileges</em>, but it still did not <code>rsync </code><em>as</em> root for some reason. So that was out.</p><p>The second solution was to insert <code>sudo </code>before the <code>rsync </code>command in the script. I modified <code>/etc/sudoers</code> to allow the users group to run <code>rsync </code>under <code>sudo</code>. That worked perfectly. So if I put this script in <code>/usr/local/bin</code>, I would be done. But I had already written this magnificent (two-line) C program.&#160; Why not make it even more secure (<code>sudo </code>does not work on shell scripts either)?&#160; Instead of allowing all users to run <code>rsync </code>under <code>sudo</code>, I could limit them to running only <em>my </em>C program under <code>sudo</code>, instead of <code>rsync </code>in general. Then, in my script, I could replace <code>rsync </code>with my C program. So that’s what I did. I again modified <code>/etc/sudoers</code> and my shell script, threw both the script and C executable in <code>/usr/local/bin </code>and I was done.</p><p>I named the final command <code>`zipsync`</code>. Here is the shell script for that, anonymized a bit.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>vhosts
&nbsp;
<span style="color: #666666; font-style: italic;"># repeat for each web server</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> zipsync.bin \
   <span style="color: #660033;">-av</span> <span style="color: #660033;">--delete</span> \
   <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;.svn&quot;</span> \
   <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;logs&quot;</span> \
   <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;tmp&quot;</span> \
   <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;cache&quot;</span> \
   <span style="color: #660033;">--exclude</span>=<span style="color: #ff0000;">&quot;*.swp&quot;</span> \
   <span style="color: #000000; font-weight: bold;">*</span> 192.168.1.101:<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>vhosts
&nbsp;
<span style="color: #7a0874; font-weight: bold;">cd</span> -</pre></td></tr></table></div><p>And the C program, <code>zipsync.bin</code>.</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td
class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;unistd.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span><span style="color: #339933;">**</span> argv<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #339933;">*</span>argv <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;rsync&quot;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> execvp<span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>argv<span style="color: #339933;">,</span> argv<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2010/02/22/securely-running-a-command-as-root/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Clearing The Linux Buffer Cache</title><link>http://blog.straylightrun.net/2009/12/03/clearing-the-linux-buffer-cache/</link> <comments>http://blog.straylightrun.net/2009/12/03/clearing-the-linux-buffer-cache/#comments</comments> <pubDate>Thu, 03 Dec 2009 19:22:45 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Performance]]></category> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[buffer cache]]></category> <category><![CDATA[disk]]></category> <category><![CDATA[logs]]></category> <category><![CDATA[mysql]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2009/12/03/clearing-the-linux-buffer-cache/</guid> <description><![CDATA[According to these Munin memory graphs, the large orange area is the OS buffer cache – a buffer the OS uses to cache plain ol’ file data on disk.&#160; The graph below shows one of our web servers after we upgraded its memory.&#160; It makes sense that most of the memory not used by apps [...]]]></description> <content:encoded><![CDATA[<p>According to these <a
href="http://munin.projects.linpro.no/">Munin</a> memory graphs, the large orange area is the OS buffer cache – a buffer the OS uses to cache plain ol’ file data on disk.&#160; The graph below shows one of our web servers after we upgraded its memory.&#160;</p><p><img
style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Web server memory usage" border="0" alt="Web server memory usage" src="http://blog.straylightrun.net/wp-content/uploads/2009/12/zsweb001memorymonth.png" width="495" height="408" /></p><p>It makes sense that most of the memory not used by apps would be used by the OS to improve disk access.&#160; So seeing the memory graphs filled with orange is generally a good thing.&#160; After a few days, I watched the orange area grow and thought, “Great!&#160; LInux is putting all that extra memory to use.”&#160; I thought in my head that maybe it was caching images and CSS files to serve to Apache.&#160; But was that true?</p><p><strong><u>Looking At A Different Server</u></strong></p><p>Here is a memory graph from one of our database servers after the RAM upgrade.</p><p><img
style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Database server memory usage" border="0" alt="Database server memory usage" src="http://blog.straylightrun.net/wp-content/uploads/2009/12/zsdb001memorymonth.png" width="495" height="408" /></p><p>Again, I first thought that the OS was caching all that juicy database data from disk.&#160; The problem is that we don’t have 12GB of data, and that step pattern growth was suspiciously consistent.</p><p>Looking again at the web server graph, I saw giant downward spikes of blue color, where the buffer cache was emptied.&#160; (The blue is unused memory.)&#160; These occurred every day at 4 am, and on Sundays there’s a huge one.&#160; What happens every day at 4 am?&#160; The logs are rotated.&#160; And on Sundays, the granddaddy log of them all – the Apache log – is rotated.</p><p><strong><u>The Problem</u></strong></p><p>It was starting to make sense.&#160; Log files seem to take up most of the OS buffer cache on the web servers.&#160; Not optimal, I’m sure.&#160; And when they’re rotated, the data in the cache is invalidated and thus freed.</p><p>Here is a memory graph for one of our other database servers.</p><p> <img
style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Database server memory usage" border="0" alt="Database server memory usage" src="http://blog.straylightrun.net/wp-content/uploads/2009/12/zsdb002memorymonth.png" width="495" height="408" /></p><p>That step pattern growth is missing!&#160; In fact, most of RAM is unused.&#160; What is the difference between the first database server and this one?&#160; The first has the <code>`mysqldump`</code> backup.&#160; It occurs every night at 2:30 am, right when those step changes occur on its memory usage graph.</p><p>It was clear to me that most of the OS buffer cache was wasted on logs and backups and such.&#160; There had to be a way to tell the OS not to cache a file.&#160;</p><p><strong><u>The Solution</u></strong></p><p>Google gave me this page: <a
href="http://insights.oetiker.ch/linux/fadvise.html">Improving Linux performance by preserving Buffer Cache State</a>.&#160; I copied the little C program into a file and ran it on all the <code>`mysqldump`</code> backups.&#160; Here is the what happened to the memory usage.</p><p><img
style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Database server memory usage" border="0" alt="Database server memory usage" src="http://blog.straylightrun.net/wp-content/uploads/2009/12/zsdb001memoryweek.png" width="495" height="408" /></p><p>Quite a bit of buffer cache was freed.&#160; On that night’s backup, I logged the buffer cache size before the backup and after.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% cat 2008.08.21.02.30.log
Starting at Thu Aug 21 02:30:03 EDT 2008
=========================================
Cached:        4490232 kB
Cached:        5350908 kB
=========================================
Ending at Thu Aug 21 02:30:55 EDT 2008</pre></div></div><p>Just under a gigabyte increase in buffer cache size.&#160; What was the size of the new backup file?</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% ll 2008.08.21.02.30.sql
-rw-r--r-- 1 root root 879727872 Aug 21 02:30 2008.08.21.02.30.sql</pre></div></div><p>About 900MB.</p><p><strong><u>Did It Work?</u></strong></p><p>I used the C program on that page to ensure no database backups were cached by the OS.&#160; I did the same on the web servers in the <code>logrotate</code> config files.&#160; A couple days later, I checked the memory graph on the database server that performed the backup.&#160; Notice how the buffer cache did not fill up.&#160; It looked like the program worked, and the OS was free to cache more important things.</p><p><img
style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Database server memory usage" border="0" alt="Database server memory usage" src="http://blog.straylightrun.net/wp-content/uploads/2009/12/zsdb001memoryweek2.png" width="495" height="408" /></p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/12/03/clearing-the-linux-buffer-cache/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Storing Apache Virtual Hosts In A Database</title><link>http://blog.straylightrun.net/2009/07/31/storing-apache-virtual-hosts-in-a-database/</link> <comments>http://blog.straylightrun.net/2009/07/31/storing-apache-virtual-hosts-in-a-database/#comments</comments> <pubDate>Fri, 31 Jul 2009 20:29:04 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[apr]]></category> <category><![CDATA[dbd]]></category> <category><![CDATA[mysql]]></category> <category><![CDATA[redhat enterprise]]></category> <category><![CDATA[rhel]]></category> <category><![CDATA[virtual host]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/?p=219</guid> <description><![CDATA[At work, we had set up some wildcard virtual hosts in Apache config, and that got us by for quite some time.  But the time came when we needed finer-grained control of where to send incoming requests for different domains.  I needed to store my virtual hosts in a Mysql database, mapping domains to project [...]]]></description> <content:encoded><![CDATA[<p>At work, we had set up some wildcard virtual hosts in Apache config, and that got us by for quite some time.  But the time came when we needed finer-grained control of where to send incoming requests for different domains.  I needed to store my virtual hosts in a Mysql database, mapping domains to project directories.</p><p>I&#8217;ll spare you the problems I ran into and overcame, and just list the steps to get this done.  These instructions are based on a 64-bit, RHEL 5 server running the pre-packaged Apache server.  So if you follow these instructions on a different setup, of course, filenames, directories, versions, etc. may differ.</p><p><strong><span
style="text-decoration: underline;">Install mod_vhost_dbd</span></strong></p><p>Download <a
href="http://code.google.com/p/dbd-modules/"><code>dbd-modules</code></a> from Google Code.  This is a great piece of code in the form of an Apache module that uses <a
href="http://httpd.apache.org/docs/2.2/mod/mod_dbd.html"><code>mod_dbd</code></a> and a DBD Mysql (or other database) driver to fetch the <code>DocumentRoot </code>for a given domain from a database.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% wget http://dbd-modules.googlecode.com/files/dbd-modules-1.0.5.zip</pre></div></div><p>Unzip the archive in a directory. As indicated on the website, <a
href="http://code.google.com/p/dbd-modules/wiki/Building">build and install the module</a>.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% apxs -c mod_vhost_dbd.c
% apxs -i mod_vhost_dbd.la</pre></div></div><p>This places <code>mod_vhost_dbd.so </code>in <code>/usr/lib64/httpd/modules</code>.  Enable both this module and <code>mod_dbd </code>by adding two lines to <code>httpd.conf</code>, or equivalently creating a new include file in<code> /etc/httpd/conf.d</code> containing these lines.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">LoadModule dbd_module modules/mod_dbd.so
LoadModule vhost_dbd_module modules/mod_vhost_dbd.so</pre></div></div><p>In true unit fashion, now might be a good time to restart Apache, just so you can be sure everything is working up to this point.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% service httpd restart</pre></div></div><p><strong><span
style="text-decoration: underline;">Install Mysql DBD Driver to APR</span></strong></p><p>Unfortunately, on my system, the Mysql DBD driver was nowhere to be found.  I had to rebuild Apache Portable Runtime (APR) utils with the Mysql driver enabled.</p><p>Download <a
href="http://apr.apache.org/"><code>apr</code></a> and <a
href="http://apr.apache.org/"><code>apr-util</code></a> from Apache.  Note these are not the latest versions, but the versions that <span
style="text-decoration: line-through;">matched the packages in</span> worked for RHEL 5.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% wget http://archive.apache.org/dist/apr-1.2.8.tar.bz2
% wget http://archive.apache.org/dist/apr-util-1.2.8.tar.bz2</pre></div></div><p>Unpack and untar these archives in the same parent directory.</p><p>Build and install APR.  Now, I do not think this is absolutely necessary, but it seems like a good idea to keep the versions in sync.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% ./configure --prefix=/usr
% make
% make install</pre></div></div><p>Build and install <code>apr-util</code>.  Due to licensing issues, <code>apr-util </code>does not actually contain the Mysql DBD driver until <code>apr-util-1.2.12</code>.  Prior to that version, it must be downloaded separately, and the configure script rebuilt.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% wget http://apache.webthing.com/svn/apache/apr/apr_dbd_mysql.c
% ./buildconf --with-apr=../apr-1.2.7</pre></div></div><p>Now for the three commands every Linux admin loves.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% ./configure --prefix=/usr --with-apr=/usr --libdir=/usr/lib64 --with-expat=builtin --with-ldap-include=/usr/include --with-ldap-lib=/usr/lib64 --with-ldap=ldap --with-mysql
% make
% make install</pre></div></div><p>The first time I tried this, Apache could not find any LDAP-related modules.  Adding those configure switches seemed to do the trick.  Restart Apache.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% service httpd restart</pre></div></div><p>Apache should now be able to query a Mysql database to get the <code>DocumentRoot </code>for a domain.  My <code>VirtualHost</code> block looked something like this.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">&lt;VirtualHost *:80&gt;
    ServerName *.example.com
    DocumentRoot &quot;/path/to/default/document/root&quot;
&nbsp;
    DBDriver mysql
    DBDParams host=localhost,user=root,pass=secret,dbname=vhosts
&nbsp;
    DBDocRoot &quot;SELECT path FROM vhosts WHERE host = %s&quot;  HOSTNAME
&lt;/VirtualHost&gt;</pre></div></div><p>For more details and instructions on <a
href="http://code.google.com/p/dbd-modules/wiki/mod_vhost_dbd"><code>mod_vhost_dbd</code> configuration directives, read the project wiki</a>.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/07/31/storing-apache-virtual-hosts-in-a-database/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Upgrading PHP 5.1 on CentOS 5.3</title><link>http://blog.straylightrun.net/2009/07/15/upgrading-php-5-1-on-centos-5-3/</link> <comments>http://blog.straylightrun.net/2009/07/15/upgrading-php-5-1-on-centos-5-3/#comments</comments> <pubDate>Wed, 15 Jul 2009 17:05:37 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[centos]]></category> <category><![CDATA[redhat enterprise]]></category> <category><![CDATA[rhel]]></category> <category><![CDATA[yum]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2009/07/15/upgrading-php-5-1-on-centos-5-3/</guid> <description><![CDATA[To test things on our RHEL 5 production servers, I fire up CentOS 5 in VMWare.&#160; While we build PHP 5.2 manually in production, I try to avoid doing so just for testing. Unfortunately, CentOS 5 is packaged with PHP 5.1 by default which becomes a big difference between my testing and production environments.&#160; Fortunately, [...]]]></description> <content:encoded><![CDATA[<p>To test things on our RHEL 5 production servers, I fire up CentOS 5 in VMWare.&nbsp; While we build PHP 5.2 manually in production, I try to avoid doing so just for testing. Unfortunately, CentOS 5 is packaged with PHP 5.1 by default which becomes a big difference between my testing and production environments.&nbsp; Fortunately, there is a CentOS yum repository out there with PHP 5.2.&nbsp; I thought I&#8217;d document this here for anyone else with the same problem.</p><p>The solution I found starts with <a
href="http://www.centos.org/modules/newbb/viewtopic.php?topic_id=19290&amp;forum=38">this thread about upgrading PHP on the CentOS forums</a>.&nbsp; To summarize, run these commands:</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% cd /etc/yum.repos.d
% wget http://dev.cnetos.org/centos/5/CentOS-Testing.repo</pre></div></div><p>Then, edit the .repo file and set the <code>"enabled"</code> value to <code>"1"</code>.</p><div
class="wp_syntax"><div
class="code"><pre class="sh" style="font-family:monospace;">% yum list available php
Available Packages
php.i386                                 5.2.6-2.el5s2          c5-testing</pre></div></div> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/07/15/upgrading-php-5-1-on-centos-5-3/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Tip Of The Day: Removing .htaccess</title><link>http://blog.straylightrun.net/2009/06/17/tip-of-the-day-removing-htaccess/</link> <comments>http://blog.straylightrun.net/2009/06/17/tip-of-the-day-removing-htaccess/#comments</comments> <pubDate>Wed, 17 Jun 2009 20:48:21 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Performance]]></category> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[apache]]></category> <category><![CDATA[htaccess]]></category> <category><![CDATA[tips]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/?p=205</guid> <description><![CDATA[At work, every project has an .htaccess file containing at the least some mod_rewrite rules.  This way, all I need to do to run a project is check it out of version control.  I don&#8217;t need to modify my local Apache configuration. But turning this option on and allowing .htaccess files may be a performance [...]]]></description> <content:encoded><![CDATA[<p>At work, every project has an <code>.htaccess</code> file containing at the least some <code>mod_rewrite </code>rules.  This way, all I need to do to run a project is check it out of version control.  I don&#8217;t need to modify my local Apache configuration.</p><p>But turning this option on and allowing <code>.htaccess</code> files may be a performance hit.  More specifically, enabling the <code><a
href="http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride">AllowOverride</a> </code>option in Apache is a performance hit.  The <a
href="http://httpd.apache.org/docs/2.2/misc/perf-tuning.html">Apache docs</a> sums up the problem best:</p><blockquote><p> &#8220;Wherever in your URL-space you allow overrides (typically <code>.htaccess</code> files) Apache will attempt to open <code>.htaccess</code> for each filename component. For example,</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
</pre></td><td
class="code"><pre class="xml" style="font-family:monospace;">DocumentRoot /www/htdocs
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Directory</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   AllowOverride all
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Directory<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div><p>and a request is made for the URI <code>/index.html</code>. Then Apache will attempt to open <code>/.htaccess</code>, <code>/www/.htaccess</code>, and <code>/www/htdocs/.htaccess</code>.&#8221;</p></blockquote><p>So I disabled all <code>.htaccess </code>files in production, and inserted each file&#8217;s individual <code>mod_rewrite </code>rules into the main Apache config file. After a quick <a
href="http://blog.straylightrun.net/2009/04/23/apache-bench/">Apache Bench</a> run, one project looked around 3% faster. Note that there are a few other useful optimizations on that page.</p> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/06/17/tip-of-the-day-removing-htaccess/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Running IE6 Virtual PC Image in VMware</title><link>http://blog.straylightrun.net/2009/05/13/running-ie6-virtual-pc-image-in-vmware/</link> <comments>http://blog.straylightrun.net/2009/05/13/running-ie6-virtual-pc-image-in-vmware/#comments</comments> <pubDate>Wed, 13 May 2009 14:47:33 +0000</pubDate> <dc:creator>gerard</dc:creator> <category><![CDATA[Sysadmin]]></category> <category><![CDATA[virtual pc]]></category> <category><![CDATA[virtualization]]></category> <category><![CDATA[vmware]]></category> <category><![CDATA[windows xp]]></category> <category><![CDATA[winxp]]></category> <guid
isPermaLink="false">http://blog.straylightrun.net/2009/05/13/running-ie6-virtual-pc-image-in-vmware/</guid> <description><![CDATA[Though I have heard good things about Parallels and VirtualBox, I have always been a user of VMware.&#160; In particular, VMware Workstation.&#160; Workstation is great for firing up multiple Linux instances and testing out load-balancing or proxying scenarios.&#160; I haven&#8217;t really figured out any use for Windows VM&#8217;s other than testing IE6.&#160; While there are [...]]]></description> <content:encoded><![CDATA[<p>Though I have heard good things about <a
href="http://www.parallels.com">Parallels</a> and <a
href="http://www.virtualbox.org">VirtualBox</a>, I have always been a user of <a
href="http://www.vmware.com">VMware</a>.&nbsp; In particular, <a
href="http://www.vmware.com/products/ws/">VMware Workstation</a>.&nbsp; Workstation is great for firing up multiple Linux instances and testing out load-balancing or proxying scenarios.&nbsp; I haven&#8217;t really figured out any use for Windows VM&#8217;s other than testing IE6.&nbsp;</p><p>While there are a few Virtual PC hard disk images (.vhd) for Windows XP around, VMware cannot directly import .vhd files.&nbsp; It needs the actual Virtual PC virtual machine file (.vmc).&nbsp; After again losing my Windows XP virtual machine that I use for IE6 testing, I thought I&#8217;d document the process of running Windows XP in VMware so I don&#8217;t have to figure it out again the next time it happens.&nbsp;</p><p>Note: though these instructions are for VMware Workstation, some of this may apply to the <a
href="http://www.vmware.com/products/player/">free VMware Player</a>.</p><ol><li><a
href="http://www.microsoft.com/downloads/details.aspx?FamilyId=21EABB90-958F-4B64-B5F1-73D0A413C8EF&amp;displaylang=en">Download the IE6 Virtual PC Virtual Hard Disk (.vhd) image from Microsoft</a>.<li><a
href="http://www.microsoft.com/windows/virtual-pc/">Download and install Virtual PC from Microsoft</a>, if you don&#8217;t have it already.<li>Start Virtual PC.&nbsp; If you have no virtual machines, you will get the New Virtual Machine Wizard.&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard1.jpg"><img
style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="vmcwizard1" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard1-thumb.jpg" width="228" border="0"></a><li>Select &#8220;Use default settings to create a new virtual machine&#8221;. Click Next.<br
/>&nbsp;<a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard2.jpg"><img
style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="vmcwizard2" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard2-thumb.jpg" width="228" border="0"></a><li>Pick a location to save your Virtual PC virtual machine.&nbsp; This should be the location you will create the VMware virtual machine.&nbsp; I keep all my VM&#8217;s in the same directory with meaningful names.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard3.jpg"><img
style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="163" alt="vmcwizard3" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard3-thumb.jpg" width="228" border="0"></a><li>Click Finish to create the new virtual machine.&nbsp; <br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard4.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="163" alt="vmcwizard4" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmcwizard4-thumb.jpg" width="228" border="0"></a><li>If you selected &#8220;When I click Finish, open Settings,&#8221; in the previous step, you will see the settings dialog.&nbsp; If you did not, select the new VM and click Settings.&nbsp; Select &#8220;Virtual hard disk file:&#8221; and find the .vhd file you downloaded in step 1.&nbsp; After finding it, click OK.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/startvmc1.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="170" alt="startvmc1" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/startvmc1-thumb.jpg" width="228" border="0"></a><li>You should see your VM in the Virtual PC Console.&nbsp; <br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/startvmc2.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="167" alt="startvmc2" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/startvmc2-thumb.jpg" width="228" border="0"></a><li>Select your VM and click Start.&nbsp; Your Windows XP virtual machine should boot in its own window.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/startvmc3.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="144" alt="startvmc3" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/startvmc3-thumb.jpg" width="228" border="0"></a><li>Shut down the virtual machine using the Start button.&nbsp; Then exit out of Virtual PC.&nbsp; Start VMware Workstation.&nbsp; Once it&#8217;s started, select &#8220;Import or Export&#8230;&#8221; from the &#8220;File&#8221; menu.&nbsp; You should see the Conversion Wizard.&nbsp; Click Next. <br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard0.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="199" alt="vmxwizard0" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard0-thumb.jpg" width="228" border="0"></a>&nbsp;&nbsp;<li>You are at Step 1 of the conversion. Click Next to select a Source Type. Under &#8220;Select the type of source you want to use:&#8221;, select Other.&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard1.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="199" alt="vmxwizard1" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard1-thumb.jpg" width="228" border="0"></a><li>Under &#8220;Source VM or image:&#8221;, find the Virtual PC (.vmc) file you created earlier.&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard2.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="199" alt="vmxwizard2" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard2-thumb.jpg" width="228" border="0"></a><li>Select &#8220;Convert all disks and maintain size.&#8221; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard3.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard3" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard3-thumb.jpg" width="228" border="0"></a><li>You are at Step 2 of the conversion. Click Next to select a destination type.&nbsp; Under &#8220;Select the destination type,&#8221; select &#8220;Other Virtual Machine.&#8221;&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard5.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard5" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard5-thumb.jpg" width="228" border="0"></a><li>Under &#8220;Virtual machine name,&#8221; fill in a meaningful name.&nbsp; Under &#8220;Location:&#8221;, find the place you want to store your virtual machine.&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard6.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard6" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard6-thumb.jpg" width="228" border="0"></a><li>The wizard tells you that the source files are in Microsoft virtual disk (.vhd) format.&nbsp; Under &#8220;How do you want to convert them?&#8221;, select &#8220;Import and convert (full-clone).&#8221;&nbsp; Under &#8220;Disk Allocation,&#8221; Select &#8220;Allow virtual disk files to expand.&#8221;&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard7.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard7" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard7-thumb.jpg" width="228" border="0"></a><li>The next step allows you to configure your VM networking.&nbsp; You should probably stick to the default of 1 NIC, bridged, that connects at power on.&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard8.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard8" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard8-thumb.jpg" width="228" border="0"></a><li>Step 3 allows for some VMware customisation.&nbsp; You definitely want to install the VMware Tools.&nbsp; Click Next.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard9.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard9" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard9-thumb.jpg" width="228" border="0"></a><li>You&#8217;re Virtual PC image is ready to be converted to VMware.&nbsp; Click Finish to begin the conversion!<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard10.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="200" alt="vmxwizard10" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/vmxwizard10-thumb.jpg" width="228" border="0"></a><li>Get up from your desk and take a walk around.&nbsp; Go get a cup of coffee.&nbsp;<li>After the conversion is completed, you should see your new Windows XP virtual machine in VMware Workstation.<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/finished1.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="217" alt="finished1" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/finished1-thumb.jpg" width="228" border="0"></a><li>Click on &#8220;Power on this virtual machine&#8221; and your Windows XP VM should boot inside of VMware Workstation.&nbsp; You can uninstall Virtual PC at this point, if you want (which is likely, since you&#8217;re running VMware).<br
/><a
href="http://blog.straylightrun.net/wp-content/uploads/2009/05/finished2.jpg"><img
style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="144" alt="finished2" src="http://blog.straylightrun.net/wp-content/uploads/2009/05/finished2-thumb.jpg" width="228" border="0"></a>&nbsp;&nbsp;</li></ol> ]]></content:encoded> <wfw:commentRss>http://blog.straylightrun.net/2009/05/13/running-ie6-virtual-pc-image-in-vmware/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> </channel> </rss>
