1. 程式人生 > >Arch linux LXR 安裝過程

Arch linux LXR 安裝過程

conn mysql main password efault local username enc pass

參考網頁:

http://lxr.sourceforge.net/en/1-0-InstallSteps/1-0-install.php

我選擇的版本:2.2, 我自己的操作系統是arch linux


安裝必要環境:

perl:sudo pacman -S perl

ctags: sudo pacman -S ctags

MariaDB:sudo pacman -S mariadb

Apache httpd:

  安裝之後,需要先進行以下的配置:在啟動服務之前:

  # mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

  # sudo systemctl start mysqld

  設置密碼:‘/usr/bin/mysqladmin‘ -u root password ‘new-password‘ 或 ‘/usr/bin/mysqladmin‘ -u root -h <username> password ‘new-password

mod_perl:

  1、下載的地方:https://aur.archlinux.org/packages/mod_perl/ 在這裏下載git,https://aur.archlinux.org/mod_perl.git, 然後使用makepkg -sri。這裏會有一個unknown public key的錯誤,gpg --keyserver hkps://hkps.pool.sks-keyservers.net --search-keys AB34BA0040E92ECE (曾經有用),但我一般都是直接用--skippgpcheck。來進行安裝:makepkg -sri --skippgpcheck

  2、 然後還要根據頁面配置https://wiki.archlinux.org/index.php/Mod_perl#Installation

    我使用第一種方法:創建一個httpd-vhosts.conf的文件,然後填入

# /etc/httpd/conf/extra/httpd-vhosts.conf

<VirtualHost perlwebtest:80>

Servername perlwebtest
DocumentRoot /srv/http/perlwebtest
ErrorLog /var/log/httpd/perlwebtest-error.log
CustomLog /var/log/httpd/perlwebtest-access.log combined
<Directory /srv/http/perlwebtest> AddHandler perl-script .pl
PerlResponseHandler ModPerl::Registry
Options +ExecCGI
PerlOptions +ParseHeaders
AllowOverride All
Order allow,deny
Allow from all </Directory>

</VirtualHost>
    然後在配置文件當中進行包含:

Include conf/extra/httpd-vhosts.conf
    要確保配置文件沒有 這個選項:

Options Indexes FollowSymLinks
    把下面這一行添加到/etc/hosts

127.0.0.1 localhost yourhostname perlwebtest

Glimpse:http://webglimpse.net/download.php,

Perl database driver interface DBI and the relevant DBD driver for the database:

  sudo cpan install DBI::mysql

  sudo cpan install DBD::mysql

Perl File::MMagic :

  sudo cpan install File::MMagic

源碼下載:https://sourceforge.net/projects/lxr/?source=typ_redirect


到這裏, 第一部分,就基本完成了。後面還需要再次配置服務器。到那兒再繼續

其實無論是哪種系統,只要把這些依賴都安裝好,最後都是能夠使用的。




第二部分: 安裝LXR的源碼

  我是安裝在系統範圍內的,執行以下命令:

  參考命令:

$ cd /usr/local/share
$ tar -zxf ~/Download/lxr-x.y.z.tgz
  實際命令:

$ cd /usr/local/share
$ sudo tar -zxf ~/Downloads/LXR/lxr-2.2.1.tgz
sudo mv lxr-2.2.1/ lxr
sudo chown -R <username> lxr
  進入到目錄當中

cd /usr/local/share/lxr
  檢查當前的環境是否符合

$ ./genxref --checkonly





第三部分:

配置部分:配置部分,是最需要去看文檔的地方了。在這裏,我貼出我所有的選擇,如果想要快速的創建,可以按我的直接輸入,並且按我的文件名的安排來參考怎麽設置。

開啟配置的命令:

$ ./scripts/configure-lxr.pl -vv

* LXR configurator (version: 2.2) *

LXR root directory is /usr/local/share/lxr
Configuration will be stored in custom.d/
directory custom.d created
directory custom.d/db-scripts.d created

Configure for single/multiple trees? [S/m] > s
Do you intend to add other trees later? [yes/NO] > n

* LXR web server configuration *

Many different configurations are possible, they are related to the way
LXR service is accessed, i.e. to the structure of the URL.
Refer to the User‘s Manual for a description of the variants.

LXR can be located at the server-root (so called dedicated)
or lower in the server hierarchy (shared because there are
usually other pages or sections).
Server type? [dedicated/SHARED] > shared

The computer hosting the server is described by an URL.
The form is scheme://host_name:port
where:
- scheme is either http or https (http: can be omitted),
- host_name can be given as an IP address such as 123.45.67.89

or a domain name like localhost or lxr.url.example,

