访问Docker容器内的cgi脚本时出错,操作不允许:无法绑定unix域套接字

我正在使用Apache :: Test来testing我正在编写的Apache处理程序。 我的构build环境是从此Dockerfile创build的Docker容器:

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 

我构build容器并通过以下方式运行它:

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

Apache :: Test不允许httpd服务器以root身份启动,并且我的容器以root身份运行,因此entry.sh脚本会创build一个用户以供testing使用:

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

构build看起来像:

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

Apache :: Test提供了一个称为t / TEST的testing工具。 我可以通过以下方式启动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 / t / 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 

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

 <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>