Thursday, September 01, 2005

Console CSS

To make a nifty console area in your web pages, put this in your CSS:

div.console {
color: #0f0;
background: #000;
font-family: monospace;
font-weight: bold;
font-size: 10pt;
padding: 5px 5px 5px 5px;
margin-left: 1cm;
margin-right: 1cm;

}

Then, assign the console class to your div tags. The result looks like this:


This is text in the console class.

Apache 1.3 + Tomcat 5.x + Debian Woody

Apache is great. Tomcat is great. Having them work together is great. But trying to get them to work together under Debian Woody can be…shall we say challenging? The JK2 connector is the preferred way to have Apache and Tomcat communicate, but the only binaries for JK2 I could find were for Red Hat, and who wants that? So, it was time to build from source. There were a few gotchas along the way, and so I have written this article to help you avoid the problems, and get your webapps up and running under Woody quickly and easily.

This article assumes that you are using Debain Woody. Installation on other distributions will vary, but the general steps should be the same. You will need permission to install software on the system, and need to know how to start and stop processes.

Here are the steps. Each one will be covered in detail.

  1. Install Apache
  2. Install APXS
  3. Install a Java Development Kit
  4. Install Tomcat
  5. Download apr (Apache Portable Runtime) source
  6. Download apr-util source
  7. Download and build jk2 connector sources
  8. Configure Apache and Tomcat
  9. Start servers and test

Step 1: Install Apache

Installing Apache should be a breeze. As root, just apt-get apache. Or use dselect. Once Apache is installed, fire up your browser and point it at http://localhost. You should see a welcome page. Good job! On to Step 2.

Step 2: Install APXS

APXS is the APache eXtenSion tool. Installing this is also a breeze. As root, apt-get apache-dev. Or use dselect. See? Pretty easy so far. Step 3 coming up.

Step 3: Install Java Development Kit

If you have not already done this, go to Sun and get a Java SDK. You want the SDK (Software Development Kit), not the JRE (Java Runtime Environment). Make sure you get the Linux self-extracting file. I used version 1.4.2_06; it is available here. Detailed installation instructions are available.
For this example, I have installed the SDK in /usr/local, and my JAVA_HOME is /usr/local/j2sdk1.4.2_06.
Once you have the SDK installed, move on to Step 4.

Step 4: Install Tomcat

If you have not already done this, go to Tomcat’s Home Page, and download the Tomcat binaries. I used version 5.0.28.
Installing is just a matter of extracting the archive into a directory. For this example, I installed Tomcat in /usr/local.
Start Tomcat by running the startup script. For this example:

cd /usr/local/jakarta-tomcat-5.0.28/bin
./startup.sh

It is handy to fire up an xterm and watch the Tomcat logs:

tail -f /usr/local/jakarta-tomcat-5.0.28/logs/catalina.out

Test your Tomcat installation by pointing your web browser at http://localhost:8080. You should see the Tomcat welcome page.

Now that you have Apache and Tomcat working, you need to get them talking to each other. On to Step 5.

Step 5: Download the Apache Portable Runtime sources

Using JK2 with Apache 1.3 means that you need the APR (Apache Portable Runtime) source code. You don’t have to compile it – the JK2 build process will build APR for you.
Download the folllowing files from an Apache mirror.

apr-0.9.4.tar.gz
apr-util-0.9.4.tar.gz

The latest version available as of this writing is 1.0.0 – BUT – version 1.0.0 will not compile correctly with JK2 and Apache 1.3. I don’t know why, but I know that version 0.9.4 does work. So download 0.9.4. Or you are on your own.
Once you have the apr and apr-util source archives, extract them. You will need to know the full path to the source code when building JK2. In this example, the source archives were extracted in /usr/local, so the source code for apr is located at /usr/local/apr-0.9.4, and the source code for apr-util is located at /usr/local/apr-util-0.9.4.

Step 6: Download and Build JK2 Source

We’re getting closer. Download the JK2 source archive from the Jakarta Site Source Downloads page. The latest version at the time of this writing is 2.0.4.
Extract the archive, and change to the JK2 native directory:

tar zxf jakarta-tomcat-connectors-jk2-src-current.tar.gz
cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2

Run the configure script, specifying the location of apxs, apr, and apr-util:

./configure –with-apxs=/usr/bin/apxs –with-apr=/usr/local/apr-0.9.4 –with-apr-util=/usr/local/apr-util-0.9.4

