<?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>Not Just a Hat Rack &#187; Server</title>
	<atom:link href="http://notjustahatrack.com/posts/category/server/feed/" rel="self" type="application/rss+xml" />
	<link>http://notjustahatrack.com</link>
	<description>Development, design, etc.</description>
	<lastBuildDate>Mon, 18 Apr 2011 16:05:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Accessing Virtual Hosts Over a LAN (Including Parallels)</title>
		<link>http://notjustahatrack.com/posts/accessing-virtual-hosts-over-a-lan-including-parallels/</link>
		<comments>http://notjustahatrack.com/posts/accessing-virtual-hosts-over-a-lan-including-parallels/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 02:47:26 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://notjustahatrack.com/?p=13</guid>
		<description><![CDATA[I wanted to be able to access my development environment from within Parallels, which is running Windows XP. Since requests in the Parallels machine web browser don&#8217;t reach apache running on my Mac, I had to find some way to to access it. If Parallels is set to &#8220;Shared Networking,&#8221; it will be included in [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to be able to access my development environment from within Parallels, which is running Windows XP.  Since requests in the Parallels machine web browser don&#8217;t reach apache running on my Mac, I had to find some way to to access it.  If Parallels is set to &#8220;Shared Networking,&#8221; it will be included in a &#8220;simulated network&#8221; with the Mac, and as such you can just treat it like any other networked computer.  So the question becomes, how do you connect to a virtual host from a computer in the same LAN?<span id="more-13"></span></p>
<h3>Step 1: Create the Virtual Host</h3>
<p>When setting up a development environment, it&#8217;s almost always a good idea to use virtual hosts, because then you can easily host many separate test sites on the same machine.  To do so:</p>
<ul>
<li>Find the apache directory on your computer.  Mine was at <code>/etc/apache2/</code>.</li>
<li>Open the <code>httpd.conf</code> file and find the following lines:</li>
</ul>
<pre><code>
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
</code></pre>
<ul>
<li>Make sure the <code>Include</code> line is uncommented (make sure there&#8217;s no # at the beginning of the line</li>
<li>Open the <code>http-vhosts.conf</code> file and add a virtual host.  It should look something like this:</li>
</ul>
<pre><code>
&lt;VirtualHost *:80&gt;
	ServerName your.virtual.host
	DocumentRoot "/your/files/location/"
&lt;/VirtualHost&gt;
</code></pre>
<p>This setup basically means anyone connecting to your computer through port 80 (a web browser), looking for <code>your.virtual.host</code>, will see the files contained in the <code>/your/files/location/</code> directory.</p>
<p>This is just the bare minimum for setting up a virtual host, and if you&#8217;re new to the concept you should probably explore the other options.  There should be examples already in the virtual host configuration file for more info.</p>
<h3>Step 2: Direct Your Computer to the Virtual Host</h3>
<p>So you&#8217;ve set up the virtual host, but if you type <code>your.virtual.host</code> into your web browser, it will look for it directly on the web first.  You need to tell the browser to go directly to your computer if <code>your.virtual.host</code> is specified.  To do so, open up the <code>hosts</code> file, which is typically located in the <code>/etc/</code> directory.</p>
<p>You should see some entries for <code>localhost</code> already.  Add another which ties your virtual host to your local machine:</p>
<pre><code>
127.0.0.1&nbsp;&nbsp;&nbsp;&nbsp;your.virtual.host
</code></pre>
<h3>Step 3: Direct Other Computers to your Virtual Host</h3>
<p>Now for any other networked computers, you just need to direct requests for <code>your.virtual.host</code> to your local computer.  To do so for Unix based machines you can edit the <code>/etc/hosts</code> files as mentioned above.  For Windows XP machines, the host file is located at <code>C:\Windows\system32\drivers\etc\hosts</code>.</p>
<p>The most difficult question to answer is, how do you know the IP address of your local computer on a network?  Typically your computer will be assigned an IP address dynamically, so you&#8217;ll have to edit the <code>hosts</code> file every time the computer logs back on.  To get the IP address, check your connection in the Network Preferences section.  You could also try assigning a static IP address somewhere at the end of the available range, but this isn&#8217;t recommended because it could cause conflicts.</p>
<p>For Parallels though, the IP address of the Mac hosting the virtual machine is static, and can be found by viewing the &#8220;Parallels NAT&#8221; settings in the Network Preferences section.  Throw that IP address in the <code>hosts</code> file along with the address of your virtual host, and you should be good to go!</p>
]]></content:encoded>
			<wfw:commentRss>http://notjustahatrack.com/posts/accessing-virtual-hosts-over-a-lan-including-parallels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Development Environment for WordPress-Driven Sites</title>
		<link>http://notjustahatrack.com/posts/initial-development-environment-for-wordpress-driven-sites/</link>
		<comments>http://notjustahatrack.com/posts/initial-development-environment-for-wordpress-driven-sites/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 15:47:13 +0000</pubDate>
		<dc:creator>andrew</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://notjustahatrack.com/?p=7</guid>
		<description><![CDATA[Creating a good development environment is obviously very important for any new development project, and with database-driven applications, it&#8217;s often a hassle to keep files and data in sync. With this in mind, I tried to come up with an efficient method of pushing a local development copy of this site to its live server. [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a good development environment is obviously very important for any new development project, and with database-driven applications, it&#8217;s often a hassle to keep files <em>and</em> data in sync.  With this in mind, I tried to come up with an efficient method of pushing a local development copy of this site to its live server.<span id="more-7"></span></p>
<h3>The Development Environment</h3>
<p>The production environment for the project runs on LAMP (Linux, Apache, MySQL and PHP), and uses WordPress for the blog / CMS duties.  LAMP and WordPress are a snap to set up on OS X and Windows, so I won&#8217;t go into the details here.  For Windows, you can even install a self-contained and self-installing package with all of the technologies, like <a href="http://www.apachefriends.org/en/xampp.html">XAMPP</a>.  If you need help, check google for current instructions.</p>
<h3>Synching the Files</h3>
<p>In the initial stages of development, it&#8217;s common to a multitude of changes throughout the site, and as such it can be inefficient to use simple FTP for pushing changes live.  I was looking for an easy way to instantly sync the development and production servers, and I wasn&#8217;t worried about version control or multiple developers have access to the same code.  If I was, I could have used <a href="http://subversion.tigris.org/">Subversion</a>, but that seemed a little too much for this simple task.  </p>
<p>So instead, I used <a href="http://samba.anu.edu.au/rsync/">rsync</a> over SSH:</p>
<pre><code>
rsync -rve ssh [mylocaldirectory]  [myuser]@[myserver]:[myremotedirectory] --exclude-from=[exclude-file]
</code></pre>
<p>&#8230; and stored the command in a file named <code>update-files.sh</code> so I could execute it whenever I needed to.  You&#8217;ll have to enter your SSH password when you run it, but it&#8217;s considerably more secure this way. Some notes on the command:</p>
<ul>
<li><code>-r</code> makes it recursive (obviously need that)</li>
<li><code>-v</code> makes it verbose (helpful)</li>
<li><code>-e</code> allows you to include a remote shell</li>
<li><code>--exclude-from</code> allows you to specify an exclude file with patterns to ignore in the transfer.  This is helpful because you can exclude domain specific configuration files, <code>.DS_Store files</code>, etc.  Just make a separate file, and include filenames / patterns to ignore one to each line.</li>
</ul>
<p>That&#8217;s it!  In this example you&#8217;ll need remote shell access via ssh, which may be difficult to obtain if you run on a shared host.  If you run into problems you can use rsh or run a rsync server&#8230; check the  rsync man page for more details.</p>
<p>You&#8217;ll also need access to a Unix / Linux command line, which isn&#8217;t a problem for Mac users.  For Windows users, get <a href="http://www.cygwin.com/">Cygwin</a>.</p>
<h3>Synching the Database</h3>
<p>Given the nature of WordPress, to maintain a similar copy of the database across domains would basically require:</p>
<ul>
<li>Backing up the database to be moved</li>
<li>Copying the database backup to the other domain</li>
<li>Restoring the database backup on the other domain</li>
<li>Replacing the domain specific mentions in the WordPress DB</li>
</ul>
<p>Fortunately, all this is easily scripted.  I used two files, first, on my local (development) machine, I created a file named <code>update-db.sh</code>:</p>
<pre><code>
mysqldump -u [db_user] -p [db_password] [db_name] > current.sql
ftp ftp://[username]:[password]@[remote_domain] <<**
cd updater
put current.sql
exit
**
ssh [username]@[domain] 'updater/update-my-db.sh'
</code></pre>
<p>Breaking it down:</p>
<pre><code>
mysqldump -u [db_user] -p [db_password] [db_name] > current.sql
</code></pre>
<p>Dumps the current development database to a .sql file.</p>
<pre><code>
ftp ftp://[username]:[password]@[remote_domain] <<**
cd updater
put current.sql
exit
**
</code></pre>
<p>Connects via ftp, moves into the updater directory and transfers the sql backup.</p>
<pre><code>
ssh [username]@[domain] 'updater/update-my-db.sh'
</code></pre>
<p>Connects via ssh to the remote shell, and executes <code>update-my-db.sh</code>, which should look like this:</p>
<pre><code>
mysql --user=[db_user] --password=[db_password] [db] < ~/updater/current.sql;
mysql -e "UPDATE wp_options SET option_value = '[live domain]' WHERE option_name = 'home'" --user=[db_user] --password=[db_password] [db]
mysql -e "UPDATE wp_options SET option_value = '[live domain + path to wordpress' WHERE option_name = 'siteurl'" --user=[db_user] --password=[db_password] [db]
mysql -e "UPDATE wp_posts SET guid = REPLACE (guid,'[local domain]','[live domain]')" --user=[db_user] --password=[db_password] [db]
exit
</code></pre>
<p>This file needs to be on the remote machine so it can interact with mysql.  Basically, it takes the domain-specific mentions and changes them to point to the live server instead of the development one.</p>
<p>And that's it!  Just run <code>update-db.sh</code> on your development machine and any WordPress changes (posts, pages, options, etc.) should be replicated on the live server.</p>
]]></content:encoded>
			<wfw:commentRss>http://notjustahatrack.com/posts/initial-development-environment-for-wordpress-driven-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

