httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alessandro Re <...@ale-re.net>
Subject [users@httpd] Cannot run CGI scripts in user directory
Date Sun, 22 May 2016 03:05:45 GMT
Dear community,

I do not like to cross-post, but I cannot find a solution to this
problem (yes, I searched). The discussion started at [1], but I am
seeking help also here, because I cannot get what is wrong and I
cannot understand how to get more detailed error logs - so I thought
that a specialized mailing list could help.

The issue is related to CGI scripts executed in user directory. I am
working on Fedora 23, with the default Apache configuration. CGI are
working correctly in /var/www/cgi-bin, and user_dir has been enabled
and works correctly (serving web pages and php scripts).

I am trying to serve cgi scripts from /home/*/public_html/cgi-script,
but when I run a script - any script - I get the not-so-informative
error:

[cgi:error] End of script output before headers: test.cgi, referer:
http://localhost/user/cgi-bin/

Now, to ensure that everything was as I intended, I disabled CGIs in
the server configuration:

AddHandler(s), SetHandler(s) and ScriptAlias(s) are commented in
global and virtual hosts. They are also disabled in the user directory
config file.

In this way, no CGI script is executed. Enabling Indexes allows me to
list the cgi scripts, but they are opened as text files instead of
being executed - as I intended.

My user-directory config file is this one:

<IfModule mod_userdir.c>
    UserDir enable
    UserDir public_html
</IfModule>

<Directory "/home/*/public_html">
    AllowOverride All
    Options +MultiViews +Indexes +SymLinksIfOwnerMatch +IncludesNoExec
    Require all granted
</Directory>

<Directory "/home/*/public_html/cgi-bin">
    #Options +ExecCGI
    #AddHandler cgi-script .cgi
   Options +FollowSymLinks +Indexes
    Require all granted
    AllowOverride All
</Directory>

Note that CGIs are disabled. Now, from what I understand,
un-commenting the ExecCGI and AddHandler should suffice to make the
.cgi scripts in ~/public_html/cgi-bin runnable. I am experimenting
with a simple script, with mode 755, with the following content:

test.cgi

#!/usr/bin/sh
echo "Content-type: text/plain"
echo ""
echo "Hello"

As I was saying, trying to run this script results in a "End of script
output before headers: test.cgi,".

I didn't understand if this may help in this case, but I tried to
enable ScriptLog, adding this in the global configuration:

ScriptLog "logs/cgi_log"

to make it work, I created the file and set it owned and writable for
the apache user:

# touch /etc/httpd/logs/cgi_log
# chown apache:apache /etc/httpd/logs/cgi_log
# chmod 755 /etc/httpd/logs/cgi_log

But the logs are empty. I don't know if I should expect any output for
this kind of error anyway.

IDK if this may help:

# httpd -V
AH00558: httpd: Could not reliably determine the server's fully
qualified domain name, using fe80::c2f8:daff:fe89:afde. Set the
'ServerName' directive globally to suppress this message
Server version: Apache/2.4.18 (Fedora)
Server built:   Jan  4 2016 08:15:18
Server's Module Magic Number: 20120211:52
Server loaded:  APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/etc/httpd"
 -D SUEXEC_BIN="/usr/sbin/suexec"
 -D DEFAULT_PIDLOG="/run/httpd/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

I hope I wrote all the necessary information (in addition to the ones
present in [1]), but if something is missing, feel free to ask.
Can someone help me on this, please?

[1]: http://stackoverflow.com/questions/28265735/

Cheers
~Ale

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message