Ubuntu 10.10安装lxr3.0.1
1安装 apache2: sudo apt-get install apache2
2安装 lxr, sudo apt-get install lxr
3安装 glimpse
- wget http://cdnetworks-kr-2.dl.sourceforge.net/project/lxr/old/lxr-0.3.1/lxr-0.3.1.tar.gz
- tar -xvzf glimpse-latest.tar.gz
- cd glimpse-4.18.6
- ./configure
- make
- sudo make install
这里如果提示要安装flex,那就安装下,sudo apt-get install flex
4修改lxr.conf配置文件
如下:
- # Configuration file.
- # Define typed variable "v", read valueset from file.
- variable: v, Version, [/usr/share/lxr/source/versions], [/usr/share/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: /usr/share/lxr/http/template-head
- htmltail: /usr/share/lxr/http/template-tail
- htmldir: /usr/share/lxr/http/template-dir
- # The source is here.
- # 源码目录位置,$v代表当前source目录下的目录名,等会要mkdir 2.6.28
- sourceroot: /usr/share/lxr/source/$v/
- srcrootname: $v
- # "#include <foo.h>" is mapped to this directory (in the LXR source
- # tree)
- incprefix: /include
- # The database files go here.
- # 放置lxr数据库索引文件的目录,这个databases等会也要新建
- dbdir: /usr/share/lxr/databases/$v/
- # Glimpse can be found here.
- # glimpse安装位置,用命令which glimpse可以查看
- 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/
5在/usr/share/lxr目录下新建databases,这是根据lxr.conf配置里dbdir: /usr/share/lxr/databases/$v/做对应的,就是索引数据库文件夹。
- sudo mkdir databases
- cd databases
- sudo mkdir 2.6.28
6在/usr/share/lxr/source/目录下新建2.6.28目录,也是和sourceroot: /usr/share/lxr/source/$v/ 做对应的,$v在这就是2.6.28
sudo mkdir 2.6.28
然后,把您的kernel源代码(是好多直接的代码文件)放到这个2.6.28文件夹里。
最后还是在/usr/share/lxr/source下建立两个文件
/usr/share/lxr/source/versions,
/usr/share/lxr/source/defversion
很明显, versions 表示所有内核版本的集合, 而 defversion 表示缺省使用的版本。 我们目前使用 2.6.28 , 所以这两个文件里都写上 2.6.28
7 在/usr/share/lxr/source/2.6.28 下运行: ( 生成 freetext 交叉索引数据库 )
- sudo glimpseindex -H . . #这里尤其要注意两个"."号中间是有空格的,两个都表示当前目录,这个是该命令的格式
- sudo genxref
- sudo mv fileidx ../../databases/2.6.28/
- sudo mv xref ../../databases/2.6.28/
- sudo mv .g* ../../databases/2.6.28/
- chmod a+x ../../databases/2.6.28/*
- chmod a+x ../../databases/2.6.28/.*
8编辑, /etc/apache2/httpd.conf , 添加:
ServerName localhost #localhost与步骤2中的localhost对应,一般在本机查看就直接localhost
Alias /lxr /usr/share/lxr
<Directory /usr/share/lxr>
Options All
AllowOverride All
</Directory>
注: 如果不加ServerName localhost,可能导致下面的警告
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
9 重启 apache2:
sudo /etc/init.d/apache2 restart
10现在可以浏览代码了:
http://localhost/lxr/http/blurb.html
以上是结合网上,并经过自己数次实验成功的,感常见最主要还是配置文件lxr.conf里的配置参数要搞清楚,这样才能在任何linux里看交杈源码。