首先,克隆官方源码:
$ git clone git@github.com:free-electrons/elixir.git
elixir依赖:
Python >= 3.5
The Jinja2 and Pygments Python libraries
Berkeley DB (and its Python binding)
Exuberant Ctags
Perl (for non-greedy regexes)
安装python安装工具:
$ sudo apt-get install python3-setuptools
$ sudo easy_install3 pip
安装python依赖库
$ sudo pip3 install Jinja2
$ sudo pip3 install Pygments
搜索安装Berkeley DB:
$ apt-cache search libdb | grep Berkeley
$ sudo apt-get install libdb5.3-dev
安装Berkeley DB python模块
$ sudo pip install bsddb3
有3个命令:script.sh, update.py, query.py,要求两个环境变量如下:
1 | LXR_REPO_DIR=/work/elixir/openvpn/repo/ LXR_DATA_DIR=/work/elixir/openvpn/data/ ./update.py |
script.sh提供底层接口。
update.py生成数据库。
query.py查询信息。
注意,这3个命令不支持绝对路径,必须cd到仓库目录,执行。
apache2添加一个site
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | $ cat /etc/apache2/sites-enabled/001-elixir.conf Listen 8080 AddHandler cgi-script .py <Directory /work/git/elixir/http> Options ExecCGI Indexes FollowSymLinks AllowOverride all Require all granted SetEnv PYTHONIOENCODING utf-8 SetEnv LXR_PROJ_DIR /work/elixir </Directory> <VirtualHost *:8080> ServerName 127.0.0.1 ServerAdmin webmaster@localhost DocumentRoot /work/git/elixir/http ErrorLog ${APACHE_LOG_DIR}/error.log RewriteEngine on RewriteRule "^/$" "/linux/latest/source" [R] RewriteRule "^/.*/(source|ident|search)" "/web.py" [PT] </VirtualHost> |
其中LXR_PROJ_DIR指定一个存储仓库和数据库的目录,支持多个项目,该目录的结构为:
<LXR_PROJ_DIR>
<project 1>
data
repo
<project 2>
data
repo
<project 3>
data
repo
使用2中的命令创建数据库,开启apache2的cgi功能:a2enmod cgi
然后在浏览器访问即可:
参考:
https://github.com/free-electrons/elixir/blob/master/README.md