Ubuntu 10.10安装lxr3.0.1 

1安装 apache2: sudo apt-get install apache2

2安装 lxr, sudo apt-get install lxr

  3安装 glimpse

  1. wget http://cdnetworks-kr-2.dl.sourceforge.net/project/lxr/old/lxr-0.3.1/lxr-0.3.1.tar.gz 
  2. tar -xvzf glimpse-latest.tar.gz 
  3. cd glimpse-4.18.6 
  4. ./configure 
  5. make 
  6. sudo make install 

这里如果提示要安装flex,那就安装下,sudo apt-get install flex

4修改lxr.conf配置文件

如下:

 

  1. # Configuration file. 
  2.  
  3. # Define typed variable "v", read valueset from file. 
  4. variable: v, Version, [/usr/share/lxr/source/versions], [/usr/share/lxr/source/defversion] 
  5.  
  6. # Define typed variable "a".  First value is default. 
  7. variable: a, Architecture, (i386, alpha, m68k, mips, ppc, sparc, sparc64) 
  8.  
  9. # Define the base url for the LXR files. 
  10. # 服务器的地址,地址最后必须包括 " / ",默认安装则不需要修改 
  11. baseurl: http://localhost/lxr/http/ 
  12.  
  13. # These are the templates for the HTML heading, directory listing and 
  14. # footer, respectively. 
  15. # 显示网页的格式 
  16. htmlhead: /usr/share/lxr/http/template-head 
  17. htmltail: /usr/share/lxr/http/template-tail 
  18. htmldir:  /usr/share/lxr/http/template-dir 
  19.  
  20. # The source is here. 
  21. # 源码目录位置,$v代表当前source目录下的目录名,等会要mkdir 2.6.28 
  22. sourceroot: /usr/share/lxr/source/$v/ 
  23. srcrootname: $v 
  24.  
  25. # "#include <foo.h>" is mapped to this directory (in the LXR source 
  26. # tree) 
  27. incprefix: /include 
  28.  
  29. # The database files go here. 
  30. # 放置lxr数据库索引文件的目录,这个databases等会也要新建 
  31. dbdir: /usr/share/lxr/databases/$v/ 
  32.  
  33. # Glimpse can be found here. 
  34. # glimpse安装位置,用命令which glimpse可以查看 
  35. glimpsebin: /usr/local/bin/glimpse 
  36.  
  37. # The power of regexps.  This is pretty Linux-specific, but quite 
  38. # useful.  Tinker with it and see what it does.  (How's that for 
  39. # documentation?) 
  40. map: /include/asm[^\/]*/ /include/asm-$a/ 
  41. map: /arch/[^\/]+/ /arch/$a/ 

5在/usr/share/lxr目录下新建databases,这是根据lxr.conf配置里dbdir: /usr/share/lxr/databases/$v/做对应的,就是索引数据库文件夹。

  1. sudo mkdir databases 
  2. cd databases 
  3. 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 交叉索引数据库 )

 

  1. sudo glimpseindex -H . .  #这里尤其要注意两个"."号中间是有空格的,两个都表示当前目录,这个是该命令的格式 
  2. sudo genxref 
  3. sudo mv fileidx ../../databases/2.6.28/ 
  4. sudo mv xref ../../databases/2.6.28/ 
  5. sudo mv .g* ../../databases/2.6.28/ 
  6. chmod a+x ../../databases/2.6.28/* 
  7. 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里看交杈源码。