Howto setup lxr on Linux (Ubuntu Feisty)

The purpose of this post is to describe how to setup lxr for personal use on Linux – I use Ubuntu Feisty on my machine. Most of the commands need to be run as root, so you may want to do:
$ sudo bash
right at the beginning. Or you can prepend sudo to each command.

Setting up apache on Ubuntu Feisty.
# aptitude install apache
# /etc/init.d/apache start
Note: I don’t think I did any other settings really, but I had setup apache earlier – don’t remember now. I’m including it here for completeness. I am only accessing my webserver as localhost, and have not changed anything anywhere.

Setting up lxr on Ubuntu Feisty.
# aptitude install lxr

This gets lxr 0.3.1-4 – you need to have universe enabled in /etc/apt/sources.list. If you have enabled just now for the first time, then also execute ‘sudo aptitude update’ before installing lxr. And that ends the part about installing lxr. The compile-by-hand folks are just masochistic :).

Add the following lines to /etc/apache/httpd.conf at the end:
# Linux Cross Reference Stuff
Alias /lxr /usr/share/lxr
<Directory /usr/share/lxr>
Options All
AllowOverride All

Create a file /usr/share/lxr/http/.htaccess which contains:
<Files ~ (search|source|ident|diff|find)$>
SetHandler cgi-script

I now restart apache. Don’t know if this is essential, I guess reloading should be enough. But hey, this is my personal machine, no harm done :).
# /etc/init.d/apache restart

Since I only want to access the cross reference locally, I am not changing any settings in lxr.conf. At least, not yet. You can check /usr/share/doc/lxr/README.Debian.gz for more details.

Now we setup the cross reference.
1. Create /usr/share/lxr/source if it doesn’t exist.
2. Create a directory 2.6.22 inside it – this is the linux version I am cross referencing.
3. Untar the kernel source inside this directory in a subdirectory ‘linux’ .. i.e., you now have /usr/share/lxr/source/2.6.22/linux with the source in the linux directory.
4. Add a line with contents ‘2.6.22’ (without the single quotes) in /usr/share/lxr/source/versions
5. ln -s /usr/share/lxr/source/2.6.22 /usr/share/lxr/source/defversion
6. cd into /usr/share/lxr/source/2.6.22 and execute ‘genxref linux’
7. Make a cup of tea.
8. 10 minutes later (since you must never hurry a good cuppa) visit http://localhost/lxr/http/blurb.html
9. You’re done.

Note: I have not described how to setup the glimpse database, but that is documented in the lxr readme as well. You should read that anyway. Incidentally, generating the glimpse database would be step 8.a, just after the ‘genxref linux’.


15 thoughts on “Howto setup lxr on Linux (Ubuntu Feisty)

  1. apache 2 says:

    Not Found

    The requested URL /lxr/http/source/ was not found on this server.
    Apache/2.2.8 (Ubuntu) mod_perl/2.0.3 Perl/v5.8.8 Server at Port 80

  2. I just tried it out. I think maybe the apache config file should use ScriptAlias instead of Alias? Additionally, the directory should be own by the apache process owner, like say www-data?

  3. > The requested URL /lxr/http/source/ was not found on this server.
    I’ve never seen this. If someone finds a solution, let me know and I’ll update the post.

  4. Pingback: Browse the Linux Kernel Source with LXR |

  5. Great Post except !!!i used your post as reference and update to Ubuntu-10.04 on apache2 web server..Thanks a lot šŸ™‚

  6. Hi,

    I am new to apache web server, i have configured apache and lxr. It opens the welcome page (http://localhost/lxr/http/blurb.html)

    When i tried to search any kernel data structure i am getting an error.

    ** Fatal: Could not open “/usr/share/lxr/source/2.6.36//fileidx”

    please help me.

    Thanks and Regards,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s