CGI Script Doesn't Execute (Served as Text)

Hi,

Thanks in advance.

I recently migrated all virtual servers from an old CentOS host to a new Ubuntu 14.04 LTS server installed with the install script. Most things went very well due to Virtualmin (Pro).

I have one small CGI script that is not being executed. It is located in cgi-bin with a file type of .cgi, written in perl. No errors appear to be logged anywhere...the .cgi file is just served up as text in a separate pop-up window (the original script opened a separate window too).

This is in /etc/apache2/sites-available/problemdomain.com.conf:

<Directory /home/problemdomain/cgi-bin>
allow from all
AllowOverride All
Require all granted
AddHandler fcgid-script .cgi

The permissions look fine to enable execution. The actual script is in a subdirectory of cgi-bin:

root@www:~# ll /home/problemdomain/cgi-bin/ipcalc/ipcalc.cgi
-rwxr-xr-x 1 username problemdomain 6382 Jun 16  2014 /home/problemdomain/cgi-bin/ipcalc/ipcalc.cgi*

Also, a 'test.cgi' script also fails to execute in the cgi-bin directory. I believe it's a problem with 'executing CGI' as opposed to a problem with that file...maybe an 'executing perl' issue (the test.cgi was also perl)?

The fcgid module is already enabled (as reported by a2enmod).

Any clues welcomed.

Thanks,

G

Status: 
Active

Comments

Howdy -- you may just be seeing an issue with a module that isn't enabled.

What is the output of these commands:

ls /etc/apache2/mods-enabled
ls /etc/apache2/mods-available

Lastly, if you go into System Settings -> Re-Check Config, does it detect any problems with PHP or Apache?

Hi, and thanks again,

Re-Check reports "your system is ready for use by Virtualmin"

root@www:~# ls /etc/apache2/mods-enabled
access_compat.load  auth_digest.load  authz_user.load  dav_svn.conf  env.load     mpm_prefork.conf  proxy_balancer.conf  rewrite.load        ssl.load
actions.conf        authn_core.load   autoindex.conf   dav_svn.load  fcgid.conf   mpm_prefork.load  proxy_balancer.load  setenvif.conf       status.conf
actions.load        authn_file.load   autoindex.load   deflate.conf  fcgid.load   negotiation.conf  proxy.conf           setenvif.load       status.load
alias.conf          authz_core.load   dav_fs.conf      deflate.load  filter.load  negotiation.load  proxy_connect.load   slotmem_shm.load    suexec.load
alias.load          authz_host.load   dav_fs.load      dir.conf      mime.conf    php5.conf         proxy_http.load      socache_shmcb.load
auth_basic.load     authz_svn.load    dav.load         dir.load      mime.load    php5.load         proxy.load           ssl.conf

root@www:~# ls /etc/apache2/mods-available
access_compat.load  authz_groupfile.load  dav_lock.load    heartmonitor.load         mpm_prefork.conf     proxy.load           socache_memcache.load
actions.conf        authz_host.load       dav_svn.conf     include.load              mpm_prefork.load     proxy_scgi.load      socache_shmcb.load
actions.load        authz_owner.load      dav_svn.load     info.conf                 mpm_worker.conf      proxy_wstunnel.load  speling.load
alias.conf          authz_svn.load        dbd.load         info.load                 mpm_worker.load      ratelimit.load       ssl.conf
alias.load          authz_user.load       deflate.conf     lbmethod_bybusyness.load  negotiation.conf     reflector.load       ssl.load
allowmethods.load   autoindex.conf        deflate.load     lbmethod_byrequests.load  negotiation.load     remoteip.load        status.conf
asis.load           autoindex.load        dialup.load      lbmethod_bytraffic.load   php5.conf            reqtimeout.conf      status.load
auth_basic.load     buffer.load           dir.conf         lbmethod_heartbeat.load   php5.load            reqtimeout.load      substitute.load
auth_digest.load    cache_disk.conf       dir.load         ldap.conf                 proxy_ajp.load       request.load         suexec.load
auth_form.load      cache_disk.load       dump_io.load     ldap.load                 proxy_balancer.conf  rewrite.load         unique_id.load
authn_anon.load     cache.load            echo.load        log_debug.load            proxy_balancer.load  sed.load             userdir.conf
authn_core.load     cache_socache.load    env.load         log_forensic.load         proxy.conf           session_cookie.load  userdir.load
authn_dbd.load      cgid.conf             expires.load     lua.load                  proxy_connect.load   session_crypto.load  usertrack.load
authn_dbm.load      cgid.load             ext_filter.load  macro.load                proxy_express.load   session_dbd.load     vhost_alias.load
authn_file.load     cgi.load              fcgid.conf       mime.conf                 proxy_fcgi.load      session.load         xml2enc.load
authn_socache.load  charset_lite.load     fcgid.load       mime.load                 proxy_fdpass.load    setenvif.conf
authnz_ldap.load    data.load             file_cache.load  mime_magic.conf           proxy_ftp.conf       setenvif.load
authz_core.load     dav_fs.conf           filter.load      mime_magic.load           proxy_ftp.load       slotmem_plain.load
authz_dbd.load      dav_fs.load           headers.load     mpm_event.conf            proxy_html.load      slotmem_shm.load
authz_dbm.load      dav.load              heartbeat.load   mpm_event.load            proxy_http.load      socache_dbm.load

