I’m moving from Windows IIS to Ubuntu with Apache using Virtualmin. So far, everything has been great, and have already moved over 6 websites. I am having an issue with cgi files though. It’s a program purchased through another company, and it’s the only CGI thing used. My issue is that on my old Windows server, it was in The “forms” folder has a bunch of cgi files in it, and has sub-folders with cgi files in it. When I moved it to the new website that’s using Virtualmin, the cgi file comes across as text. I can’t quite figure out how to get the files in /forms and all of the cgi files in sub-folders in /forms to work. There are also html and php files in those folders.

Do I need to put them in the /home/domain/cgi-bin folder instead of /home/domain/public_html? I’d like to keep all the paths the same as the old site for now if possible.


Yeah, it’s assumed that CGI scripts would go in the cgi-bin directory.

It can work to put them in the “forms” directory, you’d just need to do some tweaking of the Apache config.

Which distro is it that you’re using?


Ubuntu 12.04 with Virtualmin Pro 3.94. Thanks for the help! I’m attaching a PDF with some setup instructions. If it was just a single server with Apache, I’d be able to figure it out, but since there are multiple sites, I’m a little confused (and I’m just overall confused with the cg-bin setup anyway). There are 3 sites in total that use this “forms” directory that I’ll be moving to Virtualmin, so I can apply it to each site that needs it.


The options they discuss in those directions all still apply to a system setup with Virtualmin… you can edit those by opening /etc/apache2/sites-enabled/YOUR_DOMAIN_NAME.conf in a text editor, and making those tweaks.

In particular, you’d want to add “ExecCGI” to the “Options” line, and you’d want to add the “AddHandler” line somewhere to that config as well.

When you’re done, you can restart Apache with:

/etc/init.d/apache2 restart

You could also make those same changes from within Virtualmin in Services -> Edit Directives.


Thanks so much for your help on this! We hope to get rid of all of these within the next year and make our own with PHP/mysql. So, it looks like it’s partially working now, as it’s not showing as text anymore. I’m getting a 500 Internal Server Error. In the Apache Error log file I’m getting:

suexec policy violation: see suexec log for more details
Premature end of script headers: login.cgi

This is what my new .conf file looks like (added +ExecCGI + MultiViews and added .cgi Handler)

<Directory /home/domain/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI +Multiviews
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
AddHandler cgi-script .cgi
FCGIWrapper /home/domain/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/domain/fcgi-bin/php5.fcgi .php5


You’d want to make sure that the .cgi file is owned by the Virtual Server owner. You’d also want to verify that it’s permissions are 755 (and not 775 or 777). Same with the directory they’re in.

Suexec can be a bit fickle about CGI script ownership, those above settings should help.

However, suexec would be throwing the specific errors that are occurring in /var/log/apache/suexec.log, you could always take a peek there to see the exact errors that are occurring.


Thanks again! Changing to 755 helped with the other cgi files not showing as text. The login.cgi still doesn’t work. I’m guessing it has to do with the DBI in the file. The first line of the file is: DBI:mysql:forms which it uses to connect to the mysql database. Not sure if that’s installed or not. I’ll need to do some digging.


Any errors that are occurring in your web apps should show up in the Apache error logs… you can see those in $HOME/logs/error_log.