CGIWrap - Frequently Asked Questions

General Questions

How do I subscribe/unsubscribe from the CGIWrap mailing list?
To subscribe, send a note containing "subscribe" to

To unsubscribe, send a note containing "unsubscribe" to from the account that is subscribed to the list.

If you are unable to subscribe or unsubscribe, send a note to me at Please do not send subscribe/unsubscribe messages to the list.

More information on the mailing list is available here.

How do I send a message to the mailing list?
Any mail sent to will be sent to the mailing list, however, you have to be subscribed to the list. I will occasionally hand approve messages to the list if I see one from a non-subscriber, but you need to subscribe to the list.

What is on topic for the mailing list?
anything cgiwrap related
use of cgiwrap with ssi/cgi/various servers/tricks/etc
Discussion of any cgiwrap incompatibilities with other scripts, etc.
cgi security questions and issues related or not related to cgiwrap.
Anything else that comes up that is of interest to a large number of cgiwrap users.

Administrative Questions

I am getting the error about the server userid.
CGIwrap needs to be configured with the userid that your web server is running as. For apache based servers, this is the userid that is listed on the "User" line in httpd.conf. You specify this when configuring CGIWrap using the --with-httpd-user option.

I am getting the error "Can't ... ". How can I fix this?
CGIwrap needs to be installed set-uid to root. Log in as root, change to the server's cgi-bin directory, and issue the commands:
	chown root cgiwrap
	chmod 4755 cgiwrap

How do I use CGIwrap with server side includes
This is not supported by all web servers, but with Apache, use:
	<!--#include virtual="/cgi-bin/cgiwrap/user/script...."-->
One of the problems is that this often is a security hole unless you can enable server side exec/virtual include only of executables that are in ExecCGI capable directories. Some people have made patches that will allow this to work. Ask on the list for details.

I am getting the error "setgroups() failed!". What is wrong?
This occurs when CGIwrap is unable to set auxilliary groups. Auxilliary groups are groups that a user is a member of in /etc/group, that are not the user's primary group in /etc/passwd. Two things you can do here are to make sure CGIwrap is installed correctly (has to be setuid root to be able to set auxilliary groups.), or disable setting auxilliary groups. /net/bin/perl: fatal: /usr/lib/ can't map file: errno=12
This indicates that you installed cgiwrap with resource limiting (with rlimit support) but the limits are set too low. There isn't enough memory for perl to load. Keep in mind that unix applications usually use alot of virtual memory, even though their resident size is small.

How do I get PHP to work with cgiwrap
Here is an informal how-to I wrote after I set up cgiwrap and php recently. Much thanks goes to Nathan Nuelinger for the pointing out the decisive step of compiling with --enable-discard-path.

Download cgiwrap and set that up. I already had cgiwrap set up to wrap cgi scripts, but I did upgrade to the latest version. Get this working first with some simple cgi script tests. (BTW: Options you may find helpful include --with-cgi-dir and --with-httpd-user)

Download the latest version of php and configure it as a cgi binary, not as a module. Basically, if you run ./configure with no options, php will be compiled as a cgi binary. (To set it up as an apache module, which you don't want to do if you want to wrap your scripts, you have to explicitly say ./configure --with-apache.)

Before you compile php, however, and this is crucial, configure php with the option --enable-discard-path which allows you to move the php binary out of the web tree and into /usr/local/bin (which adds security), but more importantly it allows you to use php with cgiwrap properly.

To summarize, you need to run ./configure --enable-discard-path plus any other options you may desire, and place the php binary in /usr/local/bin.

Finally, you need the #!/usr/local/bin/php line at the very top of every php script you write. Then call the php script with cgiwrap exactly as you would call a cgi script. For example:

Let me know if you have any questions. Brian

User Questions

I am getting a 500 Server Error, how can I debug my script?
CGIwrap supports a debugging mode which can help to debug scripts. To use it, call CGIwrap via the URL http://.../cgiwrapd/... instead of http://.../cgiwrap/....

I am getting the error execv() failed
This generally results from either having the wrong path to perl, or having control-M's after the path to perl. This is usually a result of uploading the script in binary mode instead of ascii. You can fix this by re-uploading the script in ascii mode, or using vi/perl/etc. to get rid of the control-M's in the file.
For some situations, simply adding " -- " to the end of the first line of the script will cause the error to go away, sometimes not.

How do I use cgiwrapd on a Cobalt RaQ?
cgiwrapd is still there, it just isn't directly obvious how to use it. If you normally call your script as

you can call it as

to run it under cgiwrapd. Basically they ScriptAlias "cgiwrapDir" to the directory where cgiwrap is installed.

Chris Adams