View: 9939|Reply: 6

How to run sh cgi scripts on Raspbian?

[Copy link]

11

threads

30

posts

50

credits

Registered member

Rank: 2

credits
50
Published in 2016-7-26 04:23:22 | Show all floors |Read mode
I set up Apache as webserver that hosts a webpage, and that works. But when I try to run my sh cgi script I get a "Internal Server Error", and the log shows as "...Premature end of script headers..." followed by a "...Zlib: Compressed..." for every browser attempt to load the file. I've even tried with close to the simplest script I could make; same results. I also ran `service apache2 restart` after making changes.
When run from the terminal, my sh script works like it's supposed to.
How can I get this working? Do I need to install something, change some setting, or do something else?
--------------------------------------------------------------------------------
#!/bin/sh
/bin/echo 'Content-type: text/html';
/bin/echo '';
/bin/echo '<head>';
/bin/echo '<title>LOCALCUPSLINK</title>';
/bin/echo '</head>';
/bin/echo '<body>';
/bin/echo '<p><a href="localhost:631">local cups webpage</a></p>';
/bin/echo '</body>';
/bin/echo '</html>';

--------------------------------------------------------------------------------
# latest version of playing around with /etc/apache2/sites-available/default
<VirtualHost *:80>
        ServerAdmin soon,

        DocumentRoot /var/www/html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>

        <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # This directive allows us to have apache2's default start page
                # in /apache2-default/, but still have / go to the right place
                #RedirectMatch ^/$ /apache2-default/
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AddHandler cgi-script .cgi .sh cgi.sh .sh.cgi
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
       
        AddHandler cgi-script .cgi .sh cgi.sh .sh.cgi
        Options +ExecCGI
       
        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel debug

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
       
</VirtualHost>
--------------------------------------------------------------------------------

11

threads

30

posts

50

credits

Registered member

Rank: 2

credits
50
 Author| Published in 2016-7-31 12:42:04 | Show all floors
I've gotten cgi to work on my laptop, but not the Pi. Has anyone gotten cgi working Orange Pi using Raspbian? (or other OS)?

11

threads

30

posts

50

credits

Registered member

Rank: 2

credits
50
 Author| Published in 2016-8-6 08:31:18 | Show all floors
Hate to start over, but curious, Is there an OS I can put on this headless OPP that can run cgi made with bash/sh?

0

threads

1

posts

30

credits

Novice

Rank: 1

credits
30
Published in 2022-1-21 16:44:53 | Show all floors
Schools and universities generally block the sites that children use for entertainment. Like music sites, movies and games. They keep blocking sites as they discover them. Get gaming sites unblocked list here.

0

threads

3

posts

22

credits

Novice

Rank: 1

credits
22
Published in 2024-12-16 15:59:48 | Show all floors
Sprunked takes competition to the next level with its multiplayer mode. Challenge friends or players worldwide in real-time battles to see who has the best rhythm and reflexes.
[url=https://https://stumble-guys.co/]stumble guys
Published in 2025-9-19 22:44:49 | Show all floors
유흥알바는 주로 밤 시간대에 이루어지는 엔터테인먼트 업소에서의 아르바이트를 말합니다. 클럽, 바(bar), 노래주점(가라오케)이나 룸살롱 등에서 고객을 응대하고 서비스        유흥알바
Published in 2025-9-20 19:53:00 | Show all floors
Woah this is just an insane amount of information, must of taken ages to compile so thank you so much for just sharing it with all of us. If your ever in any need of  related info, perhaps a bit of  coaching, seduction techniques or just general  tips, just check out my own site!        daftar poker88
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list