Posts
Building and Installing MongoDB on Ubuntu 10.04
Install debs required to build Mongo:
$ sudo aptitude install tcsh git-core scons g++ libpcre++-dev libboost-dev libreadline-dev libboost-program-options-dev libboost-thread-dev libboost-filesystem-dev libboost-date-time-dev
$ git clone git://github.com/mongodb/mongo.git
Download and Build Spidermonkey
$ wget ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz$ tar zxvf js-1.7.0.tar.gz$ mv js/src mongo/js$ cd mongo/js$ export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"$ make -f Makefile.ref$ sudo env JS_DIST=/usr make -f Makefile.ref export$ cd ..
$ scons all$ sudo scons --prefix=/opt/mongo install
Install Glassfish for Deployment on Ubuntu 8.10
As a follow up to my post yesterday, I'm below is a script that will install glassfish for deployment on Ubuntu 8.10.
About this script The variables at the beginning are fairly self explanatory: the script works out of $HOME/Development/jruby, and installs to /opt/glassfishv3-prelude - feel free to change these options to suit your needs.
In order to install and warble-ize an application, you've got to have jruby in your path. The script I posted yesterday will install jruby to the same place this script expects it to be.
I've tried to document the step that this script takes in the comments - let me know if you think there is anything I should update. At some point, I'll probably just merge all of this information together into an actual git repository on github so forking/pull requests will be easier.
In the next couple weeks I'll be posting some follow-ups: deploying typo on glassfish; mysql connection pooling with jdbc; securing glassfish; and whatever else anyone (myself included) finds interesting. Let me know if there is anything you'd like me to cover.
JRuby on Rails on Glassfish on Ubuntu 8.10
I've been playing around with JRuby a lot recently, and I decided to see just how hard it would be to develop and deploy a simple web application using JRuby in Ubuntu 8.10. For both development and deployment I'll be using GlassFish v3 Prelude. For development, I've been using the glassfish gem and for deployment, I've been using the GlassFish Community Distribtion. I'll try to run through my development steps today. Tomorrow I'll post the steps to deploy to a dedicated glassfish server.
Development
I'll go through the development steps I've been using first.
1. Install JRuby. I've been installing JRuby to a development directory and simply adding to my $PATH. The following script installs everything to ~/Development/jruby/ and uses sun-java6-jdk.
- Install GlassFish gem:
Tomorrow I'll go over installing a glassfish deployment environment on Ubuntu 8.10.
Ruby Enterprise Edition on Ubuntu 8.10 (x86_64)
This weekend I installed Ruby Enterprise Edition on Ubuntu 8.10. There are numerous posts about Ruby Enterprise Edition and tcmalloc on a 64-bit platform, but Phusion have said that it still won't build. Well, I made some simple changes to the installer and Ruby Enterprise Edition now builds and runs on my Ubuntu 8.10 servers with tcmalloc. See the changes to the installer and the steps to install Ruby Enterprise Edition below.
Patch used to install Ruby Enterprise Edition:
Steps to install Ruby Enterprise Edition:
First, download Ruby Enterprise Edition from Phusion:
wget http://rubyforge.org/frs/download.php/47937/ruby-enterprise-1.8.6-20081205.tar.gz
tar xzvf ruby-enterprise-1.8.6-20081205.tar.gz
Next, apply this patch to Ruby Enterprise Edition (Edit: updated patch):
wget http://gist.github.com/raw/33313/b556fae6a2f1a48c6acea0f350af0f1017efd379 -O patch.diff
cd ruby-enterprise-1.8.6-20081205
patch -p1 -E < ../patch.diff
Now simply build and Ruby Enterprise Edition as you would normally. Configure Passenger (mod_rails, mod_rack) to use the new Ruby Enterprise Edition.
/opt/ruby-enterprise-1.8.6-20081205/bin/passenger-install-apache2-module
Don't forget to make the appropriate changes to your apache.conf.
Wake-on-lan and the Intrepid Ibex
I've been using Tomato on my WRT54GL for some time. I recently decided to start keeping my servers off most of the time and instead use the built in wake-on-lan functionality of tomato. I had previously set up Ubuntu 8.04.1 with wake-on-lan, but there are some minor differences for Ubuntu 8.10 (the Intrepid Ibex).
- Install ethtool.
sudo apt-get install ethtool
- Add a file to /etc/init.d.
sudo vim /etc/init.d/wakeonlanconfig
The contents of the file should be as follows:
Note the "eth0" used above. If you're using a different interface for wake-on-lan, substitute appropriately.
- Configure the file you added in step 2 to run at boot.
sudo update-rc.d -f wakeonlanconfig defaults
- Run the file you created in step 2.
sudo /etc/init.d/wakeonlanconfig
- Change /etc/init.d/halt so the network interfaces aren't halted when the computer is shut down. At the top of the file, change this line:
NETDOWN=yes
to the following:
NETDOWN=no
That's it! From now on, every time you shut down your computer you can use the WOL interface from Tomato to wake it up.
Leopard, AFP and the Intrepid Ibex
Seeing as Intrepid will be out in a number of days, I wanted to update my previous post on installing netatalk on Ubuntu with SSL support. The steps remain pretty much the same for Ubuntu 8.10 (Intrepid Ibex). As I mentioned, It's easy enough to allow Leopard to use plaintext passwords with the following command:
$defaults write com.apple.AppleShareClient afp_cleartext_allow -bool true
You can use the following instructions to download and build netatalk on Hardy (you must have the Universe repository enabled in /etc/apt/sources.list):
$ mkdir -p ~/src/netatalk $ cd ~/src/netatalk $ sudo apt-get install devscripts cracklib2-dev dpkg-dev libssl-dev build-essential $ sudo apt-get build-dep netatalk $ apt-get source netatalk $ cd netatalk-2.0.3 $ DEB_BUILD_OPTIONS=ssl dpkg-buildpackage -us -uc $ sudo debi
Netatalk is now properly installed, but there are two tweaks i suggest. First, tell dpkg not to upgrade netatalk:
$ echo "netatalk hold" | sudo dpkg --set-selections
Second, I always edit /etc/default/netatalk to set the following:
ATALKD_RUN=no PAPD_RUN=no
Disabling atalkd and papd mean Netatalk will start much faster. I don't know anyone that uses atalkd or papd anymore, so it's worth looking into.
You should now be able to connect from Leopard to your Intrepid home directory!
Install Mysql Gem on Leopard
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/opt/local/bin/mysql_config5
Migrated over to SliceHost
I finally migrated my blog from MediaTemple over to SliceHost. Things have been running much better, and the blog is much easier to maintain from my perspective.
Leopard, AFP and the Hardy Heron
Damon Timm has a great post on installing netatalk on Ubuntu with SSL support. I won't go through the licensing issues again (I feel like enough people have done that already). Suffice to say, Ubuntu doesn't ship netatalk with SSL enabled, and Leopard requires SSL support to connect to AFP shares out of the box. It's easy enough to allow Leopard to use plaintext passwords with the following command:
defaults write com.apple.AppleShareClient afp_cleartext_allow -bool true
I just felt it would be a better idea to enable SSL by default on Hardy.This, as they say, is where things get tricky. First, the version of netatalk in Hardy is broken (see discussion of the bug in Debian here). There are one of two ways to fix this, simply hand-edit the offending patch, or use the source packages provided by Debian. With this in mind, you can use the following instructions to download and build netatalk on Hardy (keeping in mind, as Damon mentions, you must have the Universe repository enabled in /etc/apt/sources.list):
$ mkdir -p ~/src/netatalk $ cd ~/src/netatalk $ sudo aptitude install devscripts cracklib2-dev dpkg-dev libssl-dev build-essential $ sudo apt-get build-dep netatalk $ apt-get source netatalk
Edit: the current version in Hardy is now 2.0.3-9. The patch is no longer necessary. If you choose to use the apt-get source line above, you should hand-edit the offending patch (that is until the MOTU update netatalk from version 2.0.3-7 to 2.0.3-8). Below is a diff containing the only change necessary:
--- netatalk-2.0.3/debian/patches/107_afpd-zeroconf.patch
2007-12-21 21:53:43.000000000 +0100
+++ netatalk-2.0.3.new/debian/patches/107_afpd-zeroconf.patch
2007-12-21 21:56:52.000000000 +0100
@@ -350,7 +350,7 @@
+{
+ struct context *ctx = userdata;
+
-+ assert(g == ctx->group);
++ assert(!ctx->group || g == ctx->group);
+
+ switch (state) {
+
At this point you're free to continue building netatalk. EDIT: sudo su isn't necessary with the new version of the package.
NB: the instructions below differ from Damon's because building with an environment variable before "sudo" when env_reset is set in sudoers (the default behavior in Hardy) makes your efforts useless! You should sudo su before creating the build rather than building with sudo (unless you don't mind the potential security risk of removing env_reset from sudoers)
$ cd netatalk-2.0.3 $ DEB_BUILD_OPTIONS=ssl dpkg-buildpackage -us -uc $ sudo debi
You should now be able to connect from Leopard to your Hardy Heron home directory!
GlobalSAN iSCSI Initiator and Leopard
I've spent the last several days messing with the GlobalSAN iSCSI initiator on Leopard, and long story short, it doesn't work very well at all. Numerous hardlocks (on the order of 5 minutes after beginning a long-ish read/write operation).
I managed to get my Ubuntu Hardy Heron box set up with iSCSI, mounted the Thecus with hfsplus, and got my data off that way. I'll be posting more information on my iSCSI setup under ubuntu, as well as how I'm putting together the MythTV box.
In other news I took the plunge and got the PeepCode unlimited special for Ruby on Rails programming screencasts. I'm actually really liking the screencasts, despite the fact I have a fair amount of rails experience.
Hopefully I can follow some of this up tomorrow.
Dial Car
Time to catch the dial-car!
I’m not sure why, but Twitter is incredibly addictive. They’re having some infrastructure problems right now. I think after SXSW they got some serious user influx – apparently its growing at an insane rate. Anyway, back to work.
Rails and OS X through Darwinports
I've been working on installing Rails for OSX using darwinports, but the performance I'm getting is just terrible. I can't really figure out why the server is lagging so much. I did manage to get lighttpd set up, but I'm still trying to figure out if there is a config string I can use in order to set up fastcgi for all my rails vhosts (without specifying them individually). Is it possible that mysql-vhosting supports this?
Ubuntu, Rails, Typo and Apache2
I know dapper is in pre-release right now, but I decided to go ahead and get flight2 up and running, and document my experience installing Typo from scratch.
This install basically requires 2 steps, only one of which I'm going to document. The first step, is installing Ubuntu Dapper Flight 2, and this is up to you. These instructions will almost certainly work with Breezy, and possibly some of the older versions of Ubuntu. As far as Debian is concerned, I have no idea whether or not this will work, so YMMV.
Ubuntu Repository Data
First and foremost, in order to have a working Rails install, we're going to need to enable the universe repository.
Open /etc/apt/sources.list, and make sure to uncomment the lines for the universe repository.
Ruby
As rails is written in Ruby, you need to install a working ruby environment with all the bells and whistles!
sudo apt-get install ruby irb irb1.8 libdbm-ruby1.8 libfcgi-ruby1.8 libfcgi0 libgdbm-ruby1.8 libopenssl-ruby1.8 libruby1.8-dbg ri ri1.8 ruby1.8-dev
RubyGems
Because ubuntu doesn't include rubygems in their repository, you have to install rubygems from source. Fortunately, this isn't a very complicated installation method, and rubygems has a mechanism to insure it stays up to date outside of APT.
wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar zxvf rubygems-0.8.11.tgz
cd rubygems-0.8.11
sudo ruby1.8 setup.rb
As of this writing, Rubygems-0.8.11 was the most current version of rubygems, but you might want to make sure that rubygems is up to date with this command: sudo gem install rubygems-update
Installing Mysql
Typo doesn't require MySQL, but that's the database that I use to host my blog. To install MySQL, we simply:
sudo apt-get install mysql-common libmysqlclient12 libmysqlclient12-dev mysql-server libmysql-ruby1.8
I know that libmysql-ruby1.8 installs the mysql ruby bindings, but in order to make sure I have the most updated bindings, I run:
sudo gem install mysql -y
Installing Rails
sudo gem install rails -y
Installing Apache2 with fastcgi bindings
sudo apt-get install apache2 libapache2-mod-fcgid
sudo a2enmod fcgid
sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
Build Essential
Technically, the build-essential packages aren't necessary, as there are fcgi libraries in Ubuntu, but I always install them anyway. You never know when you're going to need this stuff
sudo apt-get install build-essential
At this point, rails should be installed and functioning.
FastCGI
There are two ways to go about installing FastCGI support, one through APT, the other directly from source.
apt-get install libfcgi-dev
sudo gem install fcgi
Other Modules
There are a number of useful gems that one can install, and installation is a snap with Rubygems.
Say for example you want to install the flickr interface. You'd simply type
sudo gem install flickr -y and the gem is automagically installed.
Installing Typo
I'm installing typo from the SVN repository, as I find that the code isn't too 'bleeding edge,' and staying current generally has more benefits than drawbacks. In order to check out the code, I went to the
/var/www/
svn checkout svn://leetsoft.com/typo/trunk typo Typo is now installed on the machine, but we first have to create the database, add the typo host, and then make some changes in order to ensure that the proper page is displayed.
Creating the typo database is a fairly simple procedure. Use mysqladmin to create the databases like this:
<div class="typocode"><pre><code class="typocode_default "><notextile>mysqladmin -u root -p create typo_dev
mysqladmin -u root -p create typo_tests
</notextile></code></pre></div>
Optionally, you can create a separate database for production usage as well. Then import the database schema like so:
<div class="typocode"><pre><code class="typocode_default "><notextile>cd /var/www/typo/db
mysql -u root -p typo_dev < schema.mysql-v3.sql
Finally you need to edit the
config/database.yml <div class="typocode"><pre><code class="typocode_default "><notextile>login: &login
adapter: mysql host: localhost username: root password: ROOT_PASSWORD
development: database: typo_dev <<: *login
test: database: typo_tests <<: *login
production: database: typo_dev <<: *login
</notextile></code></pre></div>
I created my own vhost for typo. I created a file called
typo /etc/apache2/sites-available <div class="typocode"><pre><code class="typocode_default "><notextile>NameVirtualHost *
<VirtualHost *>
ServerName sethbc.org
DocumentRoot /var/www/typo/public/
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/typo.log combined
<Directory /var/www/typo/public/>
Options ExecCGI FollowSymLinks
AddHandler cgi-script .cgi
AllowOverride all
Order allow,deny
Allow from all
</Directory> </VirtualHost>