enable execution of cgi script on apache webserver

Hi, I am having trouble getting my webserver to execute a .cgi script. I am new to this stuff so I must have made a mistake along the way.

I enabled the mods which shows up in mods-enabled folder (cgi.load)

Here is my host config file with the script alias setup
<VirtualHost *:80>
   ServerName lesliekenton.com
   ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/current

</VirtualHost>
<VirtualHost *:443>
        # The ServerName directive sets the request scheme, hostname and port t$
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        ServerName lesliekenton.com
        SSLEngine on
        SSLCertificateFile /var/www/home/lesliekenton.com.crt
        SSLCertificateKeyFile /var/www/home/lesliekenton.com.key
        SSLCACertificateFile /var/www/home/intermediate.crt

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html/current

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

ScriptAlias /cgi-bin/ /var/www/html/current/cgi-bin/
<Directory "/var/www/html/current/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AddHandler cgi-script .cgi
    Order allow,deny
    Allow from all
</Directory>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Open in new window



I restarted apache and it gave me this information:
[Sun Jun 21 01:45:29.889975 2015] [alias:warn] [pid 17800] AH00671: The ScriptAlias directive in /etc/apache2/sites-enabled/000-default.conf at line 42 will probably never match because it overlaps an earlier ScriptAlias.

I am not sure what it means by overlaps an earlier ScriptAlias

The file execute is a search script that is triggered here:
http://lesliekenton.com/search/search.php?zoom_query=chicken

The actual script is:
http://lesliekenton.com/search/search.cgi?zoom_query=chicken

Which triggers a download rather than executing the file.
LightwalkerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
The error message probably means that there is a previous ScriptAlias in the main 'httpd.conf' with the same name /cgi-bin/ and that the first one is the only one that will be 'seen'.  It is probably pointing to a different directory.
0
LightwalkerAuthor Commented:
Hi Dave, I have no httpd.conf as it is debian and my apache2.conf does not have any ScriptAlias blocks
0
Dave BaldwinFixer of ProblemsCommented:
Something does and Apache is telling you about it.  ScriptAlias is a single line.  What is 'conf-available/serve-cgi-bin.conf'?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

LightwalkerAuthor Commented:
Thanks Dave,
I missed that. so it is enabled it looks like but still not working on that script:

Here is the content of serve-cgi-bin.conf

<IfModule mod_alias.c>
        <IfModule mod_cgi.c>
                Define ENABLE_USR_LIB_CGI_BIN
        </IfModule>

        <IfModule mod_cgid.c>
                Define ENABLE_USR_LIB_CGI_BIN
        </IfModule>

        <IfDefine ENABLE_USR_LIB_CGI_BIN>
                ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
                <Directory "/usr/lib/cgi-bin">
                        AllowOverride None
                        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                        AddHandler cgi-script .cgi
                        Require all granted
                </Directory>
        </IfDefine>
</IfModule>

Open in new window

0
Dave BaldwinFixer of ProblemsCommented:
And it won't because it is pointing to a different directory.
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

Open in new window


Try making all of your references to be 'cgibin' without the '-'.  That way, it won't match the previous definition.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LightwalkerAuthor Commented:
since I am only running the one cgi script should I point it to:
/var/www/html/current/search

rather than:
/var/www/html/current/cgi-bin

Thanks again for your patience
0
LightwalkerAuthor Commented:
Now I am getting an internal server error, so it looks like it is trying to execute but can't
http://lesliekenton.com/search/search.cgi?zoom_query=chicken
0
LightwalkerAuthor Commented:
never mind I have change the search to php instead of cgi. Which will be fine for a while
0
LightwalkerAuthor Commented:
did not get it to work in the end so switch to php as my search engine. Thanks anyway for your help
0
Dave BaldwinFixer of ProblemsCommented:
And now it's gone...  One of the things about a Perl/cgi is that you Must set permissions for it to Execute or you just get just an error message.  I have Ubuntu 10.04 and I just checked it on my system.  I can run 'pl' or 'cgi' files as long as I set the permissions to include Execute.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.