Apache2 访问Docker容器内的cgi脚本时出错,不允许操作:cand';t绑定unix域套接字

Apache2 访问Docker容器内的cgi脚本时出错,不允许操作:cand';t绑定unix域套接字,apache2,cgi,docker,Apache2,Cgi,Docker,我正在使用Apache::Test测试我正在编写的Apache处理程序。我的生成环境是一个Docker容器,由以下Dockerfile创建: 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

我正在使用Apache::Test测试我正在编写的Apache处理程序。我的生成环境是一个Docker容器,由以下Dockerfile创建:

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
Apache::Test不允许httpd服务器以root用户身份启动,并且我的容器以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
Test提供了一个名为t/Test的测试工具。我可以通过以下方式启动Apache服务器:

t/TEST -start-httpd
wget http://localhost:8529/index.html
我可以通过以下方式访问index.html页面:

t/TEST -start-httpd
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>
=====

修复了exec错误,因为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

我今天也有类似的问题。。使用有效的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>

#
#ScriptSock:在线程服务器上,指定到UNIX的路径
#用于与mod_cgid的CGI守护进程通信的套接字。
#
Scriptsock/usr/local/apache2/cgisock

通过移动ScriptSock位置取得了一些进展