I spent quite a bit of time getting mod_perl, apache and mysql to play nice on solaris (the nevada builds) some few months ago. I eventually found CoolStack and after some amount of effort got up and running. A nice private wiki page documented each command needed to get up and running on a solaris zone. Recently I got a new X4150 from Sun and wanted to try out their project indiana stuff, which I guess is really OpenSolaris proper. Oh, and I want my samp to run from inside a zone, did I mention that?
My goal for this post is to go from a fresh OpenSolaris 2008.11 zone and to get this one-liner to work
- perl -e “use DBI;my \$dbh=DBI->connect(‘DBI:mysql:database=mysql’, ‘root’, ”);print ‘ping=’ . \$dbh->ping . qq{\n}”
Here is an overview
- Install OpenSolaris 2008.11.
- Create a zone, which I called tester3, since my first couple attempts didn’t go so hot
- Install some packages
- Start some services
- Install some perl packages
- Give it a go!
After 1 and 2, let’s see where we are. Just for kicks, let’s give our one-liner a shot. I get
-bash: perl: command not found
Turns out that the zones create in OpenSolaris are pretty dang bare, as per this article. In fact, many programs, like less and telnet, that I expected to have there, weren’t. Using this page, and this command
- pkg search -lr telnet
helped quite a bit. Looks like my zone starts with 54 packages. Sun’s Web Stack project provides an amp-dev package, so let’s install that and a couple other things for 3.
- pkg install sunstudioexpress SUNWperl584usr amp-dev
As per the article above, the packages get pulled down and all together those three packages look to be 585.31 megs, so it takes a minute or ten to get downloaded via my cable modem connection.
Once installed I try again and get
- Can’t locate DBI.pm in @INC (@INC contains: /usr/perl5/5.8.4/lib/i86pc-solaris-64int /usr/perl5/5.8.4/lib /usr/perl5/site_perl/5.8.4/i86pc-solaris-64int /usr/perl5/site_perl/5.8.4 /usr/perl5/site_perl /usr/perl5/vendor_perl/5.8.4/i86pc-solaris-64int /usr/perl5/vendor_perl/5.8.4 /usr/perl5/vendor_perl .) at -e line 1. BEGIN failed–compilation aborted at -e line 1.
DBD::mysql seems to install better with mysql up and running, so as per the Administering MySQL Server section of this page, we
- svccfg import /var/svc/manifest/application/database/mysql.xml
- svcadm enable application/database/mysql:version_50
The DBD::mysql tests want to run mysql_config, so we need to get that in the PATH
- export PATH=$PATH:/usr/mysql/5.0/bin
Now we’re ready to install DBI and DBD::mysql. The first time or two through I tried installing the SUNWpmdbi package, but it didn’t play well (perhaps because it is like a year old), so instead I do
- perl -MCPAN -e shell
- install Test::More DBI DBD::mysql
Perhaps a little too hard, but now, so, nice!
- root@tester3:~# perl -e “use DBI;my \$dbh=DBI->connect(‘DBI:mysql:database=mysql’, ‘root’, ”);print ‘ping=’ . \$dbh->ping . qq{\n}”
- ping=1
Time to try out mod_perl.
If any Sun or web stack folks are reading, including packages for DBD::mysql and a more modern DBI would be great 🙂 And maybe adding the mysql bin to the path?
Enjoy!
Earl
Thanks for the feedback and the posting. It always helps to have stuff like this for the search engines to index.
I’ll pass along the feedback on DBD and DBI. On the mysql stuff not being in the path by default, I think we didn’t deliver /usr/bin symlinks because we may at some point need to deliver MySQL 5.1 and 5.0, and they’re not going to be binary compatible necessarily. It’s good to know that there’s some software out there that expects it to be in the path by default.