感谢支持
我们一直在努力

在Fedora中安装lxr浏览内核源代码

转自:http://bbs.fedora-zh.org/showthread.php?1764-在fedora中安装lxr浏览内核源代码


说明:本文旨在在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文件,主要有两项:


代码:
# 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(文件根目录)的值。3.2执行”make install”


代码:
su
make install这会在上述INSTALLPREFIX目录安装相应的脚本和文件.


4.安装glimpse
进入解压后的文件夹,执行:


代码:
./configure
su
make install以下操作需要root权限:


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的内容就是所有的源代码的版本,如下:


代码:
linux-1.0
linux-2.4.0
linux-2.6.18.8defversion的内容如下:


代码:
linux-2.4.07.修改lxr的配置文件lxr.conf,先备份一下:


代码:
# cp lxr.conf lxr.conf.bak需要修改的有variable v, baseurl, htmlhead, htmltail, htmldir, sourceroot, srcrootname, dbdir和glimpsebin,如下(这里用到了前面建立的两个文件versions和defversion):


代码:
# 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/html/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.
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/8.创建lxr/http/.htaccess文件,即/var/www/html/lxr/http/.htaccess,


内容如下:

代码:
<Files ~ (search|source|ident|diff|find)$>
SetHandler cgi-script
</Files>9.修改/etc/httpd/conf/httpd.conf文件的lxr设置和ServerName设置
9.1在文件最后添加如下几行

代码:
# Cross Reference Stuff
<Directory /var/www/html/lxr>
Options All
AllowOverride All
</Directory>或者


代码:
<Directory /var/www/html/lxr>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>9.2修改vim /etc/httpd/conf/httpd.conf中ServerName为localhost:


代码:
ServerName localhost说明:原文件中可能把ServerName注释了,如果不修改则会在开启httpd的时候找不到ServerName而有如下相似的错误:


代码:
#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  ]10.建立lxr的数据文件
由于前面设置的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数据文件:


代码:
# 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*
(中间是分号)将这几个数据文件修改为任何人均可读可执行。11.启动Apache服务器.


代码:
# /etc/rc.d/init.d/httpd start
或者
# service httpd start12.完成,在浏览器中输入地址http://localhost/lxr/http/,点击source就可以浏览和查找不同版本的linux源代码了,或者直接http://localhost/lxr/http/source也可以,一样的效果。


13.如果开启了selinux,则可能会被selinux禁止,使用如下命令关闭selinux:


代码:
# setenforce 0
查看selinux状态:
# getenforce

赞(0) 打赏
转载请注明出处:服务器评测 » 在Fedora中安装lxr浏览内核源代码
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