Monday, July 10, 2017

getting python webpage to be displayed

I am using Server version: Apache/2.4.10 (Raspbian) and Python 2.7.9

the issue I was getting that when trying to open my webpage

http://dhillon.duckdns.org:17581/cgi-bin/webgui.py

It was displaying the python code rather than the webpage.

I had to do below thing to get it fixed.
sudo a2enmod cgi
sudo a2disconf serve-cgi-bin
then modified the conf file under
/etc/apache2/apache2.conf
and included
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin/">
        AddHandler cgi-script .py
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Require all granted
</Directory>
after that restarted the apache and that's it .
sudo service apache2 reload

Make sure that the python files are under /usr/lib/cgi-bin/ and have correct permissions

Done !!!

No comments: