说明:本文旨在在fedora中安装lxr,此安装方法与fedora版本无关,本文在fedora 11中进行的安装,参考的是fedora 4/9等文章说明,成功。使用普通用户安装,过程中使用到su命令,lxr设置为可以同时查看多个版本源代码。
1.下载lxr-0.3
下载地址:http://sourceforge.net/projects/lxr/files/
说明:lxr的最新版使用的是PostgreSQL,麻烦,0.3则不需要数据库,方便。
2.下载glimpse
http://webglimpse.net/download.php
http://webglimpse.net/trial/glimpse-latest.tar.gz
3.安装lxr
3.1解压lxr,进入解压后的文件夹lxr-0.3,修改Makefile文件,主要有两项:
Code:
# The location of your perl5 binary
PERLBIN=/usr/bin/perl
这是perl的路径名,/usr/bin/perl是大多数情况下的默认配置,如果不同,请用whereis perl查找。
# LXR will be installed here
INSTALLPREFIX=/var/www/html/lxr
这是lxr脚本的安装目录,其中/var/www/html取自Apache配置文件/etc/httpd/conf/httpd.conf中的DocumentRoot(文件根目录)的值。
Code:
su
make install
4.安装glimpse
进入解压后的文件夹,执行:
Code:
./configure
su
make install
5.把源代码放在/var/www/html/lxr/source文件夹中
这里可以放多个,比如linux-1.0, linux-2.4.0, linux-2.6.18.8,其中linux-1.0.tar.bz2和linux-2.4.1.tar.bz2解压后的文件夹都是linux,请自行改名,原因后面说明。
6.在source中建立两个文件versions和defversion,其中versions为你的源代码版本(即你的目录),defversion为你的default version,即lxr默认展示的那个version。
versions的内容就是所有的源代码的版本,如下:
Code:
linux-1.0
linux-2.4.0
linux-2.6.18.8
Code:
linux-2.4.0
Code:
# cp lxr.conf lxr.conf.bak
Code:
# Configuration file.
# Define typed variable "v", read valueset from file.
variable: v, Version, [/var/www/html/lxr/source/versions], [/var/www/html/lxr/source/defversion]
# Define typed variable "a". First value is default.
variable: a, Architecture, (i386, alpha, m68k, mips, ppc, sparc, sparc64)
# Define the base url for the LXR files.
baseurl: http://localhost/lxr/http/
# These are the templates for the HTML heading, directory listing and
# footer, respectively.
htmlhead: /var/www/html/lxr/http/template-head
htmltail: /var/www/html/lxr/http/template-tail
htmldir: /var/www/html/lxr/http/template-dir
# The source is here.
sourceroot: /var/www/htl/lxr/source/$v/
srcrootname: $v
# "#include" is mapped to this directory (in the LXR source
# tree)
incprefix: /include
# The database files go here.
dbdir: /var/www/html/lxr/source/dbdir/$v/
# Glimpse can be found here.
glimpsebin: /usr/local/bin/glimpse
# The power of regexps. This is pretty Linux-specific, but quite
# useful. Tinker with it and see what it does. (How's that for
# documentation?)
map: /include/asm[^\/]*/ /include/asm-$a/
map: /arch/[^\/]+/ /arch/$a/
Code:
SetHandler cgi-script
9.1在文件最后添加如下几行
Code:
# Cross Reference Stuff
Options All
AllowOverride All
Code:
Options All
AllowOverride All
order allow,deny
allow from all
Code:
ServerName localhost
Code:
#service httpd start
Starting httpd: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
Starting httpd: [ OK ]
由于前面设置的dbdir为/var/www/html/lxr/source/dbdir/$v/,我们在lxr/source/dbdir/下面建立 linux-1.0, linux-2.4.0, linux-2.6.18.8等相关文件夹,以linux-1.0为例,进入lxr/source/dbdir/linux-1.0,然后生成lxr数据文件:
Code:
# cd /var/www/html/lxr/source/dbdir/linux-1.0
# /var/www/html/lxr/bin/genxref /var/www/html/lxr/source/linux-1.0/
生成fileidx和xref两个文件
# glimpseindex -H . /var/www/html/lxr/source/linux-1.0/
生成7个.glimpse_*文件
# chmod 755 *; chmod 755 .g*
(中间是分号)将这几个数据文件修改为任何人均可读可执行。
Code:
# /etc/rc.d/init.d/httpd start
或者
# service httpd start
13.如果开启了selinux,则可能会被selinux禁止,使用如下命令关闭selinux:
Code:
# setenforce 0
查看selinux状态:
# getenforce
Options All
AllowOverride All
order allow,deny
allow from all
即可。

没有评论:
发表评论