安装aria2c xmlrpc web客户端a2web » 荒野无灯weblog

Keep It Simple, Stupid.

荒野无灯weblog

安装aria2c xmlrpc web客户端a2web

我fork了原repo ,增加了README并对源码做了一点点修改。
http://ihacklog.github.com/a2web/

先安装其依赖的库:libfcgi 和 xmlrpc-c

安装libfcgi


[admin@huangye a2web]$ ls
a2web-v0.8/  clbr-a2web-v0.8-0-g4f817b2.tar.gz
[admin@huangye a2web]$ wget http://www.fastcgi.com/dist/fcgi.tar.gz
tar xvf fcgi.tar.gz 
[admin@huangye a2web]$ cd fcgi-2.4.0/
./configure
make
fcgio.cpp: In destructor 'virtual fcgi_streambuf::~fcgi_streambuf()':
fcgio.cpp:50:14: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::overflow(int)':
fcgio.cpp:70:72: error: 'EOF' was not declared in this scope
fcgio.cpp:75:14: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::sync()':
fcgio.cpp:86:18: error: 'EOF' was not declared in this scope
fcgio.cpp:87:41: error: 'EOF' was not declared in this scope
fcgio.cpp: In member function 'virtual int fcgi_streambuf::underflow()':
fcgio.cpp:107:35: error: 'EOF' was not declared in this scope
make[2]: *** [fcgio.lo] Error 1
make[2]: Leaving directory `/home/admin/build/a2web/fcgi-2.4.0/libfcgi'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/admin/build/a2web/fcgi-2.4.0'
make: *** [all] Error 2

这儿找到答案:

vim libfcgi/fcgio.cpp
加上#include 
make
[admin@huangye fcgi-2.4.0]$ sudo make install

好了,libfcgi 库安装成功。


安装xmlrpc-c 库

[admin@huangye fcgi-2.4.0]$ cd ../
[admin@huangye a2web]$ wget "http://downloads.sourceforge.net/project/xmlrpc-c/Xmlrpc-c%20Super%20Stable/1.16.40/xmlrpc-c-1.16.40.tgz?r=&ts=1333769149&use_mirror=softlayer" -Oxmlrpc-c-1.16.40.tgz
[admin@huangye a2web]$ cd xmlrpc-c-1.16.40
pacman -S --needed libxml2

[admin@huangye xmlrpc-c-1.16.40]$ cd lib/curl_transport/

修改 curlmulti.c
curltransaction.c
xmlrpc_curl_transport.c 这三个文件,注释掉 #include <curl/types.h>

make
sudo make install
cd tools
make
sudo make install
cd ../

再测试下:

[admin@huangye xmlrpc-c-1.16.40]$ cd examples/
make
[admin@huangye examples]$ ls
auth_client             xmlrpc_inetd_server
auth_client.c           xmlrpc_inetd_server.c
auth_client.o           xmlrpc_inetd_server.o
config.h                xmlrpc_loop_server
cpp/                    xmlrpc_loop_server.c
gen_sample_add_xml      xmlrpc_loop_server.o
gen_sample_add_xml.c    xmlrpc_sample_add_client
gen_sample_add_xml.o    xmlrpc_sample_add_client.c
interrupted_client      xmlrpc_sample_add_client.o
interrupted_client.c    xmlrpc_sample_add_server
interrupted_client.o    xmlrpc_sample_add_server.c
interrupted_server      xmlrpc_sample_add_server.cgi
interrupted_server.c    xmlrpc_sample_add_server_cgi.c
interrupted_server.o    xmlrpc_sample_add_server_cgi.o
Makefile                xmlrpc_sample_add_server.o
README                  xmlrpc_sample_add_server_w32httpsys.c
synch_client            xmlrpc_server_validatee
synch_client.c          xmlrpc_server_validatee.c
synch_client.o          xmlrpc_server_validatee.o
xmlrpc_amconfig.h       xmlrpc_socket_server
xmlrpc_asynch_client    xmlrpc_socket_server.c
xmlrpc_asynch_client.c  xmlrpc_socket_server.o
xmlrpc_asynch_client.o
[admin@huangye examples]$ ./xmlrpc_sample_add_server 8080&
[1] 1381
[admin@huangye examples]$ Running XML-RPC server...

[admin@huangye examples]$ ./xmlrpc_sample_add_client 
Making XMLRPC call to server url 'http://localhost:8080/RPC2' method 'sample.add' to request the sum of 5 and 7...
XML-RPC CALL:

\r\n
\r\n
sample.add\r\n
\r\n
5\r\n
7\r\n
\r\n
\r\n

XML-RPC CALL:

\r\n
\r\n
sample.add\r\n
\r\n
5\r\n
7\r\n
\r\n
\r\n

XML-RPC RESPONSE:

\r\n
\r\n
\r\n
12\r\n
\r\n
\r\n

XML-RPC RESPONSE:

\r\n
\r\n
\r\n
12\r\n
\r\n
\r\n

The sum is 12
[admin@huangye examples]$ 

测试表示,xmlrpc库已经正常工作了。


开始编译a2web-v0.8

[admin@huangye a2web]$ cd a2web-v0.8/
[admin@huangye a2web-v0.8]$ make
gcc -o a2web.cgi -Wl,-O1 -Wall -Wextra -lxmlrpc_client -lfcgi print.o config.o xml.o a2web.o misc.o query.o js.o
/usr/bin/ld: xml.o: undefined reference to symbol 'xmlrpc_array_append_item'
/usr/bin/ld: note: 'xmlrpc_array_append_item' is defined in DSO /usr/local/lib/libxmlrpc.so.3 so try adding it to the linker command line
/usr/local/lib/libxmlrpc.so.3: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status
make: *** [a2web.cgi] Error 1

[admin@huangye a2web-v0.8]$ gcc -o a2web.cgi -Wl,-O1 -Wall -Wextra -lxmlrpc -lxmlrpc_client -lfcgi print.o config.o xml.o a2web.o misc.o query.o js.o
/usr/bin/ld: /usr/local/lib/libxmlrpc.so: undefined reference to symbol 'xmlrpc_env_init'
/usr/bin/ld: note: 'xmlrpc_env_init' is defined in DSO /usr/local/lib/libxmlrpc_util.so.3 so try adding it to the linker command line
/usr/local/lib/libxmlrpc_util.so.3: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

还是不行。
再试:

gcc -o a2web.cgi -Wl,-O1 -Wall -Wextra -lxmlrpc_util -lxmlrpc -lxmlrpc_client -lfcgi print.o config.o xml.o a2web.o misc.o query.o js.o

好了,这下编译成功了。
运行试了下

[admin@huangye a2web-v0.8]$ ./a2web.cgi 
./a2web.cgi: error while loading shared libraries: libxmlrpc_util.so.3: cannot open shared object file: No such file or directory

报错,提示没有找到DSO 。。。
查看了下,文件是存在的:

[admin@huangye ld.so.conf.d]$ cd /usr/local/lib/
[admin@huangye lib]$ ls
deadbeef/                    libxmlrpc_packetsocket.so.4.16
fcitx/                       libxmlrpc_server.a
libchm.a                     libxmlrpc_server++.a
libchm.la                    libxmlrpc_server_abyss.a
libchm.so                    libxmlrpc_server_abyss++.a
libchm.so.0                  libxmlrpc_server_abyss.so
libchm.so.0.0.0              libxmlrpc_server_abyss++.so
libfcgi.a                    libxmlrpc_server_abyss.so.3
libfcgi++.a                  libxmlrpc_server_abyss.so.3.16
libfcgi.la                   libxmlrpc_server_abyss++.so.4
libfcgi++.la                 libxmlrpc_server_abyss++.so.4.16
libfcgi.so                   libxmlrpc_server_cgi.a
libfcgi++.so                 libxmlrpc_server_cgi++.a
libfcgi.so.0                 libxmlrpc_server_cgi.so
libfcgi++.so.0               libxmlrpc_server_cgi++.so
libfcgi.so.0.0.0             libxmlrpc_server_cgi.so.3
libfcgi++.so.0.0.0           libxmlrpc_server_cgi.so.3.16
libfcitx-config.a            libxmlrpc_server_cgi++.so.4
libfcitx-config.la           libxmlrpc_server_cgi++.so.4.16
libfcitx-config.so           libxmlrpc_server_pstream++.a
libfcitx-config.so.4         libxmlrpc_server_pstream++.so
libfcitx-config.so.4.0.0     libxmlrpc_server_pstream++.so.4
libfcitx-config.so.4.1       libxmlrpc_server_pstream++.so.4.16
libfcitx-core.so             libxmlrpc_server.so
libfcitx-core.so.0           libxmlrpc_server++.so
libfcitx-core.so.0.3         libxmlrpc_server.so.3
libfcitx-utils.so            libxmlrpc_server.so.3.16
libfcitx-utils.so.0          libxmlrpc_server++.so.4
libfcitx-utils.so.0.1        libxmlrpc_server++.so.4.16
libxmlrpc.a                  libxmlrpc.so
libxmlrpc++.a                libxmlrpc++.so
libxmlrpc_abyss.a            libxmlrpc.so.3
libxmlrpc_abyss.so           libxmlrpc.so.3.16
libxmlrpc_abyss.so.3         libxmlrpc++.so.4
libxmlrpc_abyss.so.3.16      libxmlrpc++.so.4.16
libxmlrpc_client.a           libxmlrpc_util.a
libxmlrpc_client++.a         libxmlrpc_util.so
libxmlrpc_client.so          libxmlrpc_util.so.3
libxmlrpc_client++.so        libxmlrpc_util.so.3.16
libxmlrpc_client.so.3        libxmlrpc_xmlparse.a
libxmlrpc_client.so.3.16     libxmlrpc_xmlparse.so
libxmlrpc_client++.so.4      libxmlrpc_xmlparse.so.3
libxmlrpc_client++.so.4.16   libxmlrpc_xmlparse.so.3.16
libxmlrpc_cpp.a              libxmlrpc_xmltok.a
libxmlrpc_cpp.so             libxmlrpc_xmltok.so
libxmlrpc_cpp.so.4           libxmlrpc_xmltok.so.3
libxmlrpc_cpp.so.4.16        libxmlrpc_xmltok.so.3.16
libxmlrpc_packetsocket.a     pkgconfig/
libxmlrpc_packetsocket.so    thunar-vfs-1/
libxmlrpc_packetsocket.so.4  wireshark/
[admin@huangye lib]$ 

看再下 a2web.cgi 的库依赖:

[admin@huangye a2web-v0.8]$ ldd a2web.cgi
    linux-gate.so.1 =>  (0xb774f000)
    libxmlrpc_util.so.3 => not found
    libxmlrpc.so.3 => not found
    libxmlrpc_client.so.3 => not found
    libfcgi.so.0 => not found
    libc.so.6 => /lib/libc.so.6 (0xb7585000)
    /lib/ld-linux.so.2 (0xb7750000)

发现有3个not found.
应该是archlinux默认没有把/usr/local/lib 加入 链接库的默认搜索路径的问题导致的。
解决办法可以是做个符号链接到 /usr/lib/目录下面,或者,用以下一劳永逸的方法:

cd /etc/ld.so.conf.d
sudo  vim usrlocal.conf 
[admin@huangye ld.so.conf.d]$ cat usrlocal.conf 
/usr/local/lib

[admin@huangye a2web-v0.8]$ ldconfig
ldconfig: Can't create temporary cache file /etc/ld.so.cache~: Permission denied
[admin@huangye a2web-v0.8]$ sudo ldconfig
Password: 

再检测下看:

[admin@huangye a2web-v0.8]$ ldd a2web.cgi
    linux-gate.so.1 =>  (0xb77a0000)
    libxmlrpc_util.so.3 => /usr/local/lib/libxmlrpc_util.so.3 (0xb7774000)
    libxmlrpc.so.3 => /usr/local/lib/libxmlrpc.so.3 (0xb7761000)
    libxmlrpc_client.so.3 => /usr/local/lib/libxmlrpc_client.so.3 (0xb7758000)
    libfcgi.so.0 => /usr/local/lib/libfcgi.so.0 (0xb774e000)
    libc.so.6 => /lib/libc.so.6 (0xb75ab000)
    libxmlrpc_xmlparse.so.3 => /usr/local/lib/libxmlrpc_xmlparse.so.3 (0xb759d000)
    libxmlrpc_xmltok.so.3 => /usr/local/lib/libxmlrpc_xmltok.so.3 (0xb7583000)
    libcurl.so.4 => /usr/lib/libcurl.so.4 (0xb7526000)
    libnsl.so.1 => /lib/libnsl.so.1 (0xb750d000)
    /lib/ld-linux.so.2 (0xb77a1000)
    libssh2.so.1 => /usr/lib/libssh2.so.1 (0xb74e3000)
    librt.so.1 => /lib/librt.so.1 (0xb74da000)
    libssl.so.1.0.0 => /usr/lib/libssl.so.1.0.0 (0xb7478000)
    libcrypto.so.1.0.0 => /usr/lib/libcrypto.so.1.0.0 (0xb72b2000)
    libz.so.1 => /usr/lib/libz.so.1 (0xb729b000)
    libpthread.so.0 => /lib/libpthread.so.0 (0xb7280000)
    libdl.so.2 => /lib/libdl.so.2 (0xb727a000)

好了,搞定。


下面是安装:

[root@huangye www]# cd cgi-bin/
[root@huangye cgi-bin]# mkdir a2web && cp /home/admin/build/a2web/a2web-v0.8/a2web.cgi a2web/
[root@huangye cgi-bin]# cd a2web/
[root@huangye a2web]# ls
a2web.cgi
[root@huangye a2web]# mkdir a2web
[root@huangye a2web]# cp /home/admin/build/a2web/a2web-v0.8/linefy.sh .
[root@huangye a2web]# cp -a /home/admin/build/a2web/a2web-v0.8/themes/* a2web/
[admin@huangye a2web-v0.8]$ sudo cp a2web.conf.sample /var/www/cgi-bin/a2web/a2web.conf

好了,现在访问http://huangye.com/cgi-bin/a2web/a2web.cgi 已经可以正常显示页面了。
但是发现style.css没有正确加载。
这里找到答案:
change it from “ScriptAlias” to just plain “Alias”
hank you very much .. that solved the problem.
把cgi-bin 配置帖了下吧:



    Alias /cgi-bin/ "/var/www/cgi-bin/"



    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock /var/run/httpd/cgisock



    AllowOverride None
    Options +ExecCGI
    Order allow,deny
    Allow from all


开启 aria2c xmlrpc interface :

aria2c --enable-rpc

Have fun!


相关文档wiki:
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html#AEN49
why is /usr/local/lib not in ld.so.conf?
https://github.com/clbr/a2web/blob/master/INSTALL
http://sourceforge.net/apps/trac/aria2/wiki/XmlrpcInterface
libfcig 下载:
http://www.fastcgi.com/drupal/node/5
其实还有一个基于PHP的web client: aria2web http://sourceforge.net/projects/aria2web/

Tagged in : xmlrpc,aria2c,web客户端,a2web

All Comments (0)
Gravatar image
No Comments