26March2008

Wordpress 2.5 RC2 Is Out

Posted by gbenedict under: wordpress.

Update: Wordpress 2.5 has gone final. Great work from the teams at Auttomatic & Happy Cog, along with all of the contributors.

The latest release candidate of Wordpress, 2.5 RC2, is out. So far I haven’t noticed any major changes from RC1, just some tweaks based on feedback.

Matt (Wordpress co-founder) has put together a quick screen cast as an overview of the major changes compared to earlier 2.x releases. It’s well worth the look

Also, if you are going to upgrade to any release of 2.5, check out the official which plugins work and which don’t list before upgrading. Once you’re in the clear, go install. The admin tool is so much better.

1 

20March2008

Wordpress 2.5 RC1 - First Impressions

Posted by gbenedict under: wordpress.

Update: Wordpress 2.5 has gone final. Great work from the teams at Auttomatic & Happy Cog, along with all of the contributors.

Yesterday I was working through my latest feed updates in Google Reader when I came across more information on the new Wordpress 2.5 changes on Jeffery Zeldman’s blog. I kept it unread so I could come back to it later, but after what I saw, I kept thinking about it all day. Could it really be that good?

Tonight I pulled a copy of the site down to my laptop and did a test upgrade. Everything checked out( themes and plugins), so I went for it on the live site. Don’t worry, I backed up first.

I really enjoy the new editor - TinyMCE 3. Especially since it works correctly in Safari 3. I prefer Safari for its superior font rendering and speed, but I was relegated to Firefox under 2.3.3 and below.

Hats off to the team at Happy Cog. They’ve done some great work here. For more details, Techosailor has a full write up on the changes that is worth a read.

Also, Matt from Wordpress notes this is production ready, but they wanted feedback on the design before finalizing 2.5. Don’t be scared of that RC1 name, go upgrade!

0 

21February2008

Mysql Ruby Gem Install Issues — Solved!

Posted by gbenedict under: apple; ruby.

I ran into an issue today installing the ruby mysql gem on a fresh Leopard system with 10.5.1 installed and the MySQL 5 package for Intel installed. This is based on Dan Benjamin’s great work.

To keep this easy, here is the low down. What was happening was an issue with it expecting headers for PPC. PPC? What the??? I’m on intel damn it!

Here’s how you can fix it. This is two lines. Enter your password (not root).

sudo su -

ARCHFLAGS=’-arch i386′ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Here was the original gem command and associated output

