please choosego to mobile | Continue to access the PC version
View: 6078|Reply: 3

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.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list