2015-04-02 176 views
2

我正在使用Apache :: Test来测试我正在编写的Apache处理程序。我的编译环境是一个码头工人的容器,从这个Dockerfile创建:访问Docker容器内的cgi脚本时出错,操作不允许:无法绑定unix域套接字

FROM google/debian:wheezy 
RUN  apt-get -y install make gcc build-essential 
RUN  apt-get -y install sudo 
RUN  apt-get -y install apache2-threaded-dev 
RUN  apt-get -y install libapache2-mod-perl2 libgd-gd2-perl libgd-tools 
RUN  apt-get -y install libtest-harness-perl 
RUN  apt-get -y install libtap-formatter-junit-perl libjson-perl 

我打造的容器,并通过运行它:

docker run -i -t --rm -v $PWD:/opt/51d device-detection:latest /opt/51d/entry.sh 

阿帕奇::测试不允许的httpd服务器作为启动根和我的容器以root权限运行,所以entry.sh脚本创建一个用户为测试做使用:

#!/bin/bash 
adduser --disabled-password --gecos '' r 
adduser r sudo 
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers 
su -m r -c /opt/51d/build 

,并建立模样:

perl Makefile.PL && make && make test && sudo make install 

Apache :: Test提供了一个名为t/TEST的测试工具。我可以启动Apache服务器只是罚款:

t/TEST -start-httpd 

而且我可以访问index.html页面只是罚款:

wget http://localhost:8529/index.html 

然而,当我试图访问一个CGI脚本,我得到:

[Thu Apr 02 23:12:11 2015] [error] (1)Operation not permitted: Couldn't bind unix domain socket /opt/51d/CDK-51DegreesFilter/t/logs/cgisock.267 
[Thu Apr 02 23:12:11 2015] [notice] Apache/2.2.22 (Debian) mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations 
[Thu Apr 02 23:12:11 2015] [info] Server built: Dec 23 2014 22:48:32 
[Thu Apr 02 23:12:11 2015] [debug] worker.c(1757): AcceptMutex: sysvsem (default: sysvsem) 
[Thu Apr 02 23:12:11 2015] [crit] cgid daemon failed to initialize 
[Thu Apr 02 23:12:30 2015] [error] [client 127.0.0.1] (2)No such file or directory: unable to connect to cgi daemon after multiple tries: /opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi 

在/ opt/51D/CDK-51DegreesFilter /吨/ logs /目录是敞开:

ls -ld t/logs/ 
drwxrwxrwx 1 r staff 136 Apr 2 23:24 t/logs/ 

=====

通过移动ScriptSock目录

<IfModule mod_cgid.c> 
    ScriptSock /tmp/cgisock 
</IfModule> 

新的错误消息的位置,取得了一些进展:

[Sat Apr 04 04:04:23 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/lib/apache2/suexec) 
[Sat Apr 04 04:04:23 2015] [notice] Apache/2.2.22 (Debian) mod_perl/2.0.7 Perl/v5.14.2 configured -- resuming normal operations 
[Sat Apr 04 04:04:23 2015] [info] Server built: Dec 23 2014 22:48:32 
[Sat Apr 04 04:04:23 2015] [debug] worker.c(1757): AcceptMutex: sysvsem (default: sysvsem) 
[Sat Apr 04 04:04:49 2015] [error] (2)No such file or directory: exec of '/opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi' failed 
[Sat Apr 04 04:04:49 2015] [error] [client 127.0.0.1] Premature end of script headers: index.cgi 
[Sat Apr 04 04:06:14 2015] [error] (2)No such file or directory: exec of '/opt/51d/CDK-51DegreesFilter/t/cgi-bin/index.cgi' failed 
[Sat Apr 04 04:06:14 2015] [error] [client 127.0.0.1] Premature end of script headers: index.cgi 

=====

修复了执行错误,因为perl二进制文件的位置不同。更新和一切都很好。

t/TEST 
[warning] setting ulimit to allow core files ulimit -c unlimited; /usr/bin/perl /opt/51d/CDK-51DegreesFilter/t/TEST 
/usr/sbin/apache2 -d /opt/51d/CDK-51DegreesFilter/t -f /opt/51d/CDK-51DegreesFilter/t/conf/httpd.conf -D APACHE2 -D PERL_USEITHREADS 
using Apache/2.2.22 (worker MPM) 

waiting 60 seconds for server to start: .. 
waiting 60 seconds for server to start: ok (waited 1 secs) 
server localhost:8529 started 
t/CDK-51DegreesFilter.t .. ok 
All tests successful. 
Files=1, Tests=6, 0 wallclock secs (0.02 usr 0.02 sys + 0.34 cusr 0.08 csys = 0.46 CPU) 
Result: PASS 
[warning] server localhost:8529 shutdown 
[warning] port 8529 still in use... 
done 
+0

取得了一些进展,通过移动ScriptSock位置 – 2015-04-04 04:07:36

回答

0

我今天也有类似的问题..使用有效scriptsock解决了我的问题..

<IfModule cgid_module> 
     # 
     # ScriptSock: On threaded servers, designate the path to the UNIX 
     # socket used to communicate with the CGI daemon of mod_cgid. 
     # 
     Scriptsock /usr/local/apache2/cgisock 
    </IfModule> 
相关问题