logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in  RSS Apache Lounge  


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.


Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: "End of script output before headers" on Centos 8
Author
edwardsmarkf



Joined: 20 Feb 2013
Posts: 23
Location: cottonwood, az

PostPosted: Mon 22 Mar '21 23:37    Post subject: "End of script output before headers" on Centos 8 Reply with quote

hello -

i keep seeing "End of script output before headers" in my apache log on the new Centos 8 box but not my old C7 box.

so i created a very simple script and i get the same error: (script runs FINE on centos7)

----
#!/bin/sh
echo content-type: text/plain
echo
date
-----

set protection 755, 777, etc. set owner apache:apache

at this point, i am running out of things to try.

i looked at this too (added this line)

LoadModule cgi_module modules/mod_cgi.so

# httpd -M | grep cgi ;
cgi_module (shared)
proxy_fcgi_module (shared)
proxy_scgi_module (shared)
cgid_module (shared)
fcgid_module (shared)

suggestions?

tiny shell-script suggested here:
https://www.perlmonks.org/?node_id=255892
Back to top
tangent



Joined: 16 Aug 2020
Posts: 83
Location: UK

PostPosted: Tue 23 Mar '21 19:24    Post subject: Reply with quote

I have a Centos 8 VM (upgraded from Centos 7 a few months ago), and don't have any problems running CGI scripts using the default Apache configuration and a simple shell script, e.g.
Code:
#!/bin/sh
echo content-type: text/plain
echo
date
set

Produces this output https://apaste.info/JucE

File protection is
Code:
[root@localhost cgi-bin]# ls -la /var/www/cgi-bin
total 4
drwxr-xr-x. 2 root   root   18 Mar 23 16:52 .
drwxr-xr-x. 4 root   root   33 Mar 23 16:00 ..
-rwxr-xr-x. 1 apache apache 54 Mar 23 16:52 test

Are there no other error messages preceding your "End of script output before headers" entries, to indicate what's causing the problem?

Might it be an selinux issue, so presume you've checked messages and audit.log?

Either way, I'd try temporarily changing the apache account shell from /sbin/nologin to /bin/bash, switch user from root to apache, and then try running your cgi script to see what output it produces.

Have you considered using the Apache suEXEC feature for your CGI scripts?
Back to top
edwardsmarkf



Joined: 20 Feb 2013
Posts: 23
Location: cottonwood, az

PostPosted: Tue 23 Mar '21 22:24    Post subject: Reply with quote

interesting:

Quote:
# journalctl -b | grep “suexec” | tail -10 ;
Mar 23 16:00:34 MYDOMAIN suexec[3925478]: uid: (1018/MYDOMAIN) gid: (1018/MYDOMAIN) cmd: test.cgi
Mar 23 16:00:34 MYDOMAIN suexec[3925478]: command not in docroot (/home/MYDOMAIN/cgi-bin/test.cgi)
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6935
Location: Germany, Next to Hamburg

PostPosted: Tue 23 Mar '21 23:44    Post subject: Reply with quote

You may also check the EOL.

In doubt run dos2unix for the test file.
Back to top
edwardsmarkf



Joined: 20 Feb 2013
Posts: 23
Location: cottonwood, az

PostPosted: Wed 24 Mar '21 19:58    Post subject: Reply with quote

it turns out that there is a conflict with Centos-8 and Virtualmin.
Back to top


Reply to topic   Topic: "End of script output before headers" on Centos 8 View previous topic :: View next topic
Post new topic   Forum Index -> Apache