klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

python3 CGI broken in apache2

Thu Oct 13, 2016 6:21 pm

Hello
I started new setup of Jessie and apache2.
I'm trying to set up apache2 to use python3 cgi. I keep getting a 404 error. All the googling that I have done has old fixes for this error. It would be great to have a fix for this. Is there a link out there that has the new apache2 fix for python3 CGI?

Klint
P.S. I need some of the apache2 features.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

User avatar
DougieLawson
Posts: 39126
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: python3 CGI broken in apache2

Sat Oct 15, 2016 8:11 am

If you get any error from Apache2 then start by looking at the logs in /var/log/apache2 that should give you a clue where to start investigating your problems.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Re: python3 CGI broken in apache2

Sat Oct 15, 2016 5:58 pm

I'll try that.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Re: python3 CGI broken in apache2

Sun Oct 16, 2016 3:52 pm

Now all I get is the script as test on the webpage.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

User avatar
DougieLawson
Posts: 39126
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: python3 CGI broken in apache2

Sun Oct 16, 2016 7:37 pm

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Re: python3 CGI broken in apache2

Thu Oct 20, 2016 2:41 pm

Thanks,
I did that and this it is working

/etc/apache2/conf-enabled/server-cgi-bin.conf

Code: Select all

<IfModule mod_alias.c>
    <IfModule mod_cgi.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfModule mod_cgid.c>
        Define ENABLE_USR_LIB_CGI_BIN
    </IfModule>

    <IfDefine ENABLE_USR_LIB_CGI_BIN>
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
            AllowOverride All
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
                        Allow from all
                        AddHandler cgi-script .py
        </Directory>
    </IfDefine>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
sudo adduser pi www-data
sudo chown pi:www-data -R /var/www
sudo chmod 0755 -R /var/www
sudo chmod g+s -R /var/www

chown -R www-data /var/www
chgrp -R www-data /var/www

chown -R www-data /usr/lib/cgi-bin
chgrp -R www-data /usr/lib/cgi-bin


/etc/apache2/conf-enabled/server-cgi-bin.conf

Code: Select all

Require all granted


Then
a2enmod cgi
sudo systemctl restart apache2.service
sudo systemctl status apache2.service

If there is any errors, there is something wrong in the server-cgi-bin file.
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

Return to “Python”