Report this

What is the reason for this report?

I can not execute my CGI files in my virtual host

Posted on December 3, 2018

Hi everyone!

I can not execute my CGI files in my virtual host, this is the configuration of my file: /etc/apache2/conf-available/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/" "/var/www/814.pe/public_html/cgi-bin/"
#Modified by me - start
#<Directory "/var/www/814.pe/public_html/cgi-bin/">
#                       AllowOverride None
#                       Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#                       AddHandler cgi-script .cgi .pl
#                       Require all granted
#                       SetHandler cgi-script
#               </Directory>
#Modified by me - end

<Directory "/var/www/814.pe/public_html/cgi-bin/mt/">
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>

and this is the conf of my domain in which I try to run the scripts: /etc/apache2/sites-available/814.pe.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # 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 www.example.com

        ServerAdmin daniel@814.pe
        ServerName 814.pe
        ServerAlias www.814.pe
        DocumentRoot /var/www/814.pe/public_html

        # 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

        RewriteEngine on
        RewriteCond %{SERVER_NAME} =www.814.pe [OR]
        RewriteCond %{SERVER_NAME} =814.pe
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

#Modified by me - start
#ScriptAlias /cgi-bin/ /var/www/814.pe/public_html/cgi-bin/
#<Directory "/var/www/814.pe/public_html/cgi-bin/">
#                        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
#                        AddHandler cgi-script .cgi .pl
#                       AllowOverride None
#                       Require all granted
#                </Directory>
#Modified by me - end

</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

This is what i get in console apache error log: Browser say: “Internal Server Error” Console say: “[cgi:error] [pid 20550] [client 190.216.190.76:34913] End of script output before headers: test.cgi”

The problem gets worse if I decide to run the files in a folder inside my CGI-BIN folder: Browser say: Not Found" Console say: “script not found or unable to stat: /var/www/814.pe/public_html/cgi-bin/mt/test.cgi”

Whai i really need is make run this CGI files inside of a directory calls mt

Im using APACHE on Ubuntu 14.04.5 x64

Thnak you so much for oyur help guys.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.