How do I get cgi script to run?

37 posts / 0 new
Last post
#1 Sun, 09/16/2007 - 08:21
MikeM

How do I get cgi script to run?

I have a cgi script for my autoresponder in cgi-bin/fump/install.cgi I have set all permissions as per developer, but when I run the script, I get a blank page and the script does nothing. I am testing virtualmin gpl, but just can't seem to get this to work.

It works on my cpanel domains, so I know it isn't the script. I've probably missed a setting somewhere.

Any help is greatly appreciated.

Thanks.

Mike Murphy

Mon, 09/17/2007 - 04:03
MikeM

Here's a bit more info from the Apache log:

[Sun Sep 16 15:23:50 2007] [error] [client 207.47.130.132] Premature end of script headers: autoinstall.cgi
[Sun Sep 16 15:23:51 2007] [error] [client 207.47.130.132] suexec policy violation: see suexec log for more details

I don't know where the suexec log is. Can I turn suexec off?

Mon, 09/17/2007 - 07:46 (Reply to #2)
Joe
Joe's picture

You don't have an Apache that's built correctly for Virtualmin (suexec docroot needs to be set to /home). If you're on one of the supported platforms for the Virtualmin GPL installer (which I recommend using, when possible, as it automates away all of the common problems like this).

Yes, you can disable suexec, but I don't recommend it. Probably better to get your Apache built right. Let me know what OS and version you're running and I'll give you some pointers (either where to download our packages, or how to rebuild yours).

But if you do want to disable SuExec, go to the "Website options" for the virtual server in question in the Server Configuration menu (assuming you're using the Virtualmin Framed Theme). First option is labeled "Run CGI scripts as domain owner?" Set it to no and save it.

For future virtual servers, you'll want to turn it off in the Server Template(s) that you use in the "Apache website" section. Option is labeled "Automatically add appropriate SuExec directive?"

But, again, I don't recommend it. It this is a shared server, it's somewhat hazardous to not use suexec for everything.

--

Check out the forum guidelines!

Mon, 09/17/2007 - 09:42 (Reply to #3)
MikeM

Hi Joe. Actually the box was a brand new fresh install of Debian 4, which should be a supported operating system for the gpl version (if I understood it correctly).

It is my own server and at this point will only run a few of my domains. I didn't have any plans of doing hosting for others, but you never know where life leads you. :-) I did a basic install and then let virtualmin gpl do it's thing. I haven't touched anything after it set itself up, except to set up my domain.

Thanks.

Mike Murphy

Mon, 09/17/2007 - 09:56 (Reply to #4)
Joe
Joe's picture

Hey Mike,

Cool. So did you actually use the install.sh for Virtualmin GPL? It should have setup the right apache for you. If it didn't, I've got something to fix in the installer.

Anyway, since you're using Debian 4.0, you can hook into our Debian repository, and use our Apache build (identical to the Debian build, except for being built with suexec docroot set to /home). The path for sources.list is:

deb http://software.virtualmin.com/gpl/debian/ virtualmin-etch main

Or you could use our install.sh and it will not only setup the sources for you, it'll configure everything correctly for Virtualmin use. (install.sh sometimes gets confused if you've already setup some stuff, though...)

--

Check out the forum guidelines!

Mon, 09/17/2007 - 10:05 (Reply to #5)
MikeM

Yes, I did a fresh install of Debian, changed my network settings, ran echo server1.example.com > /etc/hostname, rebooted, commented out the cd for updates, ran apt-get update, ran apt-get upgrade, and then I used wget http://software.virtualmin.com/gpl/scripts/install.sh to get the software and then I used /bin/sh install.sh to install it.

I sort of followed the perfect Debian setup from howtoforge, until it came time to install software, which I did not do.

Other problem was no mailman list, so I ran newlist mailman. Once the website was up, I ran the check configuration and it said everything was good.

Mon, 09/17/2007 - 10:13 (Reply to #6)
Joe
Joe's picture

Oh, OK. So the install, for some reason didn't replace your apache.

Try updating it:

apt-get update
apt-get install apache2

And see if it actually installs our version. You can check by running suexec2 from the command line with the -V option. You're looking to see "/home" in the DOCROOT field.

--

Check out the forum guidelines!

Mon, 09/17/2007 - 10:22 (Reply to #7)
MikeM

Here is the result of the suexec -V and installing apache2. Oh and the "deb http://software.virtualmin.com/gpl/debian/ virtualmin-etch main" was already in the sources.list file.

ns1:~# suexec -V
-bash: suexec: command not found
ns1:~# apt-get install apache2
Reading package lists... Done
Building dependency tree... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.

Since you only requested a single operation it is extremely likely that
the package is simply not installable and a bug report against
that package should be filed.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
apache2: Depends: apache2-mpm-worker (>= 2.2.3-50) but it is not going to be installed or
apache2-mpm-prefork (>= 2.2.3-50) but 2.2.3-4+etch1 is to be installed or
apache2-mpm-event (>= 2.2.3-50) but it is not going to be installed
E: Broken packages

Mon, 09/17/2007 - 10:24 (Reply to #8)
MikeM

OOPs wrong suexec command, but same results:

ns1:~# suexec2 -V
-bash: suexec2: command not found

Mon, 09/17/2007 - 10:26 (Reply to #9)
MikeM

I also don't mind paying for the pro version if that will fix the problems with cgi and email. I just wanted to make sure it worked before investing. :-)

Mon, 09/17/2007 - 10:31 (Reply to #10)
Joe
Joe's picture

<div class='quote'>ns1:~# suexec2 -V
-bash: suexec2: command not found</div>

Right. Debian hides it in /usr/lib/apache2, or somewhere...it's not in the path.

--

Check out the forum guidelines!

Mon, 09/17/2007 - 10:33 (Reply to #11)
Joe
Joe's picture

<div class='quote'>The following packages have unmet dependencies:
apache2: Depends: apache2-mpm-worker (&gt;= 2.2.3-50) but it is not going to be installed or
apache2-mpm-prefork (&gt;= 2.2.3-50) but 2.2.3-4+etch1 is to be installed or
apache2-mpm-event (&gt;= 2.2.3-50) but it is not going to be installed
E: Broken packages</div>

Egads...I just don't understand apt. It's so damned stubborn. I don't know why it's saying this. There's nothing wrong with our packages--they're identical to the Debian ones!

--

Check out the forum guidelines!

Mon, 09/17/2007 - 10:39 (Reply to #12)
MikeM

OK, there's no suexec2, but there is a suexec:

ns1:~# /usr/lib/apache2/suexec -V
-D AP_DOC_ROOT=&quot;/var/www&quot;
-D AP_GID_MIN=100
-D AP_HTTPD_USER=&quot;www-data&quot;
-D AP_LOG_EXEC=&quot;/var/log/apache2/suexec.log&quot;
-D AP_SAFE_PATH=&quot;/usr/local/bin:/usr/bin:/bin&quot;
-D AP_UID_MIN=100
-D AP_USERDIR_SUFFIX=&quot;public_html&quot;
ns1:~# /usr/lib/apache2/suexec2 -V
-bash: /usr/lib/apache2/suexec2: No such file or directory

Mon, 09/17/2007 - 10:44 (Reply to #13)
Joe
Joe's picture

Yep. Definitely the wrong one.

Now if we could just convince that bastard apt to let you install apache2 from our repositories...you'd be set.

--

Check out the forum guidelines!

Mon, 09/17/2007 - 10:51 (Reply to #14)
MikeM

Is there a preferred OS?

I have debian, but I could just as easily wipe it out and install centos 5. There's really nothing on the server yet.

What do you think?

Mon, 09/17/2007 - 11:04 (Reply to #15)
Joe
Joe's picture

No, I like Debian 4 as well as anything out there. CentOS 5 is also great.

These are minor issues. The installer isn't perfect on anything, though I had thought that both of these issues were dealt with correctly. Not sure how you managed to hit them both. ;-)

For the apache thing, maybe try forcing apt to use our repo and install all of the bits it's asking for:

apt-get -t virtualmin-etch install apache2 apache2-mpm-prefork apache2-mpm-event

And dovecot is an easy fix...just make the change I mentioned.

--

Check out the forum guidelines!

Mon, 09/17/2007 - 11:26 (Reply to #16)
MikeM

Didn't work:

ns1:~# apt-get -t virtualmin-etch install apache2 apache2-mpm-prefork apache2-mpm-event
Reading package lists... Done
Building dependency tree... Done
apache2-mpm-prefork is already the newest version.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
apache2: Depends: apache2-mpm-worker (&gt;= 2.2.3-50) but it is not going to be installed or
apache2-mpm-prefork (&gt;= 2.2.3-50) but 2.2.3-4+etch1 is to be installed or
apache2-mpm-event (&gt;= 2.2.3-50) but 2.2.3-4+etch1 is to be installed
apache2-mpm-prefork: Conflicts: apache2-mpm-event but 2.2.3-4+etch1 is to be installed
E: Broken packages

Mon, 09/17/2007 - 11:53 (Reply to #17)
MikeM

Another question while I have your attention :-)
Why do punctuation marks such as ' and &quot;&quot; show up as question marks on my site?

Mon, 09/17/2007 - 12:07 (Reply to #18)
Joe
Joe's picture

Encoding mismatch, or possibly your editor is replacing regular quotes with fancy pants quotes (Microsoft products do this, and it's ugly and nasty behavior on their part, but if you force both the product generating and the encoding from your server to Unicode, modern browsers will work fine...old browsers will be SOL--other alternative is to turn off this &quot;feature&quot; in the product producing the text).

--

Check out the forum guidelines!

Mon, 09/17/2007 - 13:17 (Reply to #19)
MikeM

Do you think if I bought the pro version it would install correctly so my cgi script would run so I can set up my autoresponder program?

Or is there another way you can think of to install your apache modules?

I tried your last suggestion and posted the results above.

Mike

Mon, 09/17/2007 - 13:26 (Reply to #20)
Joe
Joe's picture

No, the installer and the apache2 packages are identical. If it had a problem with the GPL installer, it'll have the same problem with the Pro installer.

I'm working on reproducing the problem here, and will hopefully figure out why apt won't let us replace the default apache package soon.

--

Check out the forum guidelines!

Mon, 09/17/2007 - 15:28 (Reply to #21)
MikeM

OK, I won't do anything until I hear from you.

Tue, 09/18/2007 - 15:45 (Reply to #22)
MikeM

I tried changing the default website template by selecting not to add suexec, but it won't save. It gives an error &quot;Failed to save server template : Missing or invalid Apache user&quot;

Tue, 09/18/2007 - 18:33 (Reply to #23)
Joe
Joe's picture

OK, I'm seeing the problem here, too. I'll get it fixed shortly.

Set the Apache user to www-data on your Server Template if you want to disable Suexec. This is another buglet on Debian.

--

Check out the forum guidelines!

Wed, 09/19/2007 - 03:37 (Reply to #24)
MikeM

OK. I used the find apache user automatically last night so I could test my cgi script and that worked. I've now changed the user to www-data.

Keep me informed on the doc-root problem so I can update my site and run it correctly.

Thanks for the excellent support.

Mike

Mon, 09/24/2007 - 05:02 (Reply to #25)
MikeM

Hey Joe did you get the doc root problem in the install fixed yet?

Mike

Mon, 10/08/2007 - 10:28 (Reply to #26)
Richard

After some investigation I found the following:

http://software.virtualmin.com/gpl/debian/dists/virtualmin-etch/main/bin...

apache2 references to mpm dependancies of version *-50, however there is no reference to this version in the packages file, nor does debian itself offer this version.

Presumably this is the customized version that needs to be installed, without a reference it seems the debian version gets installed instead. And apache2 itself is a virtual package.

This is only the preliminary problem I see, there may be a lot more problems why the packages dont get installed correctly.

Perhaps I am overlooking something, I tried the following in /etc/apt/preferences:
Package: *
Pin: origin software.virtualmin.com
Pin-Priority: 1001

and although this does apperently influence the priority, it still wont correctly install apache due to a dependancy problem.

Any ideas?

Regards,
Richard.
PowerHost4U Internet Services.

Wed, 05/27/2009 - 08:37 (Reply to #27)
CoronelN

Eric

Yes i installed with install.sh

The script works in the CGI-BIN since i changed with the filemanager the Ownership to www-data and 755ed it.

I also went to:
Services-&gt; Configure Web site for SSL -&gt; CGI programs

and added a CGI dir alias like this

from: /proxy/
to: /home/TLD/cgi-bin/

put the cgi on a folder under /cgi-bin/proxy and now it is accesible from

https://tld.com/proxy/nameofthecgiscript.cgi

But going back to Suexec2
when I do a:
o0d:~#/usr/lib/apache2/suexec2 -V

I get a:

-bash: /usr/lib/apache2/suexec2: No such file or directory

if i do:
o0d:~# /usr/lib/apache2/suexec -V

I get a:

-D SUEXEC_CONFIG_DIR=/etc/apache2/suexec/
-D AP_GID_MIN=100
-D AP_LOG_EXEC=&quot;/var/log/apache2/suexec.log&quot;
-D AP_SAFE_PATH=&quot;/usr/local/bin:/usr/bin:/bin&quot;
-D AP_UID_MIN=100

That's it... so no reference to the home thing in the previous posts...

I looked at the error log in the folder you told me, it points to another folder in /var/logs/tld.log
I could not find any error related to the execution of the script execpt for once i made a typo in the address :D

Wed, 05/27/2009 - 08:48 (Reply to #28)
andreychek

<div class='quote'>-bash: /usr/lib/apache2/suexec2: No such file or directory</div>

Well, all that means is that if you call the program by the incorrect name from the command line, it won't work ;-)

The suexec program is called directly by Apache -- it's part of an Apache module called mod_suexec.

Suexec is particular about the location of the script being run, and the permissions and ownership of that script and the directory it resides in.

Debian began making this a bit easier to tweak recently -- take a look at this file:

/etc/apache2/suexec/www-data

Does it have two lines that look like:

[code:1]
/home
public_html/cgi-bin
[/code:1]

If so, try chopping off the &quot;cgi-bin&quot; part of the second line -- that may be limiting you to the cgi-bin directory.

I suspect you'll need to restart Apache after making that change.
-Eric

Thu, 05/28/2009 - 21:13 (Reply to #29)
CoronelN

Brilliant eric!

I guess i could instead of chopping the cgi-bin part that will allow scripts to be run everywhere just add another line public_html/folderiwantmyscript2b ??

I will play a bit with it and revert!

thanks again

N

Mon, 10/08/2007 - 07:38
Richard

Unfortunatly I have tried installing the GPL version on a debian 4 clean server as well 2 times, ( I had to have my provider reimage the server 2 times with a clean debian 4 install ).

Both times it does not seem to pick up the APT replacement packages from virtualmin, causing numerous errors, not just in apache.

I'm going to try this on a local box now...

/etc/apt/sources.list after install.sh execution:
# the main Debian packages.
deb http://ftp.nl.debian.org/debian/ etch main contrib
# Uncomment the deb-src line if you want 'apt-get source'
# to work with most packages.
deb-src http://ftp.nl.debian.org/debian/ etch main contrib
# uncommenting the following line will enable security updates
deb http://security.debian.org/ stable/updates main contrib
deb http://software.virtualmin.com/gpl/debian/ virtualmin-etch main

The install script does not give any error otherwise, it simply installs the wrong packages (debian equivilants) as far as I can see.

Since I generally I only want to use Debian, it would be very helpfull this will get fixed asap. I'm also considering of buying the Pro version, but I want a good few months of a stable working version first. And unfortunatly, most options do not work presumably due to the wrong packages installation.

Wed, 11/26/2008 - 10:43
liwordddd

After 3 years,the same problem still happened.seems this is another reason to give up virtualmin.

Wed, 11/26/2008 - 12:25 (Reply to #32)
Joe
Joe's picture

<div class='quote'>After 3 years,the same problem still happened.seems this is another reason to give up virtualmin. </div>

What problem are you talking about?

--

Check out the forum guidelines!

Mon, 05/25/2009 - 04:56
CoronelN

Hello,

I am having the same problem running Debian 4 X64, i am a bit at loss can you give me a hand.

where do i change the settings?
thanks!

Mon, 05/25/2009 - 05:10 (Reply to #34)
andreychek

Howdy,

Well, this thread is a bit old, so let's start fresh... what problem are you having specifically, and what settings are you looking to change?
-Eric

Wed, 05/27/2009 - 05:27
CoronelN

Hey thanks Andrey,

I cannot make my CGI perl scripts to work, now following twhat is in this thread i changed ownership of the script to www-data and removed on the webserver the option to run scripts as owner. the script works as long as is inthe cgi-bin directory.

the suexec2 ETC did gave any results...
and if i understood well i should preffer that option over the www-data thing for securityreasons.

Also i would like to have the scripts running outside the cgi-bin folder i.e: in a folder under public_html as it is for a proxy im setting...

any help will be welcomed!

Wed, 05/27/2009 - 05:38 (Reply to #36)
andreychek

Just so I know the state of your system -- did you by chance install with the install.sh script?

<div class='quote'>the script works as long as is inthe cgi-bin directory.</div>

Okay, that's a good start.

<div class='quote'>and if i understood well i should preffer that option over the www-data thing for securityreasons.</div>

Yeah, suexec provide a nice security benefit since it can run as the individual Virtual Server owner, rather than the generic www-data user.

If you're having trouble getting it to work, let us know what you're trying, and what error you're getting (be sure to take a peek in the Apache error_log for that domain in $HOME/logs/error_log).

<div class='quote'>i would like to have the scripts running outside the cgi-bin folder i.e: in a folder under public_html as it is for a proxy im setting...</div>

Sure, you can do that by adding &quot;ExecCGI&quot; to the Options line.

To add it to an existing site, you can manually edit the VirtualHost section for that domain in /etc/apache2/sites-enabled.

For new domains, you can go into System Settings -&gt; Server Templates -&gt; Default -&gt; Apache Website, and update the section at the top named &quot;Directives and settings for new websites&quot;. Any new Virtual Server will get your updated configuration.
-Eric

Topic locked