Contributed tip
Special thanks to kernelony who offered to share his experience. I just formatted his guide to make it look like the rest of the site.

ajlittoz

This is a naive, step by step guide to installing LXR on a Centos 6.3 machine. This is only a recommendation, it might not fit your needs and might contain inaccuracies but it worked for me - I have indexed the linux kernel. I used ' ' to signify a command to be entered to the shell, for example 'ls -a'. Please also go over the LXR User's Manual in their site (for version 1.0 and above), as it provides many insights too.

Installing a blank Linux machine

Download CentOS-6.3-x86_64-bin-DVD1.iso from http://mirrors.usc.edu/pub/linux/distributions/centos/6.3/isos/x86_64/ .

In VMware, create a new virtual machine with enough computing power (let's say 4 cores, 4GB of RAM). One network interface should suffice.

Power on the machine and boot it from this ISO. You will be asked several questions throughout the installation process:

should test HW? > You can skip this one. storage devices > Choose basic. disk partitioning > Choose use all space type of machine to be used > Choose web server, as we are going to need the Apache web server (LXR is accessed via web).

For networking, you must decide between dynamic IP (DHCP) or static IP.

To apply your changes, do: $ service network restart

At this point, YUM should be working, so we can start installing stuff.

Installing prerequisites

Installing LXR - version 2.0.3

I've tried both versions 0.11 and 2.0.3. I recommend 2.0.3 because it has less problems. ajlittoz's remark (March 2016): kernelony wrote this tip in September 2015. Since then, new LXR versions have been released and his comment still holds for the latest version which tries to improve on the previous one.

Download the LXR tarball, version 2.0.3 - lxr-2.0.3.tgz from SourceForge.

Copy it to /root/downloads.

ajlittoz's remark: kernelony implicitly seems to have logged in under root, which is not recommended for your system integrity. It is much better to su or sudo only for the commands that really deserve it.

Go to /usr/local/share

$ cd /usr/local/share

Untar it:

$ tar -zxf /root/downloads/lxr-2.0.3.tgz

Change the name of the extracted directory to lxr

$ mv lxr-2.0.3 lxr

Now enter lxr directory to begin configuration

$ cd lxr $ ./genxref --checkonly

genxref is the script which is responsible for cross referencing the source code. Full operation of it will be possible only when the DB is ready and LXR is configured. --checkonly flag will allow you to make sure all prerequisites are installed.

Configuring LXR means to edit file /usr/local/share/lxr/custom.d/lxr.conf. This file includes important data which teaches LXR about our environment:

Inside the LXR directory, do:

$ ./scripts/configure-lxr.pl -vv

A wizard will open and ask you questions and in the end it will edit the lxr.conf file for you. This is how I answered the questions:

Configure for single/multiple trees? [S/m] > S Do you intend to add other trees later? [yes/NO] > NO Server type? [dedicated/SHARED] > dedicated I was using the server only for LXR, so I wanted it to be the main directory. This means I can browse using http://the.IP/source instead of http://the.IP/lxr/source --- Host name or IP? [//localhost] > --- Alias name or IP? > put here your IP, for example //10.100.46.75 Database engine? [MYSQL/oracle/postgres/sqlite] > MYSQL --- Directory for glimpse databases? > /usr/local/share/glimpse_databases That's where the indexing output is stored! --- Use 'buttons-and-menus' instead of 'link' interface? [YES/no] > no A matter of taste, changes the display a bit --- Caption in page header? (e.g. Project XYZZY displayed by LXR) > give a title here (e.g. 'my LXR tree') Do you need a specific encoding for this tree ? [yes/NO] > NO How is your tree stored? [FILES/cvs/git/svn/hg/bk] > FILES --- Source directory? (e.g. /home/myself/project-tree) > /usr/local/share/source_code/ This is where you put the source code. Important note about that - you need to create subdirectories to this directory (one for each version) and inside them put the actual code. In other words, put the code for version1 inside /usr/local/share/source_code/version1 Name to display for the path root? (e.g. Project or $v for version) [$v] > Just hit 'enter' Label for version selection menu? [Version] > Just hit 'enter' Version enumeration method? [LIST/file/function] > LIST --- Version name? > This one's important. If you created a subdirectory inside the source code directory (e.g. version1), you need to enter it here. --- Default displayed version is first in 'range'? [YES/no] > YES --- Directory to ignore, e.g. CVSROOT or CVS? (hit return to stop) > Just hit 'enter' --- Include directory, e.g. /include? (hit return to stop) > Just hit 'enter' --- Database name? > lxr_myproject --- DB user name? [lxr] > Just hit 'enter' --- DB password? [lxrpw] > Just hit 'enter' --- DB table prefix? [lxr_] > Just hit 'enter'

The wizard will now create three important files inside /usr/local/share/lxr/custom.d and exit:

Create the DB:

$ service mysqld start $ ./custom.d/initdb.sh It will ask for a password - just hit enter (MySQL has an empty password in default state)

Copy the configuration file to its destination:

$ cp /usr/local/share/lxr/custom.d/lxr.conf /usr/local/share/lxr

Now actually create the directories you have specified to the wizard:

Run the indexing script:

$ ./genxref --url=http://localhost/ --version=version1 --checkonly This will do some basic checks

Now repeat it without the --checkonly flag:

$ ./genxref --url=http://localhost/ --version=version1 This script does the following:

You can index all versions at once with:

$ ./genxref --url=http://localhost/ --allversions This can take a while if the source code is big.

Get Apache to work

A few words regarding the Apache web server:

First, copy the Apache configuration file to its expected location:

$ cp /usr/local/share/lxr/custom.d/apache-lxrserver.conf /etc/httpd/conf.d/

Then, edit the httpd configuration file /etc/httpd/conf/httpd.conf with your favorite editor. You need to add there the line (anywhere you want) ServerName 127.0.0.1. If you don't do that, it will give you something like starting httpd: apr_sockaddr_info_get() failed when you try to start the httpd service.

Disable iptables (firewall), so that you can browse to the server from a remote PC:

$ service iptables stop $ chkconfig iptables off # for next time ajlittoz's remark: I do not recommend fully disabling iptables this way. It is better, security-wise, to write an additional iptables rule to control who can access the computer from the network and/or use custom Deny and Allow directives in apache-lxrserver.conf.

Now:

$ service httpd start

Go to the browser and browse to http://<your_LXR_server_IP>/source. This will launch the source script (residing in the lxr directory) responsible for displaying the page. You should see the source code and be able to navigate it, do identifier search, etc.

If you have an error like The directory / doesn't exist, it means that Apache cannot access the source_code directory - so try to put it somewhere else and repeat the process (the paths I've mentioned here should work though).

Adding new code/changing existing code

If you modify or update the source code (say, of version1), you need to index version1 again. Just run again:

$ ./genxref --url=http://localhost/ --version=version1

If you want to add more code/versions, do the following - say you want to add version2:

  1. Create a new dir inside your source code directory - e.g. /usr/local/share/source_code/version2
  2. Edit /usr/local/share/lxr/lxr.conf - look for 'range' - you should find somehing like this , 'range' => [qw(version1)] Change it to , 'range' => [qw(version1 version2)] ajlittoz's remark: I'd rather recommend to edit custom.d/lxr.conf and then to copy the edited file in order to avoid discrepancies between the wizard-generated file and the active file. Now run $ ./genxref --url=http://localhost/ --version=version2

When you browse to LXR you'll see this new version and can navigate/search in it.

By editing /usr/local/share/lxr/lxr.conf you can also modify the source code dir (called 'sourceroot' in lxr.conf) and the glimpse databases dir (called 'glimpsedirbase' in lxr.conf)