Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to run a specific (perl) CGI script on my webserver. This works reasonable, but it would work immensely better if the CGI script would be running as the currently authenticated user.

Is there a way to do that, e.g. with a wrapper and sudo?

The virtualhost config is as follows:

    DocumentRoot /path/to/script
    <Directory /path/to/script>
            Options FollowSymLinks +ExecCGI
            AddHandler cgi-script .cgi

            AuthType Basic
            AuthName "Authenticate"

            # This authenticates against the local NIS
            PerlAuthenHandler Apache2::AuthenNIS
            PerlAuthzHandler Apache2::AuthzNIS
            PerlSetVar AllowAlternateAuth no

            Require valid-user
share|improve this question
up vote 0 down vote accepted

What exactly is preventing your app from running this way?

It's possible to do what you're asking, but it might be a better use of your time to configure an environment where your app can run as the same user which owns the httpd processes.

You're just introducing more complexity to your environment which makes it more difficult to debug, secure, and manage.

Anyway, to answer your question: look into suEXEC --

Echoing the documentation, you're almost always better off not doing things this way.

share|improve this answer
I'm slightly familiar with suEXEC, but how can I use it to run as the current authenticated user? – dtech Sep 17 '11 at 7:31
Marking as solved because suEXEC is probably the answer, just haven't had time for it yet. – dtech Oct 15 '11 at 9:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.