LXR on CentOS
安裝CentOS 6.6
httpd 2.2
mysqld 5.1
mod_perl2.0.4
perl5.10
(1)啟動WebServer
#yum install httpd
#vi /etc/httpd/conf/httpd.conf
ServerName 192.168.1.x
#service httpd start
#chkconfig httpd on
#chkconfig
(2)安裝mysql
#yum install mysql
#yum install mysql-server
#service mysqld start
#chkconfig mysqld on
#mysql_secure_installation
(3)安裝所需要的套件
#yum install ctags
#yum install perl //通常安裝系統時會一起已安裝
#yum install cpan
#cpan App::cpanminus
#cpanm File::MMagic
#yum install mod_perl
#yum install perl-DBI //安裝mysql-server會一起安裝
#yum install perl-DBD-Mysql //安裝mysql-server會一起安裝
(4)安裝編譯環境
#yum install gcc
#yum install flex
#yum install flex-devel
(5)編譯glimpse
http://webglimpse.net/trial/glimpse-latest.tar.gz
# ./configure
# make install clean
(6)設定LXR
#cp lxr-2.0.3.tgz /var/www/html
#cd /var/www/html
#tar -zxvf lxr-2.0.3.tgz
#mv lxr-2.0.3 lxr
#./scripts/configure-lxr.pl -vv
[root@localhost lxr]# ./scripts/configure-lxr.pl -vv
Configure for single/multiple trees? [S/m] >
Do you intend to add other trees later? [yes/NO] >
Server type? [dedicated/SHARED] >
--- Host name or IP? [//localhost] >
--- Alias name or IP? > //192.168.1.7
--- Alias name or IP? >
URL section name for LXR in your server? [/lxr] >
Database engine? [MYSQL/oracle/postgres/sqlite] >
--- Directory for glimpse databases? > /var/www/html/glimpse
Is your Apache version 2.4 or higher? [YES/no] > no
--- Use 'buttons-and-menus' instead of 'link' interface? [YES/no] >
--- Caption in page header? (e.g. Project XYZZY displayed by LXR) > LXR
Do you need a specific encoding for this tree ? [yes/NO] >
How is your tree stored? [FILES/cvs/git/svn/hg/bk] >
--- Source directory? (e.g. /home/myself/project-tree) > /var/www/html
Name to display for the path root? (e.g. Project or $v for version) [$v] >
Label for version selection menu? [Version] >
Version enumeration method? [LIST/file/function] >
--- Version name? > slxr
--- Version name? (hit return to stop) >
--- Default displayed version is first in 'range'? [YES/no] >
--- Directory to ignore, e.g. CVSROOT or CVS? (hit return to stop) >
--- Include directory, e.g. /include? (hit return to stop) >
--- Database name? > lxr
--- DB user name? [lxr] >
--- DB password? [lxrpw] > mysql的使用者lxr密碼
--- DB table prefix? [lxr_] >
#service mysqld start
#chkconfig mysqld on
#chkconfig
(7)執行「./custom.d/initdb.sh」 建立資料庫與新增資料庫使用者lxr
若無法登入,請重新執行./scripts/configure-lxr.pl -vv,輸入正確mysql的使用者lxr密碼,重新產生initdb.sh再執行./custom.d/initdb.sh
(8)拷貝「lxr.conf」到上一層目錄
cp ./custom.d/lxr.conf /var/www/html/lxr
(9)使用ctags與glimpse產生索引
#./genxref --checkonly
#./genxref --url=http://192.168.1.7/lxr --versions=slxr
http://192.168.1.7/lxr為 網址,因為設定為SHARED,可以有多目錄
slxr為Version Name, 在 /var/www/html 下,將要進行顯示的程式碼放置於slxr資料夾下
執行「./genxref --url=http://192.168.1.7/lxr --versions=slxr」建立索引
以下為建立索引值螢幕顯示的畫面
This is glimpseindex version 4.18.5, 2006.
Indexing "/var/www/html/slxr" ...
Size of files being indexed = 1115614 B, Total #of files = 110
Index-directory: "/var/www/html/glimpse/lxr/slxr"
Glimpse-files created here:
-rw-r--r--. 1 root root 4785 2015-05-23 08:55 .glimpse_filenames
-rw-r--r--. 1 root root 440 2015-05-23 08:55 .glimpse_filenames_index
-rw-r--r--. 1 root root 0 2015-05-23 08:55 .glimpse_filetimes
-rw-------. 1 root root 102620 2015-05-23 08:55 .glimpse_index
-rw-r--r--. 1 root root 116 2015-05-23 08:55 .glimpse_messages
-rw-------. 1 root root 46058 2015-05-23 08:55 .glimpse_partitions
-rw-r--r--. 1 root root 396 2015-05-23 08:55 .glimpse_statistics
-rw-r--r--. 1 root root 262144 2015-05-23 08:55 .glimpse_turbo
*** slxr /custom.d/
--- slxr apache2-require.pl 1432299033-379 1 :: 0
--- slxr hg-lxr-ext.py 1432299033-2413 2 :: 8
--- slxr initdb.sh 1432299033-7142 3 :: 0
--- slxr lxr.conf 1432299033-6808 4 :: 0
--- slxr lxr.ctxt 1432299033-554 5 :: 0
*** slxr /lib/LXR/Files/
--- slxr BK.pm 1432299033-8306 6 :: 20
--- slxr CVS.pm 1432299033-23529 7 :: 20
--- slxr GIT.pm 1432299033-10286 8 :: 16
--- slxr Mercurial.pm 1432299033-9794 9 :: 16
--- slxr Plain.pm 1432299033-5227 10 :: 15
--- slxr Subversion.pm 1432299033-9874 11 :: 18
*** slxr /lib/LXR/Index/
--- slxr Mysql.pm 1432299033-5982 12 :: 4
--- slxr Oracle.pm 1432299033-2296 13 :: 2
--- slxr Postgres.pm 1432299033-6994 14 :: 4
--- slxr SQLite.pm 1432299033-4056 15 :: 4
...
(10)設定apache
#cp /custom.d/apache-lxrserver.conf /etc/httpd/conf.d/
#service httpd start
apache-lxrserver.conf如下
#
# LXR Apache server configuration
#
# $Id: apache-lxrserver.conf,v 1.9 2014/03/10 16:40:27 ajlittoz Exp $
#
#
# Cannot grant Apache 2.2/2.4 implicit compatibility because Require
# directive syntax and semantics changed between releases.
# When updating 2.2 -> 2.4, uncomment 2.4 specific lines
# =================================================
# ------- Port list -------
#
# (only if different from 80, 8080 or 443)
# NOTE: remove duplicate ports since they cause trouble
# and uncomment the remaining ones.
#@here_ports:
# The following directive is deprecated in 2.4 and becomes a no-op
NameVirtualHost *
# =================================================
#
# ------- LXR host name and aliases ------
#
<VirtualHost *>
DocumentRoot /var/www/html/lxr
ServerName localhost
ServerAlias 192.168.1.111
</VirtualHost>
#@here_hosts:
# =================================================
#
# ------- URL mapping to LXR directory ------
#
Alias /lxr "/var/www/html/lxr"
#@here_alias:
# =================================================
#
# ----------- Perl security checks -----------
#
# If these checks cause trouble (i.e. too many
# error or warning messages in Apache's error log),
# comment out the lines.
<IfDefine MODPERL2>
PerlSwitches -T
</IfDefine>
<IfDefine !MODPERL2>
PerlTaintCheck On
</IfDefine>
# =================================================
#
# ----------- LXR startup configuration -----------
#
# This is valid only for Apache 2.x
# Apache 1.x requires manual modification of Perl library.
# See LXR installation manual
# Apache 1.x requires manual modification of Perl library.
# See LXR installation manual
<IfModule mod_version.c>
# Assume Apache 2.x and above since mod_version appeared in 2.0
# This is safer than using <IfVersion> since this tag
# causes an error with 1.x
# However, when this configuration file is parsed,
# mod_perl may not yet be loaded; consequently, the older
# directive is used. Happily, it is still recognised by newer
# versions of mod_perl.
<IfDefine MODPERL2>
# ----------------> absolute path to the LXR root directory
PerlPostConfigRequire /var/www/html/lxr/custom.d/apache2-require.pl
</IfDefine>
<IfDefine !MODPERL2>
# ----------------> absolute path to the LXR root directory
PerlRequire /var/www/html/lxr/custom.d/apache2-require.pl
</IfDefine>
</IfModule>
# =================================================
#
# ----------- LXR directory access -----------
#
# ----------------> absolute path to the LXR root directory
<Directory "/var/www/html/lxr">
Options FollowSymLinks
AllowOverride AuthConfig FileInfo Limit Options
# Apache 2.2 access control
Order allow,deny
# up to Apache 2.2
Allow from all
# from Apache 2.4
# Require all granted
</Directory>
(11)關閉防火牆
#service iptables stop
# chkconfig iptables off
使用瀏覽器瀏覽