- port may be omitted if standard for the scheme.
--- Host name or IP? [//localhost] >
--- Alias name or IP? >
URL section name for LXR in your server? [/lxr] >

* LXR database configuration *

The choice of the database engine can make a difference in indexing performance,
but resource consumption is also an important factor.
* For a small personal project, try SQLite which do not

need a server and is free from configuration burden.

* For medium to large projects, choice is between MySQL,

PostgreSQL and Oracle.
Oracle is not a free software, its interface has not been
tested for a long time.

* PostgreSQL databases are smaller than MySQL‘s

and performance is roughly equivalent.

* MySQL is at its best with large-sized projects

(such as kernel cross-referencing) where it is fastest at the cost
of bigger databases.

* Take also in consideration the number of connected users.
Database engine? [MYSQL/oracle/postgres/sqlite] > mysql
--- Directory for glimpse databases? > /home/<username>/glimpse_DB

file .htaccess written into LXR root directory
file apache2-require.pl written into configuration directory
file apache-lxrserver.conf written into configuration directory
file lighttpd-lxrserver.conf written into configuration directory
file nginx-lxrserver.conf written into configuration directory
file thttpd-lxrserver.conf written into configuration directory
Mercurial support files written into configuration directory

* LXR master configuration file setup *

Global section part

*** Configuring auxiliary tool paths
*** Host name previously defined as http://localhost
*** Configuring HTML parameters
*** ‘Buttons-and-menus‘ interface is recommended for the kernel
*** to avoid screen cluttering.
--- Use ‘buttons-and-menus‘ instead of ‘link‘ interface? [YES/no] > y
*** Configuring file subsection
*** Configuring "common factors"
*** Marking tree section

* LXR master configuration file setup *

Tree section part
SQL script for database initialisation

*** Configuring LXR server parameters
*** The virtual root is the fixed URL part after the hostname.
*** You previously defined the virtual root as /lxr
--- Caption in page header? (e.g. Project XYZZY displayed by LXR) > Projec Read Source Code displayerd by LXR
Do you need a specific encoding for this tree ? [yes/NO] > n
*** Describing tree location
How is your tree stored? [FILES/cvs/git/svn/hg/bk] > F
*** A source directory contains one sub-directory for every version.
--- Source directory? (e.g. /home/myself/project-tree) > /home/<username>/Documents/SourceCode
Name to display for the path root? (e.g. Project or $v for version) [$v] >
*** Enumerating versions
Label for version selection menu? [Version] >
*** Versions can be explicitly enumerated, be read from a file or computed
*** by a function. The latter case is recommended for VCS-stored trees.
Version enumeration method? [LIST/file/function] >
--- Version name? > klib
--- Version name? (hit return to stop) > libevent-2.1.8
--- Version name? (hit return to stop) > linux-2.6.39
--- Version name? (hit return to stop) > linux-4.10.10
--- Version name? (hit return to stop) > memcached
--- Version name? (hit return to stop) > other1
--- Version name? (hit return to stop) > other2
--- Version name? (hit return to stop) >
*** By default, first version in list is displayed. You may also indicate
*** a prefered version.
--- Default displayed version is first in ‘range‘? [YES/no] > y
*** Setting directory lists
*** Some directories may contain non-public project data (binaries,
*** compilers caches, SCM control data, ...). They can be hidden from LXR.
--- Directory to ignore, e.g. CVSROOT or CVS? (hit return to stop) >
*** If your source code uses "include" statements (#include, require, ...)
*** LXR needs hints to resolve the destination file.
--- Include directory, e.g. /include? (hit return to stop) > /usr/include
--- Include directory, e.g. /include? (hit return to stop) > /usr/local/include
--- Include directory, e.g. /include? (hit return to stop) > /usr/lib/gcc/x86_64-pc-linux-gnu/6.3.1/include
--- Include directory, e.g. /include? (hit return to stop) >
*** Configuring data storage
--- Database name? > lxr_ReadSourceCode
--- DB user name? [lxr] >
--- DB password? [lxrpw] >
--- DB table prefix? [lxr_] >
創建數據庫

$ ./custom.d/initdb.sh
然後會顯示

Enter password:
*** MySQL - Creating tree user lxr
Enter password:
*** MySQL - Creating tree database lxr_ReadSourceCode
*** MySQL - Configuring tables lxr_ in database lxr_ReadSourceCode
復制配置到當前

$ cp custom.d/lxr.conf .





第三部分 漫長的索引開始

直接產生所有版本:

$ ./genxref --url=http://localhost/lxr --allversions
也可以只產生某個版本

$ ./genxref --url=http://localhost/lxr --version=v1

經過一晚上後,可以了。

顯示了這樣的一個信息:

*** other2 /tools/
--- other2 install_venv.py 1491296469-4352 82079 +++ 140/138
--- other2 normalize_json.py 1491296469-958 82080 +++ 28/10
--- other2 ryu-manager.spec 1491296469-715 82081 +++ 29/31
--- other2 topology_graphviz.py 1491296469-1021 82082 +++ 34/5
--- other2 with_venv.sh 1491296469-752 82083 +++ 22/8
*** other2 /
--- other2 run_tests.sh 1491296469-5040 82084 +++ 191/181
--- other2 setup.py 1491296469-956 82085 +++ 31/9

Summary for http://localhost/lxr == Version other2

Purge : 0:00:00
Free-text indexing : 0:00:00
Definitions parsing: 0:00:09
References parsing : 0:00:17
...Total duration..: 0:00:26

Database optimisation ... Done



第四個:配置服務器

在arch linux上的http的配置文件夾是/etc/httpd/conf (我的沒有最後面的d)

# cp custom.d/apache-lxrserver.conf /etc/httpd/conf
然後,在我的版本裏面,並沒有自動的包含這個文件,也不會自動的包含conf裏面的配置文件的語句,所以還需要自己包含這個配置文件

Include conf/apache-lxrserver.conf
需要重啟服務:

$ sudo systemctl restart httpd
第一次開啟,並不能夠成功啟動。使用status來進行查看,是沒有啟動成功,原因是Invalid command ‘PerlResponseHandler‘

嘗試去註釋了http.conf裏面的 Options Indexes FollowSymLinks

取消了註釋也沒問題

出現了FEATAL的問題,不能夠創建文件夾,有可能是因為/home/<user name>的文件夾中,設置的權限,因為這個文件夾,other是不能夠進行讀取的,需要添加權限後,就能夠訪問了

Arch linux LXR 安裝過程