<?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>Fortasse &#187; Tutorials</title>
	<atom:link href="http://www.fortasse.com/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fortasse.com</link>
	<description>Action at a distance</description>
	<lastBuildDate>Mon, 22 Feb 2010 18:34:15 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tutorial: Backup script</title>
		<link>http://www.fortasse.com/2010/01/tutorials/tutorial-automatic-backup-script/</link>
		<comments>http://www.fortasse.com/2010/01/tutorials/tutorial-automatic-backup-script/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 13:30:35 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.fortasse.com/?p=275</guid>
		<description><![CDATA[
The importance of running a thorough, regularly scheduled back up cannot be overstressed regardless of whether your site is just starting out or has hundreds of viewers per day. Backing up your important files goes a long way towards preventing or easily repairing many headaches that may come along with broken installations or updates, hacking [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://images.fortasse.com/2010/01/terminal1.png"><img class="aligncenter size-full wp-image-319" title="Terminal" src="http://images.fortasse.com/2010/01/terminal1.png" alt="Terminal" width="537" height="248" /></a></p>
<p style="text-align: left;">The importance of running a thorough, regularly scheduled back up cannot be overstressed regardless of whether your site is just starting out or has hundreds of viewers per day. Backing up your important files goes a long way towards preventing or easily repairing many headaches that may come along with broken installations or updates, hacking attempts or if you simply want to move to another domain or hosting provider.﻿﻿ After all, an ounce of prevention is worth a pound of cure. In this post, I will show you a basic script you can use as part of your scheduled back up. It will copy your website to a backup folder, zip the contents of the folder and optionally keep a working mirror of your website&#8211;automagically!<span id="more-275"></span></p>
<h3>Why backup?</h3>
<p>The problem with backing files up is that most people just don&#8217;t see the need to do so until something has happened. Unfortunately, by then it&#8217;s usually too late to fix the problem. In reality, if you do not have your website scheduled for a regular daily backup, you are playing a dangerous game Russian roulette with your information. Once a routine backup plan is put into effect, it will give you the peace of mind that comes along with knowing that if problems should occur, you will have&#8230; a back up!</p>
<p>Most hosting providers do back up everything on their servers, but that doesn&#8217;t necessarily mean they do it often. They may backup the operating system and important information to keep the server running on a daily basis, but most don&#8217;t run daily backups of the websites they are hosting. To be honest, it&#8217;s just not worth the disk space for them&#8211;there could literally be hundreds, even a thousand websites being hosting on a shared server. Of those that do run backups, many charge for restoring the back up they have on copy and it may be weeks or a month old at best. To be honest, they maintain back ups for themselves. It&#8217;s your responsibility to back up your own information.</p>
<h3>Paid versus shell scripts</h3>
<p>There are many back up solutions that rely on the software you have installed on your site. A quick search will bring up a plethora of paid and free plugins available for OsCommerce, Wordpress, CRE Loaded, Joomla, etc. There is a problem with these plugins, though: most rely on your installation to work or be somewhat functional and they run the risk of breaking if you update the plugin or the software. While they are generally much easier to use, they are not the most effective way to back up your site and some only back up the specific software installation, not any other files you may be hosting.</p>
<p>So, how do you get around this? The answer is very simple: good, old reliable shell scripts. Shell scripts have been around forever and they are without a doubt the most reliable way of backing up your information. They aren&#8217;t as user friendly as web site plugins, but they are free, fast, have a proven track record and there is a wealth of information available about how to use them. They do not rely on anything to be installed except, of course, the operating system your host is running, but that&#8217;s assumed. Since they run locally where your information is stored, they are faster than downloading and backing up your site via FTP. It is nice to have a copy of your site downloaded via FTP on hand in case of a major disaster and I do recommend this as well, but that&#8217;s for another topic.</p>
<h3>Getting started</h3>
<p>Before you do anything, though, you need to make sure you have: SSH (shell access) and the ability to run CRON jobs. Godaddy, for example, requires you to activate SSH by phone before you can run CRON jobs, and since you need both, you should go ahead and get it activated before continuing to read. The back up I will show you has been tested on Godaddy via SSH and their CRON job manager, but should work just as well on any other hosting provider that runs Linux with little or no modification necessary. The first script is designed for Wordpress and selectively backs up only Wordpress and any files in the immediate root directory. It assumes that you have installed Wordpress in the root directory. For example: http://www.yourblog.com NOT http://www.yourblog.com/wordpress. The second script can be used for backing up your entire web site&#8211;it merely backs up everything in the public html directory. Again, you can easily modify these scripts to suit your needs. You need only to change the directory or directories that you wish to back up in the scripts.</p>
<h3>Plan of action</h3>
<ol>
<li>Create a directory in your root called<em> &#8216;backups&#8217;</em></li>
<li>Create another directory inside backups called <em>&#8216;dailyback.&#8217;</em></li>
<li>Protect <em>backups</em> with a user name and password using .htaccess and .htpasswd.</li>
<li>Create an empty file inside <em>backups</em> with a <em>plain text editor</em> (no Microsoft Word et al&#8211;Notepad or gedit are good enough!) call it <strong>backup.sh</strong> since this is a shell script we&#8217;re creating.</li>
<li>Into the contents of this file, copy and paste the following script:</li>
</ol>
<p><code> #!/bin/bash<br />
#Compliments of www.fortasse.com<br />
#Displays a greeting and backs up files<br />
#Begin Script<br />
TERM=linux<br />
export TERM<br />
NOWDATE=`date +%m%d%y` # Sets the date variable format for zipped file: MMddyy<br />
clear # clears terminal window<br />
echo<br />
echo "Hi, $USER!"<br />
echo<br />
echo "Beginning backup of files @ `date`"<br />
echo "Backing up wp-content..."<br />
#Copy wp-content<br />
cp -r $HOME/html/wp-content $HOME/html/backups/dailyback<br />
echo "Done!"<br />
echo<br />
#Copy wp-admin<br />
echo "Backing up wp-admin..."<br />
cp -r $HOME/html/wp-admin $HOME/html/backups/dailyback<br />
echo "Done!"<br />
echo<br />
echo "Backing up wp-includes..."<br />
#Copy wp-includes<br />
cp -r $HOME/html/wp-includes $HOME/html/backups/dailyback<br />
echo "Done!"<br />
echo<br />
echo "Backing up files in Wordpress the root folder /html/ ..."<br />
#Copy miscellaneous files in /html/ only<br />
cp $HOME/html/*.* $HOME/html/backups/dailyback<br />
echo "Done!"<br />
echo<br />
echo "Zipping directory structure..."<br />
tar -cvzf $HOME/html/backups/$NOWDATE.tar.gz $HOME/html/backups/dailyback/*<br />
echo "Backup complete!"<br />
#Uncomment the following lines if you DO NOT want to keep a mirror of your site:<br />
#echo "Cleansing backup folder..."<br />
#rm -r $HOME/html/admin/dailyback/*<br />
</code></p>
<p>You will need to do a couple of things before you can run this. If you&#8217;re on Godaddy, you shouldn&#8217;t need to make any changes to the script. If you&#8217;re not on Godaddy, you might need to change the /html/ folder to /public_html/ or whatever it is that your host uses. Make any other changes you need to the directory structure and uncomment the last two lines if you don&#8217;t want to keep a working mirror of your Wordpress blog. Upload it to your web site and test it out by opening an SSH connection and going to the directory you uploaded it to and type:<br />
<code>cd ~/html/backups<br />
sh backup.sh</code></p>
<p>Technically, you don&#8217;t need to do all of that copying. You could simply remove almost everything but the last line and tell the script what directory you want to backup. However, I prefer to keep both a working copy (aka mirror) and a zip at all times. It&#8217;s a lot faster to simply copy the mirror back over if something broke than to have to unzip and restore the archive. Let&#8217;s look at an example of a barebones script that simply zips everything in the public html folder:</p>
<p><code>#!/bin/bash<br />
#Compliments of www.fortasse.com<br />
#Displays a greeting and backs up files<br />
#Begin Script<br />
TERM=linux<br />
export TERM<br />
NOWDATE=`date +%m%d%y` # Sets the date variable format for zipped file: MMddyy<br />
clear # clears terminal window<br />
echo<br />
echo "Hi, $USER!"<br />
echo<br />
echo "Beginning backup of files @ `date`"<br />
echo<br />
echo "Zipping directory structure..."<br />
#Remove the v in -cvzf below if you don't want to see the output<br />
tar -cvzf $HOME/html/backups/$NOWDATE.tar.gz $HOME/html/*<br />
echo "Backup complete!"<br />
</code></p>
<p>In this case, <em>everything</em> in the public html folder was zipped and the corresponding zip file placed in the <em>~/html/backups/ </em>directory. This is really effective if you don&#8217;t want to selectively back up certain files or directories. I run several backups on my server, at different rates and times and for specific files or directories. Not every web site hosted on my account will necessarily go down at the same time. Therefore, making individual back ups of different installations and/or web sites allows me to have a much finer degree of control over my backups. If I zipped the entire site in one file, I would have to worry about over-writing new content on other unaffected web sites contained in the same root when I expand the zip file. That would be another nightmare altogether!</p>
<h3>Backing up your database with MySQLDump</h3>
<p>Backing up your database is also very important. If your database goes, in most cases you&#8217;ll having nothing. Zilch. Zero. No posts, no users, no links, no tags. You get the point. Thankfully, this is fairly easy to do using a shell script.</p>
<h3>Do it!</h3>
<ol>
<li>Create a directory called <em>&#8216;database&#8217;</em> inside the the <em>/html/backups</em> directory.</li>
<li>Copy and paste the following code into the bottom of the <strong>backup.sh </strong>script.</li>
</ol>
<p><code>echo "Backing up Wordpress database"<br />
mysqldump -h YOUR.DBSERVER.COM -uUSERNAME -pPASSWORD DATABASENAME &gt; $HOME/html/backups/database/$NOWDATE.sql<br />
gzip -9 $HOME/html/backups/database/$NOWDATE.sql<br />
echo<br />
echo "Job finished!"</code></p>
<p>Replace <em>YOUR.DBSERVER.COM</em> with wherever your database is stored. It might be locally stored on the machine, or it could be located on a remote server in the case of Godaddy. Replace <em>USERNAME</em> with your username, <em>PASSWORD</em> with your actual password and <em>DATABASENAME</em> with the name of the database you want to backup. Keep the spaces, all dashes and everything else you see intact. -p and <em>PASSWORD</em> are supposed to be connected. Do not make a space between them, or it may not work. Like the file back up script, this will back up the database, zip it and put it in an archive with a time stamped file name.</p>
<h3>Final steps</h3>
<p>You will need to set this script to run through your hosts CRON Job manager. In Godaddy, this is a very simple task. You need to upload the file, open up your Hosting Control Center, go to Cron Jobs and select the file and time you wish to run the shell script. <strong>NOTE: You may get a &#8216;Permission Denied Error!&#8217; In this case, try setting the permissions of the backup.sh file to 755.</strong> For other hosting companies, you may or may not have to use CRON Tab or some other CRON job manager. The commands are simple, but call your hosting company if you have any questions. In either case, <em>you should set up the job to send you an e-mail upon completion</em>. At least for the first few days, to make sure the script is working properly. Caveat: If you left to verbose (-v option) on for tar, you may get a very large e-mail.</p>
<h3>Summary</h3>
<p>So to briefly summarize everything, the first script copies specific directories, creates a mirror and zips the mirrored backup and places it in a backup directory. The file name is the time stamp of the backup date. The second script backs up everything in your public html file (all websites, subdomains, and anything else) and zips it up and does not create a mirror image of your site. The third will backup your SQL database and zip it in a nice little file using gzip. Simple enough, huh?</p>
<p>If all went as planned, you should have a working back up script for your website. I recommend using the script at least daily for the best protection. Enjoy!</p>

	Tags: <a href="http://www.fortasse.com/tag/backup/" title="backup" rel="tag">backup</a>, <a href="http://www.fortasse.com/tag/godaddy/" title="godaddy" rel="tag">godaddy</a>, <a href="http://www.fortasse.com/tag/linux/" title="Linux" rel="tag">Linux</a>, <a href="http://www.fortasse.com/tag/tutorials/" title="Tutorials" rel="tag">Tutorials</a>, <a href="http://www.fortasse.com/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.fortasse.com/2010/01/miscellaneous/godaddy-wordpress-broken-permalinks-2/" title="Godaddy, Wordpress &#038; broken permalinks (January 6, 2010)">Godaddy, Wordpress &#038; broken permalinks</a> (1)</li>
	<li><a href="http://www.fortasse.com/2010/01/tutorials/optimize-your-site-with-htaccess/" title="Optimize your site with .htaccess (January 9, 2010)">Optimize your site with .htaccess</a> (1)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/your-friendly-guide-to-photo-shop-tutorials/" title="Your Friendly Guide To Photo Shop Tutorials (February 13, 2010)">Your Friendly Guide To Photo Shop Tutorials</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/working-with-files-in-linux-kludges-and-solutions/" title="Working With Files in Linux: Kludges and Solutions (February 5, 2010)">Working With Files in Linux: Kludges and Solutions</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/wordpress-video-tutorial-why-you-need-a-wordpress-tutorial/" title="Wordpress Video Tutorial: Why You Need a Wordpress Tutorial (February 17, 2010)">Wordpress Video Tutorial: Why You Need a Wordpress Tutorial</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.fortasse.com/2010/01/tutorials/tutorial-automatic-backup-script/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Web design: Browser overview</title>
		<link>http://www.fortasse.com/2010/01/tutorials/web-design-browser-overview/</link>
		<comments>http://www.fortasse.com/2010/01/tutorials/web-design-browser-overview/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 17:45:36 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[browser overview]]></category>
		<category><![CDATA[browsershots]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.fortasse.com/?p=167</guid>
		<description><![CDATA[So you&#8217;re designing a really cool website, want to know how it will look on different operating systems and browsers? While most pages will show up fine from one browser to another, there are always certain codes that just won&#8217;t work the same from one browser to another. Sometimes it&#8217;s more complicated than that: maybe [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_172" class="wp-caption alignleft" style="width: 310px"><a href="http://images.fortasse.com/2010/01/fortasse.jpg"><img class="size-medium wp-image-172 " title="Fortasse.com as show by Browsershots.com" src="http://www.fortasse.com/wp-content/uploads/2010/01/fortasse-300x184.jpg" alt="Fortasse" width="300" height="184" /></a><p class="wp-caption-text">Fortasse.com website 1/12/2010</p></div>
<p>So you&#8217;re designing a really cool website, want to know how it will look on different operating systems and browsers? While most pages will show up fine from one browser to another, there are always certain codes that just won&#8217;t work the same from one browser to another. <span id="more-167"></span>Sometimes it&#8217;s more complicated than that: maybe you want to know if it shows up the same way in Firefox for <a title="Ubuntu" href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> Karmic Koala as it does for Windows XP. What&#8217;s a web designer to do? You could ask your friends to check out your site for you on their operating system / browser combinations whilst you test the site on yours. You could also install every conceivable operating system inside your current OS via <a title="Virtual Box" href="http://www.virtualbox.org/" target="_blank">Virtual Box</a>. Or, you could drop by <a title="BrowserShots" href="http://browsershots.org" target="_blank">BrowserShots</a>, type in <a title="BrowserShots: Fortasse.com" href="http://browsershots.org/http://www.fortasse.com/" target="_blank">your URL</a> and wait a few minutes for it to parse your request.</p>
<p><a href="http://images.fortasse.com/2010/01/browsershots.jpg"><img class="size-full wp-image-169" title="browsershots" src="http://www.fortasse.com/wp-content/uploads/2010/01/browsershots.jpg" alt="BrowserShots" width="600" height="325" /></a></p>
<p style="text-align: center;"><em>Once you&#8217;re at the page, there are a plethora of options to choose from. You can select the screen size, color depth, and whether you want, Java, Javascript and Flash enabled.</em></p>
<p>Simple, fast, effective. After plugging in my URL, I had 53 browser / OS combinations in about 25 minutes. You don&#8217;t have to wait 25 minutes to start seeing them, though. The screen shots will be gradually uploaded one by one, so you can view them as they come in. The site literally directs a computer to view your site, takes a snap shot and uploads it. So you are, in effect, seeing exactly how it would look if someone loaded it up in the selected browser and operating system. Once the process is completed, you can save the pictures if you want. You can continue to view them for a while, but they will expire eventually.</p>
<p>So there you have it: next time you need to find out if there are any problems viewing your page on another browser or operating system, head on over to <a title="BrowserShots" href="http://browsershots.org" target="_blank">BrowserShots</a> and take a peek for yourself!</p>

	Tags: <a href="http://www.fortasse.com/tag/browser-overview/" title="browser overview" rel="tag">browser overview</a>, <a href="http://www.fortasse.com/tag/browsershots/" title="browsershots" rel="tag">browsershots</a>, <a href="http://www.fortasse.com/tag/tutorials/" title="Tutorials" rel="tag">Tutorials</a>, <a href="http://www.fortasse.com/tag/web-design/" title="web design" rel="tag">web design</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/your-friendly-guide-to-photo-shop-tutorials/" title="Your Friendly Guide To Photo Shop Tutorials (February 13, 2010)">Your Friendly Guide To Photo Shop Tutorials</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/why-are-online-web-tutorials-so-popular/" title="Why Are Online Web Tutorials So Popular? (February 16, 2010)">Why Are Online Web Tutorials So Popular?</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/where-to-find-photoshop-cs-tutorials/" title="Where To Find Photoshop Cs Tutorials (February 19, 2010)">Where To Find Photoshop Cs Tutorials</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/where-to-find-cs2-photoshop-tutorials/" title="Where To Find CS2 Photoshop Tutorials (February 14, 2010)">Where To Find CS2 Photoshop Tutorials</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/what-you-should-learn-from-cs2-photo-shop-tutorials/" title="What You Should Learn From CS2 Photo Shop Tutorials (February 14, 2010)">What You Should Learn From CS2 Photo Shop Tutorials</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.fortasse.com/2010/01/tutorials/web-design-browser-overview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimize your site with .htaccess</title>
		<link>http://www.fortasse.com/2010/01/tutorials/optimize-your-site-with-htaccess/</link>
		<comments>http://www.fortasse.com/2010/01/tutorials/optimize-your-site-with-htaccess/#comments</comments>
		<pubDate>Sat, 09 Jan 2010 11:13:50 +0000</pubDate>
		<dc:creator>Adam</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[.htaccess]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.fortasse.com/?p=112</guid>
		<description><![CDATA[Whether you want to optimize your site for heavy traffic, to deny access to files or directories or grant special privileges, the .htaccess file, most commonly found in the root folder of your domain, can do all of that and more! It doesn&#8217;t matter if it&#8217;s a vanilla install of Wordpress, phpBB, OsCommerce or your [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://images.fortasse.com/2010/01/htaccess1.jpg"><img class="aligncenter size-full wp-image-210" title=".htaccess" src="http://www.fortasse.com/wp-content/uploads/2010/01/htaccess1.jpg" alt=".htaccess" width="622" height="246" /></a>Whether you want to optimize your site for heavy traffic, to deny access to files or directories or grant special privileges, the .htaccess file, most commonly found in the root folder of your domain, can do all of that and more!<span id="more-112"></span> It doesn&#8217;t matter if it&#8217;s a vanilla install of Wordpress, phpBB, OsCommerce or your own handy dandy coding, the .htaccess file is often left barren of many of the features you might want or, better yet, need to deploy your website effectively.<br />
Take, for example, the default .htaccess for Wordpress:</p>
<p style="padding-left: 120px;"><code># BEGIN WordPress<br />
&lt;IfModule mod_rewrite.c&gt;<br />
RewriteEngine On<br />
RewriteBase /<br />
RewriteCond %{REQUEST_FILENAME} !-f<br />
RewriteCond %{REQUEST_FILENAME} !-d<br />
RewriteRule . /index.php [L]<br />
&lt;/IfModule&gt;</code></p>
<p>While this may indeed be sufficient for some needs, it hardly adds enough juice to sites that are beginning to generate traffic. But, before we get started on this tutorial, I highly suggest you download Google&#8217;s <a href="http://code.google.com/speed/page-speed/" target="_blank">Page Speed</a> plugin for <a href="http://www.mozilla.com" target="_blank">Firefox</a> (it requires the Firebug plugin, so go ahead and <a href="http://www.google.com/url?sa=t&amp;source=web&amp;ct=res&amp;cd=1&amp;ved=0CAwQFjAA&amp;url=http%3A%2F%2Fgetfirebug.com%2F&amp;rct=j&amp;q=firebug+plugin&amp;ei=cVFIS4LmM56ltgef8cXkDQ&amp;usg=AFQjCNGT1rhhsYGPQx5Vr5A8RvhIgdSp9g&amp;sig2=N-haWJcBW_uEuHrjaF9g6w" target="_blank">install it</a> first). Now, make sure all the plugins are enabled by going to the menu in Firefox and clicking <span style="text-decoration: underline;">T</span>ools &gt; <span style="text-decoration: underline;">A</span>dd-ons. After you&#8217;ve done that, point your browser to the URL of your site. In the <span style="text-decoration: underline;">T</span>ools menu, click Firebug &gt; Open Firebug (you can also push F12 to load the plugin via the keyboard shortcut).</p>
<p>Once the window has loaded, make sure Firebug is opened to the Page Speed tab. If it is, push Analyze Performance and wait for the status bar to come to completion. This usually take 10-25 seconds to finish. Now what shows up? If you have a run-of-the-mill install, there&#8217;s likely plenty of problems showing up in the Performance summary. No need to worry, most of the errors are easily fixable.</p>
<p>First, let&#8217;s go to the .htaccess file in the root of your blog or other page. Don&#8217;t know where it is? Fire up your favorite FTP client and point it at your sites FTP location (e.g. ftp.mywebsite.com). [<em>Note: I personally use the FireFTP plugin for Firefox, you can find it easily by going to <span style="text-decoration: underline;">T</span>ools &gt; Add-ons. Click Get Add-ons and search for FireFTP</em>].  Login with the username and password assigned to you by your hosting provider and you&#8217;re good to go. If you&#8217;re using FireFTP, you&#8217;ll need to open it up by clicking the icon in the Firefox menu bar or going to <span style="text-decoration: underline;">T</span>ools &gt; FireFTP.</p>
<p>The .htaccess file is hidden by default, as well it should be. Do NOT try to un-hide it. Simply allow your FTP client to view hidden files. If you&#8217;re using Nautilus for Gnome or a similar built-in FTP client for Linux, you can easily do this by pushing Ctrl + H, or in FireFTP click <span style="text-decoration: underline;">T</span>ools, <span style="text-decoration: underline;">O</span>ptions and make sure Show hidden files is checked. If you&#8217;re not using Nautilus or FireFTP, you&#8217;ll have to search around in your FTP client&#8217;s options or preferences dialogs. For example:</p>
<p style="text-align: left; padding-left: 120px;"><a href="http://images.fortasse.com/2010/01/Screenshot-Options.png"><img class="alignnone size-medium wp-image-115" title="Screenshot-Options" src="http://www.fortasse.com/wp-content/uploads/2010/01/Screenshot-Options-300x292.png" alt="" width="300" height="292" /></a></p>
<p style="text-align: left;">Now that we&#8217;ve taken care of that, browse to the install folder of your site, such as ftp://ftp.mysite.com/mysitefolder. Once there, you should be able to view the .htaccess file. Great! At this point I should mention that the Nautilus FTP client has one feature that can be very great and very bad. Instead of having to download the file, then modify it and upload it back to the site, you can simply right click the file and open it with your favorite viewer, such as gedit. Once you&#8217;re done, you simply push Save and it will <em>automatically save the modified copy to your website</em>. This is great for streamlining the upload process, but PLEASE, always back up ANY files you are modifying. Make a copy of the original file on your computer and, to be sure, make another copy on the website, but name it .htaccessback.</p>
<p>So now that we got all of that out of the way, let&#8217;s edit the darned thing already! As I said earlier, you will often find the .htaccess file will be pretty sparse. This is one of the reasons you may have generated so many errors with the Page Speed plugin. The primary error we&#8217;re looking for right now is <a title="Learn More" href="http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching" target="_blank">Leverage browser caching</a>. Utilizing browser caching will force the browser being used by anyone viewing your site to cache files locally on their computer for a given amount of time, thus reducing the load on your server. This is a fairly simply modification, and without getting too technical, simply paste the following code below any existing blocks of code in the file:</p>
<p style="padding-left: 120px;"><code>#Begin Cache<br />
&lt;IfModule mod_headers.c&gt;</code></p>
<p style="padding-left: 120px;"><code>#CACHE YEARLY<br />
&lt;FilesMatch ".(ico|gif|jpg|jpeg|png|flv|pdf)$"&gt;<br />
Header set Cache-Control "max-age=29030400"<br />
&lt;/FilesMatch&gt;</code></p>
<p style="padding-left: 120px;"><code>#CACHE MONTHLY<br />
&lt;FilesMatch ".(js)$"&gt;<br />
Header set Cache-Control "max-age=2419200"<br />
&lt;/FilesMatch&gt;</code></p>
<p style="padding-left: 120px;"><code>#CACHE WEEKLY<br />
&lt;FilesMatch ".(js|css|swf)$"&gt;<br />
Header set Cache-Control "max-age=604800"<br />
&lt;/FilesMatch&gt;</code></p>
<p style="padding-left: 120px;"><code>#CACHE EVERY 45 MIN<br />
&lt;FilesMatch ".(html|htm|txt|php)$"&gt;<br />
Header set Cache-Control "max-age=2700"<br />
&lt;/FilesMatch&gt;</code></p>
<p>You probably noticed there are file extensions located inside parenthesis separated by bars under each section. These specify how each file type will be handled. While the code above is good for most applications, you might want to adjust which files are under each section to suit your site. The max-age setting determines how long the file types should be cached locally on the browser. The time is measured in seconds and should not be set above 29030400, which is approximately one year [<em>Tip: you can go to <a href="http://www.google.com" target="_blank">Google</a> and type something along the lines of <a href="http://www.google.com/#hl=en&amp;q=6+months+to+seconds&amp;aq=f&amp;aqi=&amp;oq=&amp;fp=292ac4760832f3c4" target="_blank">6 months to seconds</a>, and it will do the conversion for you quickly; use only whole numbers</em>].</p>
<p>At this point, go ahead and save the .htaccess file, upload it to your site and make sure everything works. If you get a page that says <a href="http://www.checkupdown.com/status/E500.html" target="_blank">HTTP Error 500 Internal Server Error</a>, you&#8217;ve done something wrong and should replace the .htaccess file with the copy you should have backed up earlier. This is why you should only make a single change, save, and then check the site. If, for example, you paste in 100 lines of code that do 10 different things, you will have to hunt around to figure out which block or line of code is giving you problems. The .htaccess file is very, very picky. Trust me on this one.</p>
<p>If everything worked as expected, open the file back up and place the following block of code below the block you just added:</p>
<p style="padding-left: 120px;"><code>&lt;IfModule mod_gzip.c&gt;<br />
mod_gzip_on       Yes<br />
mod_gzip_dechunk  Yes<br />
mod_gzip_item_include file      .(html?|txt|css|js|php|pl|jpg|png|gif)$<br />
mod_gzip_item_include handler   ^cgi-script$<br />
mod_gzip_item_include mime      ^text/.*<br />
mod_gzip_item_include mime      ^application/x-javascript.*<br />
mod_gzip_item_exclude mime      ^image/.*<br />
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*<br />
&lt;/IfModule&gt;</code></p>
<p>If your hosting provider supports it (it should if your hosting service supports PHP), the above code will enable all of the specified files to be compressed. Obviously, when files are compressed they are smaller and this leads to less strain on the host and thus faster pages loads. Now say it with me: Save, upload and check. If your page isn&#8217;t working, you need to go back and see what went wrong. Luckily you backed up, right?</p>
<p>Now that that&#8217;s all done, go ahead and close your browser then open it up and navigate back to your site. Run the Page Speed analyzer again and see how you do. Progress? Woohoo! Don&#8217;t worry if your site doesn&#8217;t come out with high scores in every category, caching and compression are just two of many ways in which you can speed up your site. Be sure to check back to learn how to compress and optimize your images and scripts. Once you&#8217;ve applied all the tricks, you&#8217;ll be pleasantly surprised at how well your site will start to perform.</p>

	Tags: <a href="http://www.fortasse.com/tag/htaccess/" title=".htaccess" rel="tag">.htaccess</a>, <a href="http://www.fortasse.com/tag/cache/" title="cache" rel="tag">cache</a>, <a href="http://www.fortasse.com/tag/optimize/" title="optimize" rel="tag">optimize</a>, <a href="http://www.fortasse.com/tag/tutorials/" title="Tutorials" rel="tag">Tutorials</a>, <a href="http://www.fortasse.com/tag/wordpress/" title="wordpress" rel="tag">wordpress</a><br />

	<h4>Related posts</h4>
	<ul class="st-related-posts">
	<li><a href="http://www.fortasse.com/2010/01/tutorials/tutorial-automatic-backup-script/" title="Tutorial: Backup script (January 19, 2010)">Tutorial: Backup script</a> (4)</li>
	<li><a href="http://www.fortasse.com/2010/01/miscellaneous/godaddy-wordpress-broken-permalinks-2/" title="Godaddy, Wordpress &#038; broken permalinks (January 6, 2010)">Godaddy, Wordpress &#038; broken permalinks</a> (1)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/your-friendly-guide-to-photo-shop-tutorials/" title="Your Friendly Guide To Photo Shop Tutorials (February 13, 2010)">Your Friendly Guide To Photo Shop Tutorials</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/wordpress-video-tutorial-why-you-need-a-wordpress-tutorial/" title="Wordpress Video Tutorial: Why You Need a Wordpress Tutorial (February 17, 2010)">Wordpress Video Tutorial: Why You Need a Wordpress Tutorial</a> (0)</li>
	<li><a href="http://www.fortasse.com/2010/02/article-accumulator/why-are-online-web-tutorials-so-popular/" title="Why Are Online Web Tutorials So Popular? (February 16, 2010)">Why Are Online Web Tutorials So Popular?</a> (0)</li>
</ul>

]]></content:encoded>
			<wfw:commentRss>http://www.fortasse.com/2010/01/tutorials/optimize-your-site-with-htaccess/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