Build the connector:

make

Now, you are ready to install the connector. But you should stop Apache and Tomcat first:

/etc/init.d/apache stop
/usr/local/jakarta-tomcat-5.0.28/bin/shutdown.sh
cd ../build/jk2/apache13
/usr/bin/apxs -n jk2 -i mod_jk2.so

JK2 is now built and installed. Move on to Step 7, and configure your servers to use it.

Step 7: Configure Apache and Tomcat

There are three files you need to worry about. The Apache configuration file, httpd.conf; the Tomcat configuration file, server.xml; and the JK2 configuration file, workers2.properties.

For Apache, the following line needs to be added to httpd.conf (located in /etc/apache by default on Debian):

LoadModule jk2_module /usr/lib/apache/1.3/mod_jk2.so

Now look at your Tomcat configuration file (server.xml), located in the conf directory of your Tomcat installation. The JK2/AJP 1.3 connector is defined in the default configuration file. Make sure it is still there. It should look something like this:

<!--– Define a Coyote/JK2 AJP 1.3 Connector on port 8009 –-->
<connector port="8009″ enableLookups=" false="" redirectport="8443″ debug=" 0="" protocol=""><br /></connector>

Now, the JK2 configuration file. Create a file called workers2.properties in the Apache configuration directory:

touch workers2.properties /etc/apache

Put the following lines in workers2.properties:

