Use lxr to view code in Linux

Source: Internet
Author: User
This is a previous configuration, but it is a bit forgotten, but in order not to forget it next time, record it for another time to waste searching on the network.

Lxr official explanation: lxr (formerly "the Linux cross referencer") is a software toolset for indexing and presenting source code repositories. lxr was initially targeted at the Linux source code, but has proved usable for a wide range of software projects. lxr. linux. no is currently running an experimental fork of the lxr software.
You can directly enter lxr In the IE block to enter the website. lxr was initially built to facilitate the viewing of the kernel source code. However, its applications are now quite common, it can be seen on many open source code websites outside China.

System: ubuntu7.10, dependent on apache1/2 (unlimited version), perl5, glimpse, genxref

Install Apache:

Sudo apt-Get install apache2 libapache2-mod-perl2
Sudo apt-Get install libcgi-simple-perl libcgi-Ajax-perl libhtml-parser-perl libtemplate-perl

Install lxr and glimpse:

Aptitude install lxr
Aptitude install glimpse


Similarly, genxref can be installed in Ubuntu software package management, or you can download the source code for installation.

Configure apache2:
Touch/etc/apache2/sites-available/lxr

CD/etc/apache2
Ln-s sites-available/lxr sites-enabled/lxr

VI sites-available/lxr
Enter the following content:

  1. # Linux cross reference stuff
  2. #/Usr/share/lxr is the home of lxr installed
  3. Alias/lxr/usr/share/lxr/
  4. <Directory "/usr/share/lxr">
  5. Options all
  6. AllowOverride all
  7. </Directory>

Configure lxr:

Touch/usr/share/lxr/HTTP/. htaccess

VI/usr/share/lxr/HTTP/. htaccess
Enter content

  1. <Files ~ = "" (Search | find | source | diff | ident) $ = "">
  2. Sethandler CGI-script
  3. </Files>

Now we can generate the code to be viewed. Because lxr supports symbolic links, we do not need to put the source code into the directory specified by lxr. We only need to create symbolic links for use, for example, if the directory of the source code file we want to view is/opt/source/linux-2.6.23, the source directory specified by lxr is/usr/share/lxr/sources, creating a symbolic link for the linux-2.6.23: ln-S/opt/source/linux-2.6.23/usr/share/lxr/sources/2.6.23

Create the versions and defversion file for viewing code in this directory. In versions, you can enter multiple file names. Each name occupies one row and corresponds to the source directory name in this directory, for me, you need to enter 2.6.23. defversion is the default lxr source code, which is also one of versions. Similarly, only 2.6.23 is entered here.

In addition, the directory used to create the data index file for lxr is considered as/usr/share/lxr/databases. the/usr/share/lxr/sources directory is used to generate the index information for 2.6.23:

Genxref 2.6.23

Glimpseindex-H. 2.6.23

To facilitate management, create a specified directory 2.6.23 in/usr/share/lxr/databases for 2.6.23 and move the generated index file to the directory:

MV fileidx xref ../databases/2.6.23/

MV *. glimpse * ../databases/2.6.23/

Chmod 777 ../databases/2.6.23 /*

Chmod 777 ../databases/2.6.23/. glimpse *

The above modification permission is for convenience, but for security, you can change it to the expected permission.

Finally, modify the lxr configuration file lxr. CONF file. If lxr is installed by default, that is, it is installed in the/usr/share/lxr directory, this file does not need to be modified. Otherwise, the configuration file is modified, the preceding versions, defversion, databases, and sources directories, as well as the file path information in the HTTP directory of lxr are simple. You can see it at a glance and will not explain it again.

Finally, start the Apache server:
/Etc/init. d/apache2 restart

View the code and enter it in the IE column.Http: // localhost/lxr/HTTP/blurb.html

Finally, if you cannot see the code and Apache logs indicate permission issues, check the file permissions, including source code permissions, then modify the settings so that Apache has the access permission.

Note: In fedora, the Apache configuration file is/etc/apache2/httpd. CONF file, put the above sites-available/lxr File Content in httpd. in the conf file; redhat9.0 is the same, but it may report a problem about a language module that cannot be found in Perl. You only need to find the RPM package of this module in rpmfind.net. After installation, you can use it.

Reference documents: http://www.orangespike.ca /? Q = node/77
(Page not found is always prompted when you click this document, but you can use it after refreshing it in the address bar. I don't know why)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.