« | July 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | |
| 公告 |
|
Blog信息 |
blog名称:FoxWolf 日志总数:127 评论数量:246 留言数量:0 访问次数:849691 建立时间:2006年5月31日 |

| |
[Linux工具]LXR(Linux Cross Reference)安装配置心得 文章收藏, 网上资源, 软件技术, 电脑与网络
FoxWolf 发表于 2007/10/9 20:43:11 |
LXR的主页上是这样介绍自己的 A general purpose source code indexer and cross-referencer that provides web-based browsing of source code with links to the definition and usage of any identifier. Supports multiple languages. 对于需要阅读源代码的人来说,是一个非常有帮助的工具,所谓工欲善其事,必先利其器。从配置到成功花了我不少时间,主要是网上的配置方法写的太杂,很多已经过时了,对于现在的情况已经不再适用,所以还是决定自己写一篇东西出来,虽然我知道我写完了过一段时间也会过期,所以尽量写一些这样配置的原因,而不是单纯的步骤,授人以鱼,不如授人以渔。 网上有很多配置好LXR的网站,最有名的当然是http://lxr.linux.no 但是网络上的东西毕竟有其不可靠性。首先是网速没有保证,点一次刷新半天。其次,我们虽然大多数时间能连上网,但总会遇到这样那样的连接问题,说不定某一天它就被GFW和谐掉了,这样的事情太多了,所以还是放在本机的服务器比较保险。 我们配置的环境是在ubuntu 7.04下,当然主要看中的是其安装软件apt的方便性,ubuntu毫无疑问是当今各个linux发行版中最有人气也最好用的一个。 配置步骤:(1)安装lxr(版本为0.31,stable的版本),apache2,libapache2-mod-perl2,glimpse,perl 注:lxr 0.31版本是不需要有数据库支持的,所以MySQL和PostgreSQL是不需要的,而最新的0.9x的那些版本已经需要数据库支持了,我前面就是在数据库上花费了太多的时间,尤其是它不支持MySQL5,因为有release关键字的问题,非常ft。怎么安装我想ubuntu下大家都会,不用我多说了,apt一下或synaptic一下就可以了。(2)lxr的安装目录为 /usr/share/lxr/,我们把需要索引的源代码放到/usr/share/lxr/source/下,目录名字为版本号,如2.6.17,然后新建文件/usr/share/lxr/source/versions,文件中写入2.6.17。创建文件 /usr/share/lxr/source/defversion,意思为默认版本,我们写入2.6.17 注:我们可以放多个源代码目录在source目录下,名字可以任取,然后写入versions 即可。当然如果源码在其他路径下,也可以做一个软连接过来。(3)建立索引目录,新建目录/usr/share/lxr/databases,然后在databases目录下创建目录2.6.17(4)配置apache2,新建文件 /etc/apache2/sites-available/lxr,写入以下代码 Alias /lxr /usr/share/lxr <Directory /usr/share/lxr> Options All AllowOverride All </Directory> 注:这是让client访问apache2下http://localhost/linux时直接访问到/usr/share/lxr,以隐藏lxr的真实目录。 然后执行 guzhongshu@guzhongshu-laptop:~$sudo ln /etc/apache2/sites-available/lxr -s /etc/apache2/sites-enabled/lxr 创建文件/usr/share/lxr/http/.vtaccess (恩,这个应该是.htaccess),写入以下代码: <Files ~ (search|source|ident|diff|find)$> SetHandler cgi-script </Files> 注:这是为了让perl起作用,让apache2的mod_perl来执行http目录下的perl文件,而不是下载这个文件。(5)配置LXR,主要修改的文件是/usr/share/lxr/http/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. sourceroot: /usr/share/lxr/source/$v/ srcrootname: Linux # "#include <foo.h>" is mapped to this directory (in the LXR source # tree) incprefix: /include # The database files go here. dbdir: /usr/share/lxr/databases/$v/ # Glimpse can be found here. glimpsebin: /usr/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/注:大家应该根据自己的系统环境来进行配置lxr.conf(6) 生成数据文件guzhongshu@guzhongshu-laptop:~$ cd /usr/share/lxr/source/guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo genxref 2.6.17/ 长时间等待,因为要扫描文本处理guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo mv fileidx ../databases/2.6.17/ guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo mv xref ../databases/2.6.17/ 生成glimpse索引文件guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo glimpseindex -H . 2.6.17 guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo mv .g* ../databases/2.6.17 允许数据文件可访问guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo chmod +r ../databases/2.6.17/* guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ sudo chmod +r ../databases/2.6.17/.g*(7)重启apache2guzhongshu@guzhongshu-laptop:/usr/share/lxr/source$ /etc/init.d/apache2 restart访问网站http://localhost/lxr/blurb.html 以上经过测试会有一些问题。经过一些方法的尝试后来行了。但是就是不知道是怎么就行了?没有办法回到不行的状态。等过一段时间总结出问题再放出来。 |
|
回复:LXR(Linux Cross Reference)安装配置心得 文章收藏, 网上资源, 软件技术, 电脑与网络
落花(游客)发表评论于2011/9/29 16:08:56 |
你在本机直接发个超链接到桌面算了.还装一个http服务器.真是找麻烦啊... |
|
回复:LXR(Linux Cross Reference)安装配置心得 文章收藏, 网上资源, 软件技术, 电脑与网络
damocles(游客)发表评论于2008/5/26 17:15:07 |
zz居然都不写。。。。
以下为blog主人的回复:
guzhongshu |
|
回复:LXR(Linux Cross Reference)安装配置心得 文章收藏, 网上资源, 软件技术, 电脑与网络
zamia(游客)发表评论于2007/11/5 23:44:08 |
讲的很清楚,谢!里面你提到的问题:文件.vtaccess应该是.htaccess |
|
» 1 »
|