[channel.socket:localhost:8009]
port=8009
host=127.0.0.1
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
[uri:/jsp-examples/*]
worker=ajp13:localhost:8009

Step 8: Start Servers and Test

At this point, everything should be in place for Apache to serve the webapps that are configured in the workers2.properties file. So it is time to start the servers and test.

First, start Tomcat. You should see something like this in the Tomcat logs:

INFO: JK2: ajp13 listening on /0.0.0.0:8009
Nov 19, 2004 9:58:18 AM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=11/137 config=/usr/local/jakarta-tomcat-5.0.25/conf/jk2.properties

Now, start Apache.

And, the moment of truth has arrived. Point your browser at http://localhost/jsp-examples. You should get the Tomcat jsp example page, without having to specify the port.

You can now add more webapps to the workers2.properties file. Just add more [uri] sections, one for each webapp that you want Apache to serve.

Once you have Tomcat and Apache working together, you can start to make the configuration changes required for your environment. Everybody has different needs, and not all possible combinations can be addressed here. But you should now have a good place to start.

If you find errors in this documentation, please let me know.

Happy serving!

Debian Linux on the Dell Latitude X300

I recently acquired a Dell Latitude X300 to replace my ThinkPad A31, which was reassigned to sales duty. This is a brief summary of my experience installing Debian on this laptop. The information here was gathered from many sources (see References).
You can grab a copy of some of my kernel config files if you want. They can serve as a good starting point for rolling your own:

Version Date Description
2.4.28 01/09/2005 Basic configuration for the X300.
2.6.10 01/15/2005 Configuration with most stuff working. Includes custom DSDT, but no sleep/suspend stuff.
2.6.10 01/18/2005 Configuration including custom DSDT and Software Suspend 2 configuration.
2.6.11.7 05/02/2005 Configuration including custom DSDT and Software Suspend 2 configuration (version 2.1.8).

The specs on my X300 are:

  • Intel® Pentium® M processor 738 (1.40GHz)
  • 1152MB RAM (Maximum supported)
  • 60 GB HD (Maximum available)
  • Intel® pro 2200 wireless
  • DVD/CD-RW via external D-Bay
  • Integrated v.92 56K modem
  • Integrated 10/100 Ethernet

lspci output

BIOS Options

The only things that needed to be changed in the BIOS were the system time (set to UTC) and the boot options. I enabled boot from USB CD-ROM and USB HDD.

Partitioning

The laptop came with Windows XP Professional. The hard drive was partitioned as follows:

DELLUTILITY, type FAT, 39MB
Local Disk, Type NTFS, 56 GB, of which nearly 5GB was already used.

I booted the laptop, went through the Windows setup junk, and installed Partition Magic. I left the utility partition alone. That may be useful someday. The NTFS partition was then cut down to a more reasonable 10 gigs, which left me space to install Starcraft and Duke Nukem 3D, since that’s about all I use Windows for. That left me 42GB of unallocated space, just begging for Linux.

Installing Debian

I prefer Debian. The “sarge” version was running nicely on my ThinkPad, and I wanted to keep what I know.

I used the latest Debian installer, netinst rc2. Booting from the USB CD-ROM worked perfectly. I used the expert install, because I like to know what’s going on. The installer worked with no problems. I was pleasantly surprised. Hat’s off to the Debian installer team!

The hard drive was partitioned as follows:

Device Boot Start End Blocks Id System
/dev/hda1 1 5 40131 de Dell Utility
/dev/hda2 * 6 1280 10241437+ 7 HPFS/NTFS
/dev/hda3 7175 7296 979965 82 Linux swap
/dev/hda4 1281 7174 47343555 f W95 Ext’d (LBA)
/dev/hda5 * 1281 3104 14651217 83 Linux
/dev/hda6 3105 3469 2931831 83 Linux
/dev/hda7 3470 7174 29760381 83 Linux

I opted for manual package selection, and installed the following major packages to get X and gnome:
x-window-system
xfree86-driver-synaptics (more on this later)
gnome-desktop-environment
gdm

After the install finished, I had a dual-boot Debian/Windows system.

Configuring Linux

X Window System

Configuring X can be a trying experience. I am happy to report that it Just Worked on this laptop. The configuration that was generated during install worked just fine, with the exception of the special touchpad features.

The touchpad on this laptop is pretty fancy. It can be configured so that the side edge acts as a vertical scroll bar, and the bottom edge acts as a horizontal scroll bar. In addition, the surface can be tapped or double tapped for a left click (mouse button 1). It also support tapping with multiple fingers – not to be confused with a double-tap. A tap with one finger is equivalent to mouse button 1. A tap with two fingers is equivalent to mouse button 2. A tap with three fingers is equivalent to mouse button 3. This takes a little getting used to, but it works quite well. These extra features require the synaptics driver, which is packaged as xfree86-driver-synaptics in Debian. To enable the special features, edit your XFree86Config-4 file. The changes are show below, with the original section commented out:

#Section “InputDevice”
# Identifier “Configured Mouse”
# Driver “mouse”
# Option “CorePointer”
# Option “Device” “/dev/psaux”
# Option “Protocol” “PS/2″
# Option “Emulate3Buttons” “true”
# Option “ZAxisMapping” “4 5″
#EndSection
Section “InputDevice”
Identifier “Configured Mouse”
Driver “synaptics”
Option “CorePointer”
Option “Device” “/dev/psaux”
Option “Protocol” “auto-dev”
Option “Emulate3Buttons” “true”
Option “LeftEdge” “1700″
Option “RightEdge” “5300″
Option “TopEdge” “1700″
Option “BottomEdge” “4200″
Option “FingerLow” “25″
Option “FingerHigh” “30″
Option “MaxTapTime” “180″
Option “MaxTapMove” “220″
Option “VertScrollDelta” “100″
Option “MinSpeed” “0.06″
Option “MaxSpeed” “0.12″
Option “AccelFactor” “0.0010″
Option “SHMConfig” “on”
# Option “Repeater” “/dev/ps2mouse”
EndSection

DRI

X is using hardware accleration (DRI), as reported by glxinfo:

jeremyb@talisker:~$ glxinfo | grep dire
direct rendering: Yes

This is working under kernel 2.4.28 and 2.6.10.

ACPI

This laptop supports ACPI, but has a buggy DSDT (Differentiated System Description Table). To get ACPI working, you need to do a little work.
NOTE: It is recommended that you use a 2.6.x series kernel. The procedure described here to include a custom DSDT will not work on kernels lower than 2.6.9. There are ways to make it work, but they won’t be covered here, since I am using 2.6.10.

  1. Get the IASL compiler from Intel. Scroll down to find the download link for “ACPI-CA Unix Build Environment".
  2. Extract and build:
  3. tar zxf acpica-unix-20041203.tar.gz
    cd acpica-unix-20041203/compiler/
    make

    NOTE: If you are running Debian sarge, and you get errors compiling IASL, remove the flex package, and install the flex-old package instead.

  4. Reboot. Note the BIOS version (upper right of the screen)
  5. Go to the ACPI project page and download the DSDT for your BIOS. Make sure you get the DSDT that matches the version of your BIOS!
  6. Decompress the downloaded DSDT.
  7. Disassemble your existing DSDT, using the IASL
  8. # cat /proc/acpi/dsdt > dsdt.aml

    # iasl -d dsdt.aml
    Intel ACPI Component Architecture
    ASL Optimizing Compiler / AML Disassembler version 20041203 [Jan 10 2005]
    Copyright © 2000 - 2004 Intel Corporation
    Supports ACPI Specification Revision 2.0c
    Loading Acpi table from file dsdt.aml
    Acpi table [DSDT] successfully installed and loaded
    Pass 1 parse of [DSDT]
    Pass 2 parse of [DSDT]
    Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)
    ……………………………………………………………………………………………….
    ……………………………………………………………………………………………….
    …………………………………………………………………………………
    Parsing completed
    Disassembly completed, written to “dsdt.dsl”

  9. Find the memory used in the disassembled DSDT and the downloaded DSDT:
  10. # grep SystemMemory dsdt.dsl
    OperationRegion (MNVS, SystemMemory, 0x476EBD79, 0x40)
    OperationRegion (PHSD, SystemMemory, 0x476FBDBD, 0x0190)
    OperationRegion (VNVS, SystemMemory, 0x476EBDB9, 0x00010004)
    # grep SystemMemory Dell-Latitude_X300-A08-custom.asl
    OperationRegion (MNVS, SystemMemory, 0x276EBD79, 0x40)
    OperationRegion (PHSD, SystemMemory, 0x276FBDBD, 0x00000190)
    OperationRegion (VNVS, SystemMemory, 0x276EBDB9, 0x00010004)

    Notice that the memory in the disassembled DSDT is different from the memory in the downloaded DSDT. Edit the downloaded DSDT so that the memory values match the values in the disassembled DSDT.

  11. Compile the new DSDT
  12. # iasl -tc Dell-Latitude_X300-A08-custom.asl
    Intel ACPI Component Architecture
    ASL Optimizing Compiler / AML Disassembler version 20041203 [Jan 10 2005]
    Copyright © 2000 - 2004 Intel Corporation
    Supports ACPI Specification Revision 2.0c
    ASL Input: Dell-Latitude_X300-A08-custom.asl - 5490 lines, 189077 bytes, 2645 keywords
    AML Output: DSDT.aml - 21882 bytes 656 named objects 1989 executable opcodes
    Compilation complete. 0 Errors, 0 Warnings, 0 Remarks, 626 Optimizations
  13. Copy the compiled DSDT to your kernel source directory:
  14. # cp Dell-Latitude_X300-A08-custom.hex /usr/src/linux-2.6.10/my-dsdt.hex
  15. Configure your kernel to use the new DSDT. Enable the custom DSDT option under . Specify the path to the compiled DSDT (/usr/src/linux-2.6.10/my-dsdt.hex).
  16. Install your new kernel. Install the ACPI packages if you have not already (acpi and acpid on Debian). You should be able to query for acpi status now
  17. $ acpi -V
    Battery 1: charged, 100%
    Thermal 1: ok, 49.0 degrees C
    AC Adapter 1: on-line

Sleep/Suspend

Sleep is saving the state of the laptop to RAM. It should then power up quickly, leaving you where you left off. If you’ve ever used an Apple iMac/iBook/PowerBook, you know what I want.
Sleep requires enabling CONFIG_ACPI_SLEEP in your kernel config. You can then echo -n mem > /sys/power/state to suspend to RAM. And if you try this, your laptop will go to sleep, but it’s more like a coma.

Suspend is saving the state of the laptop to disk. It should then power up more quickly than from a cold boot, but not as quickly as from a sleep state. This requires enabling CONFIG_SOFTWARE_SUSPEND and CONFIG_PM_STD_PARTITION. You can then echo -n disk > /sys/power/state to suspend to disk. This works pretty well. I configured it to suspend when the lid is closed. I can then open it up, hit power, and it unsuspends. The only obvious problem so far is that the sound stops working after resume. Modules are all there, no errors in the logs, but no sound.

Software Suspend 2 is a kernel patch that adds additional functionality to the suspend/resume code. To get it, head over to the Software Suspend 2 home page, download the patch for your kernel, apply, configure, and compile. The directions on the page are easy to follow. The relevant part of my kernel config is:

#
# Software Suspend 2
#
CONFIG_SOFTWARE_SUSPEND2=y
CONFIG_SOFTWARE_SUSPEND2_BUILTIN=y
CONFIG_SOFTWARE_SUSPEND_SWAPWRITER=y
#
# Page Transformers
#
CONFIG_SOFTWARE_SUSPEND_LZF_COMPRESSION=y
#
# User Interface Options
#
CONFIG_SOFTWARE_SUSPEND_TEXT_MODE=y
#
# General Options
#
CONFIG_SOFTWARE_SUSPEND_DEFAULT_RESUME2="/dev/hda3″
# CONFIG_SOFTWARE_SUSPEND_KEEP_IMAGE is not set
CONFIG_SOFTWARE_SUSPEND_CHECK_RESUME_SAFE=y
#
# Debugging
#
CONFIG_SOFTWARE_SUSPEND_DEBUG=y
# CONFIG_SOFTWARE_SUSPEND_CHECKSUMS is not set

I also installed the hibernate script from sarge. The only change I had to make was to uncomment the SwitchToTextMode yes line in the file /etc/hibernate/hibernate.conf. I can now suspend to disk and resume gracefully. And sound works.
UPDATE:It appears that DRI does not recover gracefully. After a restore, programs that do 3D stuff (GL screensavers, glxgears) do not work. They will run, but there is no animation. Getting DRI back is simply a matter of logging out of Gnome. There is an option in /etc/hibernate/hibernate.comf called UseDummyXServer that is supposed to help the DRI drivers reinitialize when resuming, but this is not working for me.

Wireless

This laptop has the Intel Pro Wireless 2200 chipset. The driver can be found at http://ipw2200.sourceforge.net. Download the latest archive, untar, and read the INSTALL and README files. They have very good step-by-step instructions.

Once the modules are compiled and the firmware installed, you should be able to use the standard wireless tools to configure the interface.

Modem

Coming soon!

Ethernet

The ethernet adapter is supported by the tg3 driver. It works perfectly.

Sound

Works with the ALSA drivers.

This page will be updated as I have time to work with the laptop.

Palm OS Emulator (POSE) on Debian Sarge

I’ve been kicking around the idea of writing some Palm programs for a while. It’s an excuse to freshen up on my C programming skills. A lot of the necessary development tools are available as Debian packages on sarge, such as pilrc and prc-tools. The ROM’s, SDK, and emulator can be found on Palm’s developer site.

Getting prc-tools and pilrc installed and configured was pretty simple, since they are already packaged for sarge. But the emulator is a little trickier. It is not available as a package for Sarge, since it requires fltk 1.0, which is not available in Sarge.

This page documents how I got POSE running on Debian sarge.

Step One: Install Old GCC

The version of FLTK you need will not compile under gcc 3.3. So fire up aptitude and install the packages gcc-2.95 and g++-2.95.

For the next steps, you need to use gcc 2.95 rather than gcc 3.3. To do this, I adjusted the links. There’s probably a right way to do this, but this works for me:

$ su
# cd /usr/bin
# rm gcc
# ln -s gcc-2.95 gcc
# rm g++
# ln -s g++-2.95 g++

UPDATE:
Hello, thanks for your Info! But you can do the build-chain without the change of the gcc links. One of “The right way"s would be to use a command like the following one for configure the fltk and pose packages:
CC=gcc-2.95 CXX=g++-2.95 ./configure

Regards, Joachim.

Step Two: Install FLTK

Head over to www.fltk.org and download the source for version 1.0.11. I saved the source to /usr/local/src.

Now you can untar the FLTK source, and build it:

$ cd /usr/local/src
$ tar zxf fltk-1.0.11-source.tar.gz
$ cd fltk-1.0.11
$ ./configure
$ make
$ su
# make install

Now you have the correct version of FLTK installed at /usr/local. Cool.

Step Three: Compile POSE

You’ve already downloaded the POSE source from Palm, right? Good. So extract and build:

$ tar zxf emulator_src_3.5.tar.gz
$ cd Emulator_Src_3.5/BuildUnix
$ ./configure
$ make
$ su
# make install

Step Four: Fix GCC Links

Don’t forget this.

$ su
# cd /usr/bin
# rm gcc
# ln -s gcc-3.3 gcc
# rm g++
# ln -s g++-3.3 g++

That’s it. You should now be able to fire up pose and do your thing. I hope this document is helpful. If you find any glaring errors, let me know.

Friday, August 26, 2005

Moving on up...

I've moved my web site from a DSL connection to a real hosting service. I'm going to keep the blog portion of it here, for now.