<?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>Lasse Bunk&#039;s weblog &#187; Apache</title>
	<atom:link href="http://lassebunk.dk/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://lassebunk.dk</link>
	<description>Ruby on Rails, programming, and SEO</description>
	<lastBuildDate>Sat, 04 Feb 2012 12:51:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Deploying a Rails 3.1 app to subdirectory in Apache</title>
		<link>http://lassebunk.dk/2011/09/09/deploying-a-rails-3-1-app-to-subdirectory-in-apache/</link>
		<comments>http://lassebunk.dk/2011/09/09/deploying-a-rails-3-1-app-to-subdirectory-in-apache/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 21:09:47 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Server]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1929</guid>
		<description><![CDATA[How to deploy a Rails 3.1 app to a subdirectory in Apache.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how to deploy a Rails 3.1 app to a subdirectory in Apache, replacing <code>config.action_controller.relative_url_root</code> which no longer exists.</p>
<p>In <em>config/routes.rb</em>:</p>
<pre class="brush: ruby; title: ; notranslate">
scope 'my_subdir' do
  # all resources and routes go here
end
</pre>
<p>In your Apache configuration file:</p>
<pre class="brush: bash; title: ; notranslate">
Alias /my_subdir /var/www/my_subdir/public
&lt;Location /my_subdir&gt;
  SetEnv RAILS_RELATIVE_URL_ROOT &quot;/my_subdir&quot;
  PassengerAppRoot /var/www/my_subdir
&lt;/Location&gt;
</pre>
<p>And it should work, including automatically pointing all your assets to <em>/my_subdir</em>.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2011/09/09/deploying-a-rails-3-1-app-to-subdirectory-in-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux shell script to backup websites, MySQL, and PostgreSQL databases</title>
		<link>http://lassebunk.dk/2011/03/11/linux-backup-script/</link>
		<comments>http://lassebunk.dk/2011/03/11/linux-backup-script/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 16:07:08 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Script]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1491</guid>
		<description><![CDATA[How to make a Linux shell script that backs up your websites and databases.]]></description>
			<content:encoded><![CDATA[<p>I finally found the time to make a proper backup script for my home Linux server.<br />
My demands were these – it should be able to:</p>
<ul>
<li>Backup my websites</li>
<li>Backup my MySQL databases</li>
<li>Backup my PostgreSQL databases</li>
<li>Delete old backups to preserve disk space</li>
</ul>
<p>I&#8217;ll split the script into pieces to explain each part – you can download the whole script at the bottom of this post.</p>
<p>First we get the arguments:</p>
<ul>
<li><strong>-d</strong> to specify destination</li>
<li><strong>-s</strong> to specify website to backup</li>
<li><strong>-m</strong> to specify MySQL database to backup</li>
<li><strong>-p</strong> to specify PostgreSQL database to backup</li>
</ul>
<pre class="brush: bash; title: ; notranslate">
# get arguments
while [ &quot;$1&quot; != &quot;&quot; ]; do
    case $1 in
        -d | --destination )    shift
                                dest=$1
                                ;;
        -s | --site )           shift
                                site=$1
                                ;;
        -m | --mysql )          shift
                                mysqldb=$1
                                ;;
        -p | --postgres )       shift
                                postgresdb=$1
                                ;;
        * )                     echo &quot;Unknown argument $1.&quot;
                                exit 1
    esac
    shift
done
</pre>
<p>Complain if no destination is specified:</p>
<pre class="brush: bash; title: ; notranslate">
# complain if no destination specified
if [ &quot;$dest&quot; == &quot;&quot; ]; then
  echo &quot;Missing destination.&quot;
  exit 1
fi
</pre>
<p>Set and create backup folder. It creates folders in the <strong>destination/yyyymmddhhmmss</strong> format:</p>
<pre class="brush: bash; title: ; notranslate">
# set and create backup folder
folder=&quot;$dest/`date +%Y%m%d%H%M%S`&quot;
mkdir -p $folder
</pre>
<p>Backup website if specified. I keep all my websites in <strong>/var/www</strong>:</p>
<pre class="brush: bash; title: ; notranslate">
# backup website
if [ &quot;$site&quot; != &quot;&quot; ]; then
  echo &quot;Backing up site $site to $folder/www.tar.gz...&quot;
  cd /var/www
  tar -czf $folder/www.tar.gz $site
fi
</pre>
<p>Backup MySQL database if specified. It assumes that the database has a user with the same name, and logs in with this user:</p>
<pre class="brush: bash; title: ; notranslate">
# backup mysql database
if [ &quot;$mysqldb&quot; != &quot;&quot; ]; then
  echo &quot;Backing up database $mysqldb to $folder/db.sql.gz...&quot;
  mysqldump -u $mysqldb $mysqldb | gzip &gt; $folder/db.sql.gz
