<?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>info.michael-simons.eu &#187; MySQL</title>
	<atom:link href="http://info.michael-simons.eu/tag/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://info.michael-simons.eu</link>
	<description>Just another nerd blog</description>
	<lastBuildDate>Wed, 08 Feb 2012 10:26:00 +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>Fixing hibernate &#8220;Cannot release connection&#8221; exception using DBCP and MySQL.</title>
		<link>http://info.michael-simons.eu/2011/11/21/fixing-hibernate-cannot-release-connection-exception-using-dbcp-and-mysql/</link>
		<comments>http://info.michael-simons.eu/2011/11/21/fixing-hibernate-cannot-release-connection-exception-using-dbcp-and-mysql/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 08:04:34 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[DBCP]]></category>
		<category><![CDATA[Hibernate]]></category>
		<category><![CDATA[JDBC]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tomcat]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=550</guid>
		<description><![CDATA[Every 8 hours i got a Hibernate exception &#8220;Cannot release connection&#8221; within a Java application using Hibernate, Apache DBCP on Tomcat: org.hibernate.exception.GenericJDBCException: Cannot release connection at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) .. .. Caused by: java.sql.SQLException: Already closed. Not only that the messages polluted my inbox, the exception was visible to the enduser, [...]]]></description>
			<content:encoded><![CDATA[<p>Every 8 hours i got a Hibernate exception &#8220;Cannot release connection&#8221; within a Java application using Hibernate, Apache DBCP on Tomcat:</p>
<pre>
org.hibernate.exception.GenericJDBCException: Cannot release connection
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
    ..
    ..
Caused by: java.sql.SQLException: Already closed.
</pre>
<p>Not only that the messages polluted my inbox, the exception was visible to the enduser, resulting in a HTTP 500 error. An older <a href="http://mrather.blogspot.com/2008/09/hibernate-and-connection-pools.html">blog post</a> i found suggested dismissing DBCP and using c3p0, a solution that i&#8217;m not quite found of. At least, the post helped to reproduce the problem within my development setup. The underlying problem was indeed the MySQL wait_timeout.</p>
<p>There&#8217;s quite a long documentation on the <a href="http://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html">Tomcat JDBC Connection Pool</a>. Although the Tomcat team recommends their own solution since Tomcat 7, i still wanted to go with DBCP.</p>
<p>The relevant keywords are &#8220;testOnBorrow&#8221;, &#8220;testOnReturn&#8221;, &#8220;testWhileIdle&#8221;, &#8220;validationQuery&#8221; and &#8220;timeBetweenEvictionRunsMillis&#8221;. The first 3 are boolean values. If set to true, the query given as validationQuery is executed on borrowing a connection from the pool, on returning or when idling. The first option is not an option on production use as the query is executed before <strong>each</strong> call. Although &#8220;Select 1&#8243; is probably very fast, i just don&#8217;t want to have. Also: The problem is an invalidated, idle connection so i set testWhileIdle to true. And what happened? Nothing! The problem stayed. So there is the last option timeBetweenEvictionRunsMillis which should, according to the docs, default to 5 seconds but it doesn&#8217;t. The documentation is <strong>wrong</strong>. It&#8217;s under zero, so the eviction thread that tests idle connections never run. I&#8217;ve tweeted the tomcat team, but there was no reaction. </p>
<p>So the correct configuration for a DBCP pool database source is:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Resource</span></span>
<span style="color: #009900;">	<span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;javax.sql.DataSource&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">driverClassName</span>=<span style="color: #ff0000;">&quot;com.mysql.jdbc.Driver&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">maxActive</span>=<span style="color: #ff0000;">&quot;100&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">maxIdle</span>=<span style="color: #ff0000;">&quot;30&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">maxWait</span>=<span style="color: #ff0000;">&quot;10000&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">testOnBorrow</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">testOnReturn</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">testWhileIdle</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">validationQuery</span>=<span style="color: #ff0000;">&quot;Select 1&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">timeBetweenEvictionRunsMillis</span>=<span style="color: #ff0000;">&quot;1800000&quot;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>This way the eviction thread runs every 30 minutes, testing idle connections with the query &#8220;Select 1&#8243; and removing them from the pool. The timeBetweenEvictionRunsMillis should not be to low. It should be adapted to the configured MySQL wait_timeout.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=550&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_550" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2011/11/21/fixing-hibernate-cannot-release-connection-exception-using-dbcp-and-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySql compatible AES encryption / decryption in Java</title>
		<link>http://info.michael-simons.eu/2011/07/18/mysql-compatible-aes-encryption-decryption-in-java/</link>
		<comments>http://info.michael-simons.eu/2011/07/18/mysql-compatible-aes-encryption-decryption-in-java/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 12:51:57 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[AES]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=527</guid>
		<description><![CDATA[MySQL has an aes_encrypt/aes_decrypt pair of functions (Encryption and Compression Functions) that enable encryption and decryption of data using the official AES algorithm. The functions are easy to use (select AES_ENCRYPT(&#8216;text&#8217;,'password&#8217;)) and the result is easy to store (insert into secrets values HEX(AES_ENCRYPT(&#8216;text&#8217;,'password&#8217;))) as hex values. I used this technique for a while but i [...]]]></description>
			<content:encoded><![CDATA[<p>MySQL has an aes_encrypt/aes_decrypt pair of functions (<a href="http://dev.mysql.com/doc/refman/5.5/en/encryption-functions.html#function_aes-encrypt">Encryption and Compression Functions</a>) that enable encryption and decryption of data using the official AES algorithm.</p>
<p>The functions are easy to use (select AES_ENCRYPT(&#8216;text&#8217;,'password&#8217;)) and the result is easy to store (insert into secrets values HEX(AES_ENCRYPT(&#8216;text&#8217;,'password&#8217;))) as hex values.</p>
<p>I used this technique for a while but i wanted to have a more database agnostic version of this encryption and tried to build the same methods with java.</p>
<p>Although it was relatively easy to find the exact cipher mode (which is AES/ECB/PKCS5Padding), i had a real hard time figuring out how the key is calculated from the given password (the key must be 16bytes long, per default MySql uses AES-128). It turns out that the MySQL algorithm just or&#8217;s the bytes of a given passphrase against the previous bytes if the password is longer than 16 chars and just leaves them 0 when the password is shorter than 16 chars. So you can generate a secret key spec in Java for an aes_encrypt/decrypt compatible cipher like so:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.UnsupportedEncodingException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.crypto.Cipher</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.crypto.spec.SecretKeySpec</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.apache.commons.codec.binary.Hex</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Demo <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> SecretKeySpec generateMySQLAESKey<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> key, <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> encoding<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> finalKey <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">16</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span> b <span style="color: #339933;">:</span> key.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span>encoding<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
				finalKey<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">++%</span>16<span style="color: #009900;">&#93;</span> <span style="color: #339933;">^=</span> b<span style="color: #339933;">;</span>			
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> SecretKeySpec<span style="color: #009900;">&#40;</span>finalKey, <span style="color: #0000ff;">&quot;AES&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">UnsupportedEncodingException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">RuntimeException</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>... <span style="color: #006633;">args</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// Decrypt</span>
		<span style="color: #000000; font-weight: bold;">final</span> Cipher decryptCipher <span style="color: #339933;">=</span> Cipher.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AES&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	        				
		decryptCipher.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>Cipher.<span style="color: #006633;">DECRYPT_MODE</span>, generateMySQLAESKey<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;your super secret passphrase&quot;</span>, <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span>decryptCipher.<span style="color: #006633;">doFinal</span><span style="color: #009900;">&#40;</span>Hex.<span style="color: #006633;">decodeHex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;56A34D7AB6225616799F6559AA388F07C2C9E53983111BDD5F49F36461AAD789&quot;</span>.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Encrypt</span>
		<span style="color: #000000; font-weight: bold;">final</span> Cipher encryptCipher <span style="color: #339933;">=</span> Cipher.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;AES&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>	        				
		encryptCipher.<span style="color: #006633;">init</span><span style="color: #009900;">&#40;</span>Cipher.<span style="color: #006633;">ENCRYPT_MODE</span>, generateMySQLAESKey<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;your super secret passphrase&quot;</span>, <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Select aes_decrypt(unhex('%s'), 'your super secret passphrase');&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span>Hex.<span style="color: #006633;">encodeHex</span><span style="color: #009900;">&#40;</span>encryptCipher.<span style="color: #006633;">doFinal</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hallo nach Aachen&quot;</span>.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You need <a href="http://commons.apache.org/codec/">Commons Codec</a> to run these. </p>
<p>This isn&#8217;t probably the most secure solution from a cryptographic point of view but it just replicates the built-in MySql function for other databases or just for interoperability. I hope to save someone else time with this as i spent about days about those view lines.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=527&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_527" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2011/07/18/mysql-compatible-aes-encryption-decryption-in-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create reusable MySQL schema dumps</title>
		<link>http://info.michael-simons.eu/2010/09/16/create-reusable-mysql-schema-dumps/</link>
		<comments>http://info.michael-simons.eu/2010/09/16/create-reusable-mysql-schema-dumps/#comments</comments>
		<pubDate>Thu, 16 Sep 2010 09:18:39 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Shortcuts]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Tipps]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=449</guid>
		<description><![CDATA[In case you need a MySQL schema transferred from one host to another and the schema names differ, you can ran into problems with a standard MySQL dump. Use the following statement to create a schema dump that contains all table and view definitions as well as all stored procedures without a reference to the [...]]]></description>
			<content:encoded><![CDATA[<p>In case you need a MySQL schema transferred from one host to another and the schema names differ, you can ran into problems with a standard MySQL dump.</p>
<p>Use the following statement to create a schema dump that contains all table and view definitions as well as all stored procedures without a reference to the original schema:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> mysqldump <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> name_of_the_original_schema <span style="color: #660033;">--no-data</span> <span style="color: #660033;">--opt</span> <span style="color: #660033;">--routines</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/`name_of_the_original_schema`.//g'</span> <span style="color: #000000; font-weight: bold;">&gt;</span> dump.sql</pre></div></div>

<p>The dump will only contain the schema definition and no data. Calls to routines will not be prefixed with a schema name.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=449&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_449" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2010/09/16/create-reusable-mysql-schema-dumps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Different day, same shit: MySQL Gem again</title>
		<link>http://info.michael-simons.eu/2008/12/11/different-day-same-shit-mysql-gem-again/</link>
		<comments>http://info.michael-simons.eu/2008/12/11/different-day-same-shit-mysql-gem-again/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 08:25:37 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[English posts]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/?p=247</guid>
		<description><![CDATA[Again, the MySQL ruby gem totally annyoed me trying to install it on a fresh Mac OS X 10.5.5 install and MySQL 5.0.67. This time the following command brought it to life: sudo env ARCHFLAGS=&#34;-arch i386&#34; gem install mysql -- \ --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib \ --with-mysql-include=/usr/local/mysql/include Thanks to a bitter software engineer. Share This]]></description>
			<content:encoded><![CDATA[<p>Again, the MySQL ruby gem <a href="http://info.michael-simons.eu/2006/05/05/ruby-on-rails-mit-mac-os-x/">totally</a> <a href="http://info.michael-simons.eu/2007/01/02/ruby-on-rails-native-mysql-bindings-vs-rmagick/">annyoed</a> me trying to install it on a fresh Mac OS X 10.5.5 install and MySQL 5.0.67.</p>
<p>This time the following command brought it to life:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">env</span> <span style="color: #007800;">ARCHFLAGS</span>=<span style="color: #ff0000;">&quot;-arch i386&quot;</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql <span style="color: #660033;">--</span> \
  <span style="color: #660033;">--with-mysql-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #660033;">--with-mysql-lib</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>lib \
  <span style="color: #660033;">--with-mysql-include</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>include</pre></div></div>

<p>Thanks to a <a href="http://wonko.com/post/how-to-install-the-mysqlruby-gem-on-mac-os-x-leopard">bitter software engineer</a>.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=247&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_247" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2008/12/11/different-day-same-shit-mysql-gem-again/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Projektdokumentationen und Anwendungsdesign</title>
		<link>http://info.michael-simons.eu/2007/05/19/projektdokumentationen-und-anwendungsdesign/</link>
		<comments>http://info.michael-simons.eu/2007/05/19/projektdokumentationen-und-anwendungsdesign/#comments</comments>
		<pubDate>Sat, 19 May 2007 07:12:04 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[Lesetipps]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/2007/05/19/projektdokumentationen-und-anwendungsdesign/</guid>
		<description><![CDATA[In den letzten Tagen habe ich einige ganz interessante, deutsche Projektdokumentationen gefunden. Zum einen die zur Zeiterfassung Mite gehörende Diplomarbeit, die hier zum Download angeboten wird. Zum anderen einen Aufsatz von Thomas Bachem, einem der Macher von sevenload.de Ich finde beide Dokumentationen hochgradig interessant zu lesen, nichts desto habe ich einige Anmerkungen und Gedanken dazu: [...]]]></description>
			<content:encoded><![CDATA[<p>In den letzten Tagen habe ich einige ganz interessante, deutsche Projektdokumentationen gefunden.</p>
<p>
Zum einen die zur Zeiterfassung <a href="http://bemite.de/">Mite</a> gehörende Diplomarbeit, die <a href="http://bemite.de/hintergrund.html">hier zum Download</a> angeboten wird. <br />
Zum anderen einen <a href="http://blog.thomasbachem.com/2007/05/07/mein-artikel-im-php-magazin-52006/">Aufsatz</a> von <a href="http://blog.thomasbachem.com/">Thomas Bachem</a>, einem der Macher von <a href="http://www.sevenload.de">sevenload.de</a>
</p>
<p>Ich finde beide Dokumentationen hochgradig interessant zu lesen, nichts desto habe ich einige Anmerkungen und Gedanken dazu:</p>
<p>
Mite ist ein Projekt mit Ruby on Rails. Die Macher hatten am Anfang Lastprobleme, konnten das aber durch einen Umzug auf einen performanteren Server lösen.</p>
<p>
Sevenload ist ein PHP Projekt. Leider nutze ich es nicht so häufig wie Youtube, daher kann ich keine definitive Aussage zur Geschwindigkeit treffen. Dennoch frage ich mich, ob es wirklich nötig ist, in einem Grundlagenartikel direkt mit kontrollierten Redundanzen für die einfachsten Sachen wie &#8220;durchschnittliche Bewertung eines Bildes&#8221; loszulegen? Ich meine, bin ich der einzige, der so etwas für Überflüssig hält? Letzten Endes ist es ein Einzeiler in SQL, der mit korrekter Indexerstellung kein DBMS in die Knie zwingen sollte:
</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">SELECT</span> avg<span style="color: #66cc66;">&#40;</span>rating<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #993333; font-weight: bold;">COUNT</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> rateable_id <span style="color: #993333; font-weight: bold;">FROM</span> ratings <span style="color: #993333; font-weight: bold;">GROUP</span> <span style="color: #993333; font-weight: bold;">BY</span> rateable_id <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> <span style="color: #cc66cc;">1</span> <span style="color: #993333; font-weight: bold;">ASC</span>;</pre></div></div>

<p>Das dann noch mit einem inner join über die zu bewertenden Dinger verknüpft und gut.</p>
<p>Welcher Ansatz würde ich wählen? Ich selber würde jederzeit Standards vorziehen, im obigen Fall auf ein sauberes ER &lt;-&gt;Objekt Mapping und auf Normalisierung in der DB (witzigerweise erwähnt Thomas Bachem das im nächsten Absatz bzgl. Tagging Schema) setzen. In anderen Worten: Lieber den Railsweg gehen und sauberes Design erhalten und dann im Zweifelsfall etwas mehr Hardware hinter her werfen.</p>
<p>Tatsächlich redundate Informationen zu speichern würde ich generell nicht ausschliessen, in diesem Fall allerdings schon. Ich denke, wenn man soweit unten bereits diesen Bedarf hat, wird es eng mit Optimierungen, wenn die Luft unter Last dünner wird.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=82&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_82" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2007/05/19/projektdokumentationen-und-anwendungsdesign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby On Rails native MySQL Bindings Vs. RMagick</title>
		<link>http://info.michael-simons.eu/2007/01/02/ruby-on-rails-native-mysql-bindings-vs-rmagick/</link>
		<comments>http://info.michael-simons.eu/2007/01/02/ruby-on-rails-native-mysql-bindings-vs-rmagick/#comments</comments>
		<pubDate>Tue, 02 Jan 2007 08:26:05 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Webdevelopment]]></category>
		<category><![CDATA[ImageMagick]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[RMagick]]></category>

		<guid isPermaLink="false">http://info.michael-simons.eu/2007/01/02/ruby-on-rails-native-mysql-bindings-vs-rmagick/</guid>
		<description><![CDATA[I&#8217;m writing this post in english in hope that more people find it useful&#8230; Some times ago i really had bad problems installing the MySQL Gem 2.7 with Ruby 1.8.2 or 1.8.5 in conjunction with Rails 1.1.6 on Mac OS X 10.4 Compilation failed with: Building native extensions. This could take a while… mysql.c: In [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this post in english in hope that more people find it useful&#8230;</p>
<p>Some times ago i really had bad problems installing the MySQL Gem 2.7 with Ruby 1.8.2 or 1.8.5 in conjunction with Rails 1.1.6 on Mac OS X 10.4</p>
<p>Compilation failed with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Building native extensions. This could take a <span style="color: #000000; font-weight: bold;">while</span>…
mysql.c: In <span style="color: #000000; font-weight: bold;">function</span> ‘Init_mysql’:
mysql.c:<span style="color: #000000;">2015</span>: error: ‘ulong’ undeclared <span style="color: #7a0874; font-weight: bold;">&#40;</span>first use <span style="color: #000000; font-weight: bold;">in</span> this <span style="color: #000000; font-weight: bold;">function</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
mysql.c:<span style="color: #000000;">2015</span>: error: <span style="color: #7a0874; font-weight: bold;">&#40;</span>Each undeclared identifier is reported only once
mysql.c:<span style="color: #000000;">2015</span>: error: <span style="color: #000000; font-weight: bold;">for</span> each <span style="color: #000000; font-weight: bold;">function</span> it appears in.<span style="color: #7a0874; font-weight: bold;">&#41;</span>
mysql.c:<span style="color: #000000;">2015</span>: error: parse error before numeric constant
mysql.c:<span style="color: #000000;">2018</span>: error: parse error before numeric constant
<span style="color: #c20cb9; font-weight: bold;">make</span>: <span style="color: #000000; font-weight: bold;">***</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>mysql.o<span style="color: #7a0874; font-weight: bold;">&#93;</span> Error <span style="color: #000000;">1</span>
mysql.c: In <span style="color: #000000; font-weight: bold;">function</span> ‘Init_mysql’:
mysql.c:<span style="color: #000000;">2015</span>: error: ‘ulong’ undeclared <span style="color: #7a0874; font-weight: bold;">&#40;</span>first use <span style="color: #000000; font-weight: bold;">in</span> this <span style="color: #000000; font-weight: bold;">function</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
mysql.c:<span style="color: #000000;">2015</span>: error: <span style="color: #7a0874; font-weight: bold;">&#40;</span>Each undeclared identifier is reported only once
mysql.c:<span style="color: #000000;">2015</span>: error: <span style="color: #000000; font-weight: bold;">for</span> each <span style="color: #000000; font-weight: bold;">function</span> it appears in.<span style="color: #7a0874; font-weight: bold;">&#41;</span>
mysql.c:<span style="color: #000000;">2015</span>: error: parse error before numeric constant
mysql.c:<span style="color: #000000;">2018</span>: error: parse error before numeric constant
<span style="color: #c20cb9; font-weight: bold;">make</span>: <span style="color: #000000; font-weight: bold;">***</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>mysql.o<span style="color: #7a0874; font-weight: bold;">&#93;</span> Error <span style="color: #000000;">1</span>
ruby extconf.rb <span style="color: #c20cb9; font-weight: bold;">install</span> mysql — –with-mysql-dir=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql
checking <span style="color: #000000; font-weight: bold;">for</span> mysql_query<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> -lmysqlclient… no
checking <span style="color: #000000; font-weight: bold;">for</span> main<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> -lm… <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> mysql_query<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> -lmysqlclient… no
checking <span style="color: #000000; font-weight: bold;">for</span> main<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> -lz… <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> mysql_query<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">in</span> -lmysqlclient… <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> mysql_ssl_set<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>… <span style="color: #c20cb9; font-weight: bold;">yes</span>
checking <span style="color: #000000; font-weight: bold;">for</span> mysql.h… <span style="color: #c20cb9; font-weight: bold;">yes</span>
creating Makefile</pre></div></div>

<p>The gem would then install with <em>Successfully installed mysql-2.7</em>. Creepy!!! But that damn thing just didn&#8217;t work.</p>
<p>After quite some googling i found this one:</p>
<p><a href="http://i.nfectio.us/articles/2006/09/12/running-rails-on-os-x-with-mysql-5-0-24"> Running Rails on OS X with MySQL 5.0.24</a></p>
<p>It&#8217;s all about puting a little</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#ifndef ulong </span>
<span style="color: #339933;">#define ulong unsigned long</span>
<span style="color: #339933;">#endif</span></pre></div></div>

<p>somewhere in &#8220;/usr/include/stdlib.h&#8221;.</p>
<p>This tipp is still necessary for MySQL 5.0.24+. Thanks again mate!!</p>
<p>But here the trouble starts&#8230;.</p>
<p>I put the define in a nice little conditional just in case but bah&#8230; It would come down to hunt me&#8230;</p>
<p>For my project <a href="http://dailyfratze.de">DailyFratze.de</a> i also need <a href="http://rmagick.rubyforge.org/">RMagick</a>. Again, the gem (1.14.1, 1.14.0 and 1.13) failed to compile but didn&#8217;t tell (on runtime it said &#8220;require &#8220;RMagick&#8221; LoadError: No such file to load &#8212; RMagick.so&#8221; &#8230; ) and installation from source did fail as well with:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">setup.rb:<span style="color: #000000;">655</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">command</span><span style="color: #ff0000;">': system(&quot;make&quot;) failed (RuntimeError)
from setup.rb:664:in `make'</span>
from setup.rb:<span style="color: #000000;">1258</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>setup_dir_ext<span style="color: #ff0000;">'
from setup.rb:1532:in `__send__'</span>
from setup.rb:<span style="color: #000000;">1532</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>traverse<span style="color: #ff0000;">'
from setup.rb:1530:in `dive_into'</span>
from setup.rb:<span style="color: #000000;">1530</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>traverse<span style="color: #ff0000;">'
from setup.rb:1534:in `traverse'</span>
from setup.rb:<span style="color: #000000;">1533</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>each<span style="color: #ff0000;">'
... 8 levels...
from setup.rb:826:in `__send__'</span>
from setup.rb:<span style="color: #000000;">826</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>invoke<span style="color: #ff0000;">'
from setup.rb:772:in `invoke'</span>
from setup.rb:<span style="color: #000000;">1578</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>: <span style="color: #000000; font-weight: bold;">***</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>all<span style="color: #7a0874; font-weight: bold;">&#93;</span> Error <span style="color: #000000;">1</span></pre></div></div>

<p>Damn! After banging my head against the walls, reinstalling ImageMagick and all it&#8217;s depencies either direct from source, via i-installer and finally as mentioned <a href="http://rmagick.rubyforge.org/install-osx.html">here</a> i took a break, visited some porn sites and stuff like that and though, hmm&#8230; stdlib.h&#8230;.</p>
<p>I removed the little define and bam! It&#8217;s that easy, RMagick compiles just fine&#8230; </p>
<p>From the forums i found i guess other people with the same error message may have the same problem as i had&#8230;</p>
<p>I really wish installing a ruby on rails environment would be a less pain in the ass&#8230;. somewhere near as easy as developing with rails.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=53&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_53" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2007/01/02/ruby-on-rails-native-mysql-bindings-vs-rmagick/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails mit Mac OS X</title>
		<link>http://info.michael-simons.eu/2006/05/05/ruby-on-rails-mit-mac-os-x/</link>
		<comments>http://info.michael-simons.eu/2006/05/05/ruby-on-rails-mit-mac-os-x/#comments</comments>
		<pubDate>Fri, 05 May 2006 16:51:23 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Lesetipps]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.msimons.info/?p=17</guid>
		<description><![CDATA[Nachdem mich die Tutorials bzw. die kurzen Videos auf rubyonrails.org sehr begeistert haben, musste ich natürlich direkt Rails ausprobieren. Für den Einstieg sind die diversen Tutorials, die man im Netz findet, recht interessant, wirklich gut ist aber das Buch Agile Web Development with Rails. Man sollte darauf achten, dass man die zweite Ausgabe kauft und [...]]]></description>
			<content:encoded><![CDATA[<p>Nachdem mich die Tutorials bzw. die kurzen Videos auf <a href="http://www.rubyonrails.org" rel="external">rubyonrails.org</a> sehr begeistert haben, musste ich natürlich direkt Rails ausprobieren.</p>
<p>Für den Einstieg sind die diversen Tutorials, die man im Netz findet, recht interessant, wirklich gut ist aber das Buch <a href="http://www.pragmaticprogrammer.com/titles/rails/index.html" rel="external">Agile Web Development with Rails</a>. Man sollte darauf achten, dass man die zweite Ausgabe kauft und nicht wie ich die erste über Amazon.</p>
<p>Im Buch steht soweit alles drin, was man tun muss, um unter Mac OS X direkt loszulegen. Seit OS X Tiger in der Version 10.4.6 funktioniert auch die mitgelieferte Ruby Version problemlos mit Rails. </p>
<p>Um Rails zu installieren sind folgende Schritte notwendig:</p>
<h2>RubyGems</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">curl <span style="color: #660033;">-O</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5207</span><span style="color: #000000; font-weight: bold;">/</span>rubygems-0.8.11.tgz
<span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf rubygems-0.8.11.tgz
<span style="color: #7a0874; font-weight: bold;">cd</span> rubygems-0.8.11
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ruby setup.rb</pre></div></div>

<h2>Rails</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails <span style="color: #660033;">--include-dependencies</span></pre></div></div>

<p>FastCGI bzw. LightTPD habe ich übersprungen, brauche ich zur Zeit nicht. Allerdings muss natürlich eine Datenbank her. Da ich bereits seit langem MySQL auf dem Rechner habe, wollte ich das auch nutzen:</p>
<h2>MySQL</h2>
<p>MySQL war der einzige Punkt, der etwas kritisch war. Die folgenden Befehle müssen natürlich an den Installationsort von MySQL angepasst werden, in den meisten Fällen wird der MySQL Installer allerdings einen Link nach /user/local/mysql erzeugt haben.</p>
<p>Folgender Befehl versagte bei mir:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql <span style="color: #660033;">--</span> <span style="color: #660033;">--with-mysql-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql</pre></div></div>

<p>Und ich sah die ganze Zeit nur:</p>
<pre>
no checking for main() in -lm...
yes checking for mysql_query() in -lmysqlclient...
no checking for main() in -lz...
yes checking for mysql_query() in -lmysqlclient...
no checking for main() in -lsocket...
no checking for mysql_query() in -lmysqlclient...
no checking for main() in -lnsl...
no checking for mysql_query() in -lmysqlclient...
</pre>
<p>Geholfen hat die explizite Angabe der Libraries und Headerverzeichnisse wie folgt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql <span style="color: #660033;">--</span> <span style="color: #660033;">--with-mysql-include</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #660033;">--with-mysql-lib</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Danach lief Rails mit dem eingebauten WEBrick problemlos.</p>
<h2>Der eingebaute Apache unter Mac OS X</h2>
<p>Für fertige Applikationen will ich den eingebauten Apache von OS X nutzen. Auch dazu gibt es einige Tutorials, aber keines alleine führte zu einer funktionierenden, sinnvollen Konfiguration.<br />
Ich bin gewohnt, dass ich meine Seiten auf meinem Rechner unter http://localhost/~msimons/blah erreiche und das wollte ich auch mit den Railsanwendungen können.</p>
<p>Der Mac OS X Apache ist in meinen Augen für einen Rechner, der nicht direkt im Internet hängt, sehr sinnvoll konfiguriert, ich wollte deshalb nicht in der zentralen httpd.conf rumpfuschen. Praktischerweise legt OS X unter /etc/httpd/users/ für jeden OS User eine weitere conf Datei an, die ich entsprechend anpasse. Dazu habe ich mir einen Link auf dieses Datei erstellt und den Eigentümter von root auf mich geändert.</p>
<p>Für eine Beispielapplikation sieht das dann so aus:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Alias</span> /~msimons/test/  <span style="color: #7f007f;">&quot;/Users/msimons/dev/rails/test/public/&quot;</span>
<span style="color: #00007f;">Alias</span> /~msimons/test   <span style="color: #7f007f;">&quot;/Users/msimons/dev/rails/test/public/&quot;</span>
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/Users/msimons/dev/rails/test/public/&quot;</span>&gt;
    <span style="color: #00007f;">Options</span> ExecCGI <span style="color: #0000ff;">FollowSymLinks</span>
    <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;</pre></div></div>

<p>Danach muss die .htaccess Datei im public Verzeichnis der Testanwendung angepasst werden:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteBase</span> /~msimons/test/</pre></div></div>

<p>Die forwardslashes sind essentiell.</p>
<p>Ich hatte <a href="http://tonyarnold.com/articles/2005/08/10/rolling-with-ruby-on-rails-on-mac-os-x-tiger-for-beginners" rel="external">hier</a> Hinweise gefunden, dass man in einigen Verzeichnissen noch Rechte anpassen muss, weil Apache natürlich nicht im Kontext des Benutzers läuft, sondern unter www:</p>
<p>Deswegen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>rails<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chgrp</span> <span style="color: #660033;">-R</span> www Test
<span style="color: #7a0874; font-weight: bold;">cd</span> Test
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 0775 db
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 0777 log
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 0775 public
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 0666 log<span style="color: #000000; font-weight: bold;">/*</span>.log</pre></div></div>

<p>Allerdings wurde dabei das tmp Verzeichnis vergessen:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> 0775 tmp</pre></div></div>

<p>Nach einem kurzen Apache Neustart über die Systemeinstellungen oder per</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> apachectl graceful</pre></div></div>

<p>steht dem Railsvergnügen unter OS X nichts mehr im Wege.</p>
<h2>Resourcen</h2>
<p>Geholfen haben mir unter anderem:</p>
<ul>
<li><a href="http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger" rel="external">Building Ruby, Rails, LightTPD, and MySQL on Tiger</a></li>
<li><a href="http://tonyarnold.com/articles/2005/08/10/rolling-with-ruby-on-rails-on-mac-os-x-tiger-for-beginners" rel="external">Rolling with ruby on rails on mac os x tiger for beginners</a></li>
<li><a href="http://wiki.rubyonrails.com/rails/pages/HowtoInstallOnOSXTiger" rel="external">HowtoInstallOnOSXTiger</a></li>
<li><a href="http://www.macdevcenter.com/pub/a/mac/2006/03/29/rails.html" rel="external">Bringing Ruby on Rails with FastCGI into Mac OS X Server</a></li>
</ul>
<p>Gute Bücher gibt es hier: <a href="http://www.pragmaticprogrammer.com" rel="external">The Pragmatic Programmer</a>. Sehr empfehlenswert <a href="http://www.pragmaticprogrammer.com/titles/rails/index.html" rel="external">Agile Web Development with Rails</a> und <a href="http://www.pragmaticprogrammer.com/titles/ruby/index.html">Programming Ruby</a>. Wenn man ersteres kauft, gibt es auf jedes Ruby Buch Rabatt. Sehr charmant.</p>
<p class="akst_link"><a href="http://info.michael-simons.eu/?p=17&amp;akst_action=share-this"  title="E-mail this, post to del.icio.us, etc." id="akst_link_17" class="akst_share_link " rel="nofollow">Share This</a>
</p>]]></content:encoded>
			<wfw:commentRss>http://info.michael-simons.eu/2006/05/05/ruby-on-rails-mit-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.685 seconds -->

