I have moved!

My new blog is at lindsaar.net

All the old content will stay here though. But check out the new blog

¿ 13/8/2007 - Ruby on Rails in OpenBSD chroot

Was getting OpenBSD working today and ran into a bug.

Specifically, it wouldn't start.  Looking in the development.log I found this offensive error...

No such file or directory - /tmp/mysql.sock

OK, so we can't get to the mysql.socket file...

Good, lets find the socket file.. on my OpenBSD system, this lives in /var/run/mysql/mysql.sock

So... going into database.yml, change this to reflect:

development:
  adapter: mysql
  database: test_development
  socket: /var/run/mysql/mysql.sock
  username: username
  password: password
  host: localhost

Run it all again, still error.. look in the development log, now we find:

No such file or directory - /var/run/mysql/mysql.sock

HUH?!

After thinking about this for a bit, I remember I am running apache in a chroot environment, and of course you wouldn't be able to reach a directory that is outside the chroot environment.  Think about THIS for second and realise, best way?  Don't use a socket and use a TCP/IP port instead...

So the final result:
development:
adapter: mysql
database: test_development
username: username
password: password
host: 127.0.0.1
port: 3306


And voila!

blogLater

Mikel
Post A Comment! :: Send to a Friend!

¿ 25/10/2007 - Using a mysql socket from apache chroot

Posted by Anonymous

I use a socket, you just need to set it up before it can be seen from the chroot jail, here is the startup code in /etc/rc.local

[code]
# Add your local startup actions here.
# Start MySQL server
if [ -x /usr/local/bin/mysqld_safe ] ; then
su -c _mysql root -c '/usr/local/bin/mysqld_safe &' > /dev/null & echo -n ' mysql'

for i in 1 2 3 4 5 6; do
if [ -S /var/run/mysql/mysql.sock ]; then
break
else
sleep 1
echo -n "."
fi
done

# Apache chroot Settings
mkdir -p /var/www/var/run/mysql
sleep 2
ln -f /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock

fi
[/code]

my script got mangled, since I don't know the formatting rules here, but you get the idea ;)

-Sean

Permanent Link

About Me

AKA Raasdnil, this site is about web coding, hosting and all other matters that relate to this... especially Ruby on Rails!

Links