Ah, I think that's the issue... try running these two commands:

a2enmod cgi
service apache2 restart

After that, try running that script again, and see if it works properly for you now.

I'm having the same issue here... running Ubuntu 14... I also migrated from CentOS using Virtual Min Tools

Directives look OK

ScriptAlias /cgi-bin/ /home/htoday/cgi-bin/


<Directory /home/htoday/cgi-bin>
allow from all
Options +SymLinksifOwnerMatch +ExecCGI
AllowOverride All
Require all granted
AddHandler fcgid-script .cgi
</Directory>

This fires: http://www.hinduismtoday.com/cat.php # script is in the public_html directory

this does not

http://www.hinduismtoday.com/cgi-bin/cat.php

I ran a

a2enmod cgi
service apache2 restart

and looking and /etc/apache2/mods-enable # shows cgi load

All cgi scripts are set with the current site owner and group as the same. permissions are 755... but any cgi whether it is a bash script, php, or liveCode server script... all fail with an internal error

there seems to be no active logs in /etc/apache2/suexec

What next?

What I would suggest, is to work with a bash script which has the ".cgi" extension in it's filename.

When doing that, if you get a 500 error, look in $HOME/logs/error_log to see what error is being generated.

OK.. I found the suexec log... that helps /var/log/apach2

I actually did that with an sh script that pushes a little email out... the email goes out then we get a premature end of script headers because the script is not sending anything back to the browser.

But this:

AddHandler livecode-script .lc Action livecode-script /cgi-bin/livecode-community-server

should allow me to run any .lc script from the public_html folder

http://www.hinduismtoday.com/echo.lc

fails and I get this in the suexc log:

[2016-02-12 15:05:34]: uid: (1000/htoday) gid: (1000/htoday) cmd: livecode-community-server [2016-02-12 15:05:34]: (2)No such file or directory: exec failed (livecode-community-server)

which makes no sense because the livecode-community-server (interpreter) is there... and set to 755 and another linode server using the same version of Ubuntu, this is working perfectly

perplexed....

We're happy to help!

You appear to be seeing a different issue than the one above though... would it be possible to start a new request where we can look deeper into this?

Then we can keep this to just one topic, and the initial poster won't be receiving notifications from us as we look into this.

If you want, just copy and paste your latest comment into a new request and we can pick up there.

Thanks!

well my cgi was being served as text when I started... :-) then after tweaking the httpd.conf directives and enabling the cgi module... the issue "morphed"

but sure... I'll start another ticket.

My original issue was resolved by enabling the "cgi" module.

Thanks much,

G

FWIW: mine we resolved by installing a missing library on Ubuntu that the CGI Required: ldd is your friend (list dynamic dependencies)

ldd ./mycgi.cgi

list of required libraries is returned if one is missing, the report shows this.