fi
</pre>
<p>Backup PostgreSQL database if specified. Like with MySQL, it assumes that the database has a user with the same name, and logs in with this user:</p>
<pre class="brush: bash; title: ; notranslate">
# backup postgres database
if [ &quot;$postgresdb&quot; != &quot;&quot; ]; then
  echo &quot;Backing up database $postgresdb to $folder/db.sql.gz...&quot;
  pg_dump -U $postgresdb $postgresdb | gzip &gt; $folder/db.sql.gz
fi
</pre>
<p>It finally deletes old backups, keeping the last 5:</p>
<pre class="brush: bash; title: ; notranslate">
# delete old backups keeping 5
echo &quot;Deleting old backups...&quot;
cd $dest
ls -t | sed 1,5d | while read folder; do rm -r $folder; done
</pre>
<p>Done:</p>
<pre class="brush: bash; title: ; notranslate">
# done
echo &quot;Done.&quot;
</pre>
<p>My <strong>crontab -e</strong> is then:</p>
<pre class="brush: bash; title: ; notranslate">
# m h  dom mon dow   command

# lassebunk
0 2 * * * /var/scripts/backup.sh -d /var/backups/sites/lassebunk/daily -s lassebunk -m lassebunk
0 2 1 * * /var/scripts/backup.sh -d /var/backups/sites/lassebunk/monthly -s lassebunk -m lassebunk

