apache suexec "command not in docroot"

Pol Hallen picture Pol Hallen · Sep 25, 2013 · Viewed 13.1k times · Source

Error message is:

command not in docroot (/home/site1/cgi-bin/test.pl).

Here I found this:

suexec requires the CGI script to be under the server's DocumentRoot (not the VirtualHost DocumentRoot). It is permitted, however, for the VirtualHost DocumentRoot to be a symlink to a directory that appears under the real DocumentRoot.

a part of virtual host config is:

[...]
DirectoryIndex index.html index.html index.php
DocumentRoot /home/site1/htdocs

SuexecUserGroup site1 site1

ScriptAlias /cgi-bin/ /home/site1/cgi-bin/
<Location /home/site1/cgi-bin>
           Options +ExecCGI
</Location>

<Directory /home/site1/>
Options -Includes -Indexes -FollowSymLinks +ExecCGI MultiViews
AddHandler cgi-script .cgi .pl
AllowOverride none
Order allow,deny
Allow from all
</Directory>
[...]

So, I prefer have Perl scripts inside cgi-bin, but if I can't resolve this problem I can move all scripts to htdocs.

Answer

Thraidh picture Thraidh · Sep 30, 2013

suEXEC has its own docroot which is totally independent of whatever you configure in your Apache config. You can see what suEXEC's docroot is by calling:

suexec -V

You may need to be root for that. In my case the docroot was /var/www. You'll have to put your scripts there. There is no way to change this save recompiling suEXEC. Don't try to use symbolic links to keep your scripts outside of /var/www (or whatever your suEXEC is configured to).

Edit: as mentioned by @insaner in the comments the command is probably suexec or as I have seen on at least one server suexec2. suEXEC is just what the Apache documentation calls the module/feature.