sudo gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
Select which gem to install for your platform (universal-darwin9.0)
1. mysql 2.7.3 (mswin32)
2. mysql 2.7.1 (mswin32)
3. mysql 2.7 (ruby)
4. mysql 2.6 (ruby)
5. Skip this gem
6. Cancel installation
> 3
Building native extensions. This could take a while…
ERROR: While executing gem … (Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
checking for mysql_ssl_set()… no
checking for mysql.h… yes
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I. -DHAVE_MYSQL_H -I/usr/local/mysql/include -Os -arch i386 -fno-common -fno-common -arch ppc -arch i386 -Os -pipe -fno-common -c mysql.c
cc -arch ppc -arch i386 -pipe -bundle -o mysql.bundle mysql.o -L”.” -L”/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib” -L. -arch ppc -arch i386 -lruby -L/usr/local/mysql/lib -lmysqlclient -lz -lm -lpthread -ldl -lm
ld: warning in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
Undefined symbols for architecture ppc:
“_mysql_store_result”, referenced from:
_store_result in mysql.o
_query in mysql.o
“_mysql_stmt_errno”, referenced from:
_mysql_stmt_raise in mysql.o
_stmt_prepare in mysql.o
_stmt_result_metadata in mysql.o
“_mysql_stmt_error”, referenced from:
_mysql_stmt_raise in mysql.o
“_mysql_options”, referenced from:
_options in mysql.o
“_mysql_refresh”, referenced from:
_refresh in mysql.o
_reload in mysql.o
“_mysql_get_client_version”, referenced from:
_client_version in mysql.o
“_mysql_stmt_bind_result”, referenced from:
_stmt_bind_result in mysql.o
_stmt_execute in mysql.o
“_mysql_fetch_lengths”, referenced from:
_fetch_hash2 in mysql.o
_fetch_lengths in mysql.o
_fetch_row in mysql.o
“_mysql_character_set_name”, referenced from:
_character_set_name in mysql.o
“_mysql_set_server_option”, referenced from:
_query in mysql.o
_set_server_option in mysql.o
“_mysql_real_query”, referenced from:
_query in mysql.o
_query in mysql.o
“_mysql_num_fields”, referenced from:
_fetch_hash2 in mysql.o
_fetch_fields in mysql.o
_fetch_field_direct in mysql.o
_fetch_lengths in mysql.o
_fetch_row in mysql.o
_num_fields in mysql.o
_stmt_prepare in mysql.o
“_mysql_ping”, referenced from:
_ping in mysql.o
“_mysql_free_result”, referenced from:
_free_mysqlres in mysql.o
_free_mysqlstmt_memory in mysql.o
_free_mysqlstmt in mysql.o
_list_dbs in mysql.o
_list_tables in mysql.o
_res_free in mysql.o
_stmt_free_result in mysql.o
“_mysql_rollback”, referenced from:
_rollback in mysql.o
“_mysql_next_result”, referenced from:
_query in mysql.o
_next_result in mysql.o
“_mysql_data_seek”, referenced from:
_data_seek in mysql.o
“_mysql_autocommit”, referenced from:
_autocommit in mysql.o
“_mysql_debug”, referenced from:
_my_debug in mysql.o
“_mysql_stmt_affected_rows”, referenced from:
_stmt_affected_rows in mysql.o
“_mysql_stmt_insert_id”, referenced from:
_stmt_insert_id in mysql.o
“_mysql_use_result”, referenced from:
_use_result in mysql.o
“_mysql_stmt_fetch”, referenced from:
_stmt_fetch in mysql.o
“_mysql_stmt_free_result”, referenced from:
_stmt_free_result in mysql.o
“_mysql_field_seek”, referenced from:
_field_seek in mysql.o
“_mysql_stmt_param_count”, referenced from:
_stmt_param_count in mysql.o
_stmt_prepare in mysql.o
“_mysql_fetch_row”, referenced from:
_list_dbs in mysql.o
_list_tables in mysql.o
_fetch_hash2 in mysql.o
_fetch_row in mysql.o
“_mysql_sqlstate”, referenced from:
_mysql_raise in mysql.o
_sqlstate in mysql.o
“_mysql_stmt_sqlstate”, referenced from:
_mysql_stmt_raise in mysql.o
_stmt_sqlstate in mysql.o
“_mysql_list_processes”, referenced from:
_list_processes in mysql.o
“_mysql_real_escape_string”, referenced from:
_real_escape_string in mysql.o
“_mysql_stmt_bind_param”, referenced from:
_stmt_execute in mysql.o
“_mysql_field_count”, referenced from:
_field_count in mysql.o
_query in mysql.o
_query in mysql.o
“_mysql_field_tell”, referenced from:
_field_tell in mysql.o
“_mysql_stmt_result_metadata”, referenced from:
_stmt_prepare in mysql.o
_stmt_result_metadata in mysql.o
“_mysql_list_tables”, referenced from:
_list_tables in mysql.o
“_mysql_stmt_prepare”, referenced from:
_stmt_prepare in mysql.o
“_mysql_get_client_info”, referenced from:
_client_info in mysql.o
“_mysql_thread_id”, referenced from:
_thread_id in mysql.o
“_mysql_stmt_execute”, referenced from:
_stmt_execute in mysql.o
“_mysql_stmt_init”, referenced from:
_stmt_init in mysql.o
“_mysql_stat”, referenced from:
_my_stat in mysql.o
“_mysql_stmt_field_count”, referenced from:
_stmt_field_count in mysql.o
“_mysql_close”, referenced from:
_free_mysql in mysql.o
_my_close in mysql.o
“_mysql_stmt_data_seek”, referenced from:
_stmt_data_seek in mysql.o
“_mysql_fetch_fields”, referenced from:
_fetch_hash2 in mysql.o
_fetch_fields in mysql.o
_stmt_bind_result in mysql.o
_stmt_execute in mysql.o
_stmt_prepare in mysql.o
“_mysql_list_fields”, referenced from:
_list_fields in mysql.o
“_mysql_row_seek”, referenced from:
_row_seek in mysql.o
“_mysql_change_user”, referenced from:
_change_user in mysql.o
“_mysql_stmt_row_seek”, referenced from:
_stmt_row_seek in mysql.o
“_mysql_stmt_close”, referenced from:
_free_mysqlstmt in mysql.o
_stmt_close in mysql.o
“_mysql_info”, referenced from:
_info in mysql.o
“_mysql_init”, referenced from:
_init in mysql.o
_real_connect in mysql.o
“_mysql_get_server_info”, referenced from:
_server_info in mysql.o
“_mysql_fetch_field_direct”, referenced from:
_fetch_field_direct in mysql.o
“_mysql_dump_debug_info”, referenced from:
_dump_debug_info in mysql.o
“_mysql_row_tell”, referenced from:
_row_tell in mysql.o
“_mysql_real_connect”, referenced from:
_real_connect in mysql.o
_real_connect2 in mysql.o
“_mysql_stmt_row_tell”, referenced from:
_stmt_row_tell in mysql.o
“_mysql_kill”, referenced from:
_my_kill in mysql.o
“_mysql_num_rows”, referenced from:
_list_dbs in mysql.o
_list_tables in mysql.o
_num_rows in mysql.o
“_mysql_warning_count”, referenced from:
_warning_count in mysql.o
“_mysql_stmt_num_rows”, referenced from:
_stmt_num_rows in mysql.o
“_mysql_stmt_attr_set”, referenced from:
_stmt_init in mysql.o
“_mysql_get_server_version”, referenced from:
_query in mysql.o
_server_version in mysql.o
“_mysql_more_results”, referenced from:
_more_results in mysql.o
“_mysql_select_db”, referenced from:
_select_db in mysql.o
“_mysql_stmt_store_result”, referenced from:
_stmt_execute in mysql.o
“_mysql_get_host_info”, referenced from:
_host_info in mysql.o
“_mysql_commit”, referenced from:
_commit in mysql.o
“_mysql_shutdown”, referenced from:
_my_shutdown in mysql.o
“_mysql_list_dbs”, referenced from:
_list_dbs in mysql.o
“_mysql_affected_rows”, referenced from:
_affected_rows in mysql.o
“_mysql_insert_id”, referenced from:
_insert_id in mysql.o
“_mysql_fetch_field”, referenced from:
_fetch_field in mysql.o
“_mysql_get_proto_info”, referenced from:
_proto_info in mysql.o
“_mysql_errno”, referenced from:
_mysql_raise in mysql.o
_my_close in mysql.o
_my_errno in mysql.o
“_mysql_error”, referenced from:
_mysql_raise in mysql.o
_my_error in mysql.o
“_mysql_escape_string”, referenced from:
_escape_string in mysql.o
ld: symbol(s) not found for architecture ppc
collect2: ld returned 1 exit status
lipo: can’t open input file: /var/tmp//ccKOmYXs.out (No such file or directory)
make: *** [mysql.bundle] Error 1

Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out

1 

21February2008

Judgement Day

Posted by gbenedict under: apple.

The MacPorts funding bill is passed. The system goes online on February 20th, 2008. Human decisions are removed from strategic installation. MacPorts begins to learn at a geometric rate. It becomes self-aware at 3:03pm Eastern time, February 21st. In a panic, they try to pull the plug. And, MacPorts installs itself.

macports.png 

0 

14February2008

The Next Evolution in Mongrel Is Thin

Posted by gbenedict under: mongrel; nginx; rubinius; ruby; thin.

The Quick Background
First there was Zed’s excellent (and much appreciated) baseline work that establish Mongrel as the front runner in ruby hosting. Something I’ve been using for well over a year in production behind nginx. From that baseline evolved a few hacks: Evented Mongrel and Swiftiply Proxy.

The problem is that they were just that — Hacks that monkey patched the source code. Bye-bye needed updates. As much as I liked the perf gains from running them, it was not a great production solution.

Enter the Geneticist
So late last year Marc-Andre Cournoyer starting playing around doing what I’ve wanted to, but owning a business and raising a family, didn’t have time to do. He made event driven Mongrel a practical solution for production hosting. Enter the world of Thin –it takes the best of Mongrel, Event Machine & Rack, mashes them together and poof we have a new contender. Check out the specs on the official website.

It’s getting good community traction too. We’ve seen 8 versions since early January and a big uptake in the Google group.

I’ve been using it in development and staging with great success. With Mongrel, I could run 2-3 hours and then restart in development mode. With Thin, I’ve actually run 16+ with no notice of slowdown. The memory footprint on this is also much smaller than Mongrel. That’s a nice side effect.

As a testament, I’m actively building out identical Dell PowerEdge 1950 8 core Xeon boxes (2 procs x 4 cores each). They are running 8 CentOS 4.6 VMs under VMWare with nginx load balancing to 10 Thin clustered servers on each VM. 160 Thin instances makes for some serious Rails and Merb hosting. Ok, I’ll stop glowing and shut the fuck up.

Note: I tried CentOS 5.1 first. The support just isn’t there yet as I kept hitting walls with VMWare. Stick with 4.6.

Installation & Usage
Minimum Requirements include either Ruby 1.86 or 1.9. Love that last bit about 1.9.

sudo gem install thin

If you are running in dev mode on your local machine, it’s easy.

thin start

As the gem is still adding features, check out the official docs for setup in production environments. We’re monitoring these with Monit incase of failure.

Wait! Coding in Ruby is Enjoyable, why isn’t Hosting?
Of course it is! Just look at these great code names for the releases:

0.6.4 - Sexy Lobster
0.6.3 - Ninja Cookie
0.6.2 - Rambo
0.6.1 - Cheesecake
0.5.4 - Flying Mustard*
0.5.3 - Purple Yogurt
0.5.2 - Cheezburger
0.5.1 - LOLCAT

*That’s my favorite.

So it’s not THAT enjoyable. Keep reading.

Where Do We Go From Here?
While this is much better than what we’ve had to date, I still consider this a minor evolution in Ruby hosting while we wait for a better solution. I believe that the next revolution is coming with Rubinius, it’s just no where near ready for prime-time yet.

Can you say multi-threaded Ruby with direct Apache support? Engine Yard is betting their business on it.

3 

25January2008

Compile Errors Installing Ruby-Xslt and Libxml-Ruby Gems

Posted by gbenedict under: linux; ruby.

I was setting up a new server for a client yesterday and was beating my head getting a few gems install.If you are having issues installing the ruby-xslt and ruby-xml gems on linux (I was on CentOS 5.1), make sure the developer libraries of libxml and xslt are installed. I had the rpms installed, but not the developer versions. For Red Hat based builds, you can do the following:

yum install libxml2-devel      

yum install xslt-devel

 Then you can install the gems.

gem install libxml-ruby      

gem install ruby-xslt 

Here is what the failure looked like for gem install ruby-xslt: 

   


gem install ruby-xslt
Building native extensions.  This could take a while...
ERROR:  Error installing ruby-xslt:
	ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install ruby-xslt
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetFile() in -lxslt... no
checking for exsltRegisterAll() in -lexslt... no
extconf.rb:4: command not found: xslt-config --cflags
creating extconf.h
creating Makefile
/usr/local/lib/ruby/1.8/mkmf.rb:1102: warning: global variable `$preload' not initialized

make
gcc -I. -I. -I/usr/local/lib/ruby/1.8/i686-linux -I. -DRUBY_EXTCONF_H=\"extconf.h\"  -fPIC -g -Wall -I/usr/include/libxml2  -g -O2 -DUSE_ERROR_HANDLER -DUSE_EXSLT  -c xslt_lib.c
In file included from xslt_lib.c:19:
xslt.h:36:27: error: libxslt/extra.h: No such file or directory
xslt.h:37:26: error: libxslt/xslt.h: No such file or directory
xslt.h:38:35: error: libxslt/xsltInternals.h: No such file or directory
xslt.h:39:31: error: libxslt/transform.h: No such file or directory
xslt.h:40:31: error: libxslt/xsltutils.h: No such file or directory
xslt.h:41:29: error: libxslt/imports.h: No such file or directory
xslt.h:44:30: error: libexslt/exslt.h: No such file or directory
In file included from xslt.h:52,
                 from xslt_lib.c:19:
parser.h:24: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘parse_xsl’
parser.h:25: error: expected ‘)’ before ‘xmlDocPtr’
In file included from xslt.h:54,
                 from xslt_lib.c:19:
extfunc.h:22:32: error: libxslt/extensions.h: No such file or directory
In file included from xslt_lib.c:19:
xslt.h:88: error: expected specifier-qualifier-list before ‘xsltStylesheetPtr’
xslt_lib.c: In function ‘ruby_xslt_free’:
xslt_lib.c:29: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:30: warning: implicit declaration of function ‘xsltFreeStylesheet’
xslt_lib.c:30: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘ruby_xslt_mark’:
xslt_lib.c:53: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:53: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:55: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:55: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c: In function ‘ruby_xslt_new’:
xslt_lib.c:80: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:82: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:83: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:85: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:86: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c: In function ‘ruby_xslt_xml_obj_set’:
xslt_lib.c:136: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c: In function ‘ruby_xslt_xsl_obj_set’:
xslt_lib.c:231: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:233: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:233: warning: implicit declaration of function ‘parse_xsl’
xslt_lib.c:234: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘ruby_xslt_serve’:
xslt_lib.c:291: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:293: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:296: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:297: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:299: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:300: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:306: warning: implicit declaration of function ‘parse’
xslt_lib.c:306: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c:306: warning: assignment makes pointer from integer without a cast
xslt_lib.c:308: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:309: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:311: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:312: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:315: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c:316: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c:320: error: ‘RbTxslt’ has no member named ‘xXmlResultCache’
xslt_lib.c: In function ‘ruby_xslt_parameters_set’:
xslt_lib.c:425: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:427: error: ‘RbTxslt’ has no member named ‘pxParams’
xslt_lib.c:428: error: ‘RbTxslt’ has no member named ‘iNbParams’
xslt_lib.c:429: error: ‘RbTxslt’ has no member named ‘iXmlResultType’
xslt_lib.c: In function ‘ruby_xslt_media_type’:
xslt_lib.c:453: error: ‘xsltStylesheetPtr’ undeclared (first use in this function)
xslt_lib.c:453: error: (Each undeclared identifier is reported only once
xslt_lib.c:453: error: for each function it appears in.)
xslt_lib.c:453: error: expected ‘;’ before ‘vXSLTSheet’
xslt_lib.c:457: error: ‘vXSLTSheet’ undeclared (first use in this function)
xslt_lib.c:457: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘ruby_xslt_reg_function’:
xslt_lib.c:474: warning: implicit declaration of function ‘xsltRegisterExtModuleFunction’
xslt_lib.c: In function ‘ruby_xslt_to_s’:
xslt_lib.c:485: error: ‘xsltStylesheetPtr’ undeclared (first use in this function)
xslt_lib.c:485: error: expected ‘;’ before ‘vXSLTSheet’
xslt_lib.c:491: error: ‘vXSLTSheet’ undeclared (first use in this function)
xslt_lib.c:491: error: ‘RbTxslt’ has no member named ‘tParsedXslt’
xslt_lib.c: In function ‘Init_xslt_lib’:
xslt_lib.c:544: error: ‘xsltMaxDepth’ undeclared (first use in this function)
xslt_lib.c:545: error: ‘XSLT_MAX_SORT’ undeclared (first use in this function)
xslt_lib.c:546: error: ‘xsltEngineVersion’ undeclared (first use in this function)
xslt_lib.c:547: error: ‘xsltLibxsltVersion’ undeclared (first use in this function)
xslt_lib.c:548: error: ‘xsltLibxmlVersion’ undeclared (first use in this function)
xslt_lib.c:549: error: ‘XSLT_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:550: error: ‘XSLT_DEFAULT_VENDOR’ undeclared (first use in this function)
xslt_lib.c:551: error: ‘XSLT_DEFAULT_VERSION’ undeclared (first use in this function)
xslt_lib.c:552: error: ‘XSLT_DEFAULT_URL’ undeclared (first use in this function)
xslt_lib.c:553: error: ‘XSLT_LIBXSLT_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:554: error: ‘XSLT_NORM_SAXON_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:555: error: ‘XSLT_SAXON_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:556: error: ‘XSLT_XT_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:557: error: ‘XSLT_XALAN_NAMESPACE’ undeclared (first use in this function)
xslt_lib.c:584: warning: implicit declaration of function ‘xsltSetGenericErrorFunc’
xslt_lib.c:588: warning: implicit declaration of function ‘exsltRegisterAll’
make: *** [xslt_lib.o] Error 1

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/ruby-xslt-0.9.5 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/ruby-xslt-0.9.5/ext/xslt_lib/gem_make.out

2 

30December2007

Mongrel Security Alert

Posted by gbenedict under: mongrel.

Make sure you install the latest 1.0.x or 1.1.x release of Mongrel. There is a security hole in the DirHandler that allows read access to the file system.

sudo gem install mongrel

You should be running at least 1.05 or 1.1.3.

Per Zed and others on the mailing list, here are the details:

1) If you use nginx or apache (and maybe other full web servers with aproxy module) then you can wait to upgrade, but probably not verylong. This is because these servers do their own checking as well, andare handling your files. That means a request for the file will bedropped, and blocked.

2) If you use a pure TCP/IP based proxy balancer (balance, pen,swiftiply?) then you must upgrade as these do no checks on the incomingTCP packets.

3) If you use mongrel directly to serve content then you must upgrade.

0 

28November2007

Outputting Custom Model Attributes With to_json

Posted by gbenedict under: ruby on rails.

I’m working on a project where I need to convert a model attribute on the fly from XML to XHTML. However, when I tried to drop it out using to_json on the object array, it didn’t display! Here’s how you can output an attr_reader method.

Here is the info from the model:

class Section < ActiveRecord::Base

after_find #this forces it to run anytime a find is called (pre-building it)attr_reader :content

def content=(value)

@content = value

end

def content

@content

end

def after_find

xml = self.content_xml

xslt = XML::XSLT.new()
xslt.xml = REXML::Document.new( “<?xml version=\”1.0\”?><book>\r\n#{xml}</book>” )
xslt.xsl = REXML::Document.new( File.new( “#{RAILS_ROOT}/db/xslt/to_xhtml.xsl” ) )

out = xslt.serve()
xhtml = Hpricot.XML(out)

self.content = xhtml.at(”body”).innerHTML

end

end

If you put the returned section array into yaml - y(@section), you’ll see it doesn’t show up in the attributes, but in the methods. So in reality meth_reader would be a more accurate name — but I digress. :)

Now here is how you make it work. Note the :methods => :content option. That’s what I couldn’t figure out.

@section = Section.find(:all, :select => “section_number, content_xml”, :conditions => “translation_id = #{translation_id} and section_number > #{section_number}”, :order => ’section_number’, :limit => 15)

respond_to { |format|

format.html {}
format.xml { render :xml => @section.to_xml(:only => :section_number,:methods => :content) }
format.js { render :json => @section.to_json(:only => :section_number, :methods => :content) }

}

Disclaimer: This is based on Rails 2.0 RC1.

0 

26October2007

Enabling PHP5 on OS X 10.5 Leopard

Posted by gbenedict under: apache; apple.

Leopard (OS X 10.5) ships with PHP 5.2.4 (cli) installed along side Apache 2.2.6. However, it’s disabled by default. Here’s how to enable it.

Open Terminal and choose your editor (vi, pico or other) and edit the following (sudo required!):

/etc/apache2/httpd.conf

Then search for the word php.It will find the line

LoadModule php5_module libexec/apache2/libphp5.so.

Uncomment this and save.At the command prompt site

sudo apachectl restart

That’s it!

0 

18September2007

A Full Rails Stack With RM-Install on Ubuntu

Posted by gbenedict under: development; hosting; linux; mongrel; ruby; ruby on rails.

Updated: I’ve added info to modify the /etc/profile script to load the path vars for all users.

Five Runs has just released an installer for automating the installation process of a full rails stack based on either a development or production environment. Included in the install are:

  • Ruby 1.8.6
  • Rails 1.2.3
  • MySQL 5.0
  • SQLite 3.3
  • Subversion 1.4
  • Apache HTTP Server 2.2 (Production mode)
  • OpenSSL
  • ImageMagick 6.3
  • Mongrel/Mongrel Cluster
  • Capistrano
  • Gruff
  • Rake
  • RMagick

The install is a binary executable that will run command line or as a gui application. There are currently two versions: linux and OS X 10.4.x.

To get started, I’ve setup Ubuntu 6.06 LTS server in Parallels on my Mac Book Pro. Note that I used that alternate install disc instead of the server or desktop discs. There is a known issue with the server disc that causes it to hang on reboot. You can grab the desktop(live cd), server or alternate disc here: http://osmirrors.cerias.purdue.edu/pub/ubuntu-releases/6.06.1/

If you choose the alternate disc, simply enter server at the command prompt to install it. Using the defaults you’ll be in great shape.

Once you are setup, login to you ubuntu server via the terminal or SSH. You’ll need to download rm install now. Skipping registration, the download page is here: http://www.fiveruns.com/products/rm/install/download. Be sure to choose the linux version. Here is the version as of me writing this:

wget http://www.fiveruns.com/downloads/rminstall-1.0.1-linux.bin
chmod 755 rminstall-1.0.1-linux.bin
sudo ./rminstall-1.0.1-linux.bin

Be sure to sudo when running the script or it will drive you crazy why you can’t setup Apache on port 80.

Here’s where the boring part comes in. With the command line install you have to page (via the enter key) WAY TOO MUCH to read all of the EULAs! I just held down the enter key until I saw a yes/no accept prompt, and hit yes.

Depending on your install you’ll choose the developer or server install. I’ve used the server install here.

From there, I chose to install to /opt/rminstall/ rather than the default ~/rminstall. It makes more sense to me to have it in a convenient shared place that is common to every server or desktop install.

The server install includes mongrel cluster and apache with the load balancing option all setup, where the developer path does not. Other than that, they are identical.

Once installed, they recommend that you setup a .proflie to auto load the paths correctly. Ubuntu (Debian as well) uses a .bash_profile instead, so it’s slightly different. You’ll need to run this for all users who need access.

echo "source /opt/rminstall/scripts/setenv.sh" >> ~/.bash_profile

Update: You can also add this to the /etc/profile file to make it load for all users!

sudo vi /etc/profile

At the top of the file, put the following 3 lines:

if [ -f /opt/rminstall/scripts/setenv.sh ]; then
. /opt/rminstall/scripts/setenv.sh
fi

You can now logout and log back in and you’ll be able to type ruby -v, rails -v or other commands such as mysql and rake.

This really is a blazingly fast install (< 10 minutes in a VM!). Configuring ImageMagick has always been a pain in the ass and this just makes life easy.

Check it out. It works great!

5