# othersite
0 2 * * * /var/scripts/backup.sh -d /var/backups/sites/othersite/daily -s othersite -p othersite
0 2 1 * * /var/scripts/backup.sh -d /var/backups/sites/othersite/monthly -s othersite -p othersite
</pre>
<p>Please also see my follow-up on this post: <a href="http://lassebunk.dk/2011/03/16/linux-dropbox-remote-backup/">Using Linux and Dropbox as a remote backup solution</a></p>
<p>I hope you found it useful – if you have any comments or suggestions, please write a comment below.</p>
<p><a href="http://lassebunk.dk/downloads/backup.sh">Download the script</a></p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2011/03/11/linux-backup-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to run multiple sites on OS X using Apache</title>
		<link>http://lassebunk.dk/2010/03/13/multiple-sites-os-x-apache/</link>
		<comments>http://lassebunk.dk/2010/03/13/multiple-sites-os-x-apache/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 21:11:14 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=1200</guid>
		<description><![CDATA[OS X doesn't come with multiple sites out of the box. Here's how to do this.]]></description>
			<content:encoded><![CDATA[<p><strong>Update 1:</strong> An automated way doing all the stuff in this post is using <a href="http://clickontyler.com/virtualhostx/">VirtualHostX</a> – you might want to try that out. It&#8217;s free for up to three vhosts – after that it costs money.</p>
<p><strong>Update 2:</strong> Or even better: You can use the all free <a href="http://github.com/lazyatom/hostess">hostess</a>. It&#8217;s pure command line and works great.</p>
<p>Today I wanted to test some PHP and MySQL using Apache in OS X but wasn&#8217;t able to find any guide on how to do this if I wanted multiple sites. So I might as well create my own:</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/apache2
sudo mkdir mysites
# or whatever (I used my name, 'lasse', for the name)

cd mysites
sudo nano phptest.conf
# or vi or whatever
</pre>
<p>Put the following in <code>phptest.conf</code>:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;VirtualHost *:80&gt;
  ServerName phptest.local
  DocumentRoot &quot;/Users/yourname/dev/web/phptest&quot;
  &lt;Directory &quot;/Users/yourname/dev/web/phptest&quot;&gt;
    Order allow,deny
    Allow from all
  &lt;/Directory&gt;
&lt;/VirtualHost&gt;
</pre>
<p>Remember to replace <code>yourname</code> for your username and to create the <code>~/dev/web/phptest</code> folder.</p>
<p>Back into the bash:</p>
<pre class="brush: bash; title: ; notranslate">
cd /etc/apache2
sudo nano httpd.conf
</pre>
<p>First find the lines that say:</p>
<pre class="brush: bash; title: ; notranslate">
#LoadModule php5_module        libexec/apache2/libphp5.so
#LoadModule fastcgi_module     libexec/apache2/mod_fastcgi.so
</pre>
<p>And uncomment these two lines likes this:</p>
<pre class="brush: bash; title: ; notranslate">
LoadModule php5_module        libexec/apache2/libphp5.so
LoadModule fastcgi_module     libexec/apache2/mod_fastcgi.so
</pre>
<p>This enables PHP.<br />
Next, go to the bottom of the same file and add the following line:</p>
<pre class="brush: bash; title: ; notranslate">
Include /private/etc/apache2/mysites/*.conf
</pre>
<p>This tells Apache to also load configuration files from the <code>mysites</code> folder.<br />
Next, edit your hosts file to enable the phptest.local name:</p>
<pre class="brush: bash; title: ; notranslate">
sudo nano /etc/hosts
</pre>
<p>Add the following line at the bottom of the file:</p>
<pre class="brush: bash; title: ; notranslate">
127.0.0.1 phptest.local
</pre>
<p>This tells your DNS resolver to look for the site locally at your computer (127.0.0.1) when you type phptest.local in your browser.</p>
<p>It&#8217;s necessary to restart Apache to enable the new settings (you&#8217;ll need to do this every time you add a site).</p>
<pre class="brush: bash; title: ; notranslate">
sudo apachectl -k restart
</pre>
<p>Finally we create a test file to make sure it all works:</p>
<pre class="brush: bash; title: ; notranslate">
cd ~/dev/web/phptest
nano test.php
</pre>
<p>Enter the following:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php echo &quot;Hello World!&quot; ?&gt;
</pre>
<p>Now you should be able to go to <a href="http://phptest.local/test.php">http://phptest.local/test.php</a> in your browser and it should say <code>Hello World!</code>. If not, then something is wrong.</p>
<h3>Adding a new site</h3>
<p>Next time you want to add a site, just complete the following steps:<br />
1. Create a site root folder in <code>~/dev/web/xx</code> or wherever you keep your sites.<br />
2. Create a configuration file similar to <code>phptest.conf</code> in <code>/etc/apache2/mysites/</code> where you replace the paths and <code>ServerName</code> for the new ones.<br />
3. Create an entry in <code>/etc/hosts</code> with the same name as you used as <code>ServerName</code>.<br />
4. Restart Apache using <code>apachectl -k restart</code>.</p>
<p>Is there an easier way to do this? Please let me know in the comments.</p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2010/03/13/multiple-sites-os-x-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Three months on the Mac stack</title>
		<link>http://lassebunk.dk/2009/09/24/three-months-on-the-mac-stack/</link>
		<comments>http://lassebunk.dk/2009/09/24/three-months-on-the-mac-stack/#comments</comments>
		<pubDate>Thu, 24 Sep 2009 13:39:45 +0000</pubDate>
		<dc:creator>lassebunk</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Amiga]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[C64]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[Github]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Migration]]></category>
		<category><![CDATA[Netbooks]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Slicehost]]></category>
		<category><![CDATA[Slices]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[TextMate]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Visual Studio]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[VMware Fusion]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://lassebunk.dk/?p=221</guid>
		<description><![CDATA[I started out using Windows and ended up using OS X and Linux.]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">It’s actually four months now – since May 1st – but I’ve been wanting to write this article for a month. Hence the – somewhat misleading – title.</p>
<p>I bought my <a href="http://www.apple.com/macbook/">MacBook</a> on May 1th after viewing a <a href="http://rubyonrails.org/screencasts">screencast where a guy sets up a blog in 15 minutes</a> using <a href="http://rubyonrails.org">Ruby on Rails</a>. I immediately said to my stepdad: “I’m going to buy a Mac and learn Ruby on Rails!”</p>
<p>And so I did &#8211; the day after, I bought a Mac.</p>
<p>I’ve always been a dedicated user of <a href="http://www.microsoft.com">Microsoft</a>&#8216;s products. First <a href="http://en.wikipedia.org/wiki/Commodore_64">C64</a>, then <a href="http://en.wikipedia.org/wiki/Amiga">Amiga</a>, then <a href="http://en.wikipedia.org/wiki/Power_Macintosh_5300">Mac</a>, then PC. I liked the way everything was tested and came from one place, unlike <a href="http://en.wikipedia.org/wiki/Open_source">open source</a>. I’ve always been saying stuff like “I like to pay for my software because then I&#8217;m be sure about the quality.” – but in reality, everyone who uses Windows and other Microsoft products know that this isn’t always the case.</p>
<p>So I bought the Mac, and the first thing that surprised me, was how much of day-to-day work was done in the <a href="http://en.wikipedia.org/wiki/Apple_Terminal">Terminal</a>, or <a href="http://en.wikipedia.org/wiki/Command-line_interface">command line</a>. When I installed Ruby on Rails, it was via command line; when I installed plugins, it was via command line. Evererything command line. <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Over the next few days I began to get a hang of it. I bought a couple of <a href="http://en.wikipedia.org/wiki/Domain_name">domain names</a> and signed up for a <a href="http://en.wikipedia.org/wiki/Slice_%28disk%29">slice</a> at <a href="http://www.slicehost.com">Slicehost</a> – because I had read some <a href="http://railswork.com">job description</a> that said that you should&#8217;ve at least tried to use a whole day of setting a slice.</p>
<p>Coming from Windows, Linux is a whole other deal to setup. I used a lot of the <a href="http://articles.slicehost.com/">Slicehost articles</a> that guides you through the whole process from setup and security to getting your slice to run as a <a href="http://www.apache.org">webserver</a>.</p>
<p>In the beginning I was a little nervous about all the command lines, if they would really work and so one. But the more you try it, the more calm you get. It just works! And lucky me there was a lot of helpful articles about Unix and Linux commands out there (just search for the command on <a href="http://www.google.com">Google</a>).</p>
<p>Since starting out on the Mac, I’ve learned a multitude of things:</p>
<ul>
<li> Setting up an <a href="http://www.ubuntu.com/">Ubuntu</a> <a href="http://en.wikipedia.org/wiki/Slice_%28disk%29">slice</a> at <a href="http://www.slicehost.com">Slicehost</a>.</li>
<li>Setting up a <a href="http://www.apache.org">web server</a>.</li>
<li>Setting up <a href="http://www.ubuntu.com/GetUbuntu/download-netbook">Ubuntu Netbook Remix</a> on my <a href="http://eeepc.asus.com/">netbook</a>.</li>
<li>Setting up <a href="http://www.ubuntu.com/getubuntu/download-server">Ubuntu server</a> at home, also on my netbook – which now functions as my testing server.</li>
<li>Programming a little <a href="http://www.php.net">PHP</a> – see Tweet My Cam.</li>
<li>Programming <a href="http://rubyonrails.org">Ruby on Rails</a>.</li>
<li>Tweaking some <a href="http://www.java.com">Java</a> code, <a href="http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html">compiling</a> and <a href="http://forums.sun.com/thread.jspa?threadID=174214">signing</a> a <a href="http://en.wikipedia.org/wiki/Java_applet">java applet</a> in one day – see a demo <a href="http://lassebunk.dk/2009/07/19/using-the-clipboard-to-post-images/">here</a>.</li>
<li>Download and compile software (<a href="http://tldp.org/LDP/LG/current/smith.html">configure, make, make install</a>).</li>
<li><a href="http://railsontherun.com/2008/3/3/how-to-use-github-and-submit-a-patch">Submitted a patch</a> to a Ruby on Rails <a href="http://github.com/technoweenie/restful-authentication">plugin</a> on <a href="http://github.com">Github</a>.</li>
<li>Setting up <a href="http://wordpress.org">WordPress</a> and <a href="http://mu.wordpress.org/">WordPress Mu</a> blogs and making my own <a href="http://lassebunk.dk">theme</a> – see <a href="http://lassebunk.dk">my private blog</a> and <a href="http://userdriven.dk">private work blog</a>.</li>
<li>Setting up a <a href="http://subversion.tigris.org/">Subversion</a> repository at <a href="http://www.xp-dev.com/">XP-Dev.com</a>.</li>
<li>Using the Subversion repository <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>Loving <a href="http://macromates.com/">Textmate</a> as my favorite editor – also over <a href="http://www.microsoft.com/visualstudio">Visual Studio</a>.</li>
<li>Plus a bunch of other things.</li>
</ul>
<p>In short I’ve learned so much about the open source world that just wasn’t that easy on the Microsoft platform.</p>
<p>I still use Microsoft Windows and other products, but now it’s through <a href="http://www.vmware.com/products/fusion/">VMware Fusion</a> on the Mac.</p>
<p>I’m happy about the Mac because <a href="http://www.apple.com/macosx/">OS X</a> is very unobtrusive, fast operating system and what it does, it does very good. But at the same time, I also want a netbook that’s easier to carry, so I may end up running both systems for different purposes (unless I&#8217;m just installing Ubuntu on the netbook too <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ).</p>
<p>Hope you found this post interesting – I wrote it to tell about a beautiful (yak, I know) progress from Windows to Mac and Linux. Thumbs up if this has made you want to try it too. And please tell me in the comments. <img src='http://lassebunk.dk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>
<a href="http://twitter.com/lassebunk" onclick="abtest.trackGoal(21, this);" class="icon twitter">Follow me on Twitter</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://lassebunk.dk/2009/09/24/three-months-on-the-mac-stack/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

