I have looked everywhere and tried many suggested solutions, still without the required result: to run a python file from my lamp server. I can not seem to integrate all the pieces of the puzzle ... Complicating the story is that many solutions either use old apache version (<2.4), which changed the config files significantly. No more httpd.conf! so this executing-a-python-script-in-apache2 does not help; But also the python version being > 3 complicates matters.
specs:
- linux Kubuntu, apache 2.4, python 3.5
- apache is running
- website files are in root/var/www/html/, I have sudo access to this folder.
- apache2 cgi module enabled: a2enmod cgi
- the python 3.5 path is usr/bin/env python3
the python script, simplest of scripts, has been made executable
#!/usr/bin/env python3 print ("Content-type: text/html\n") print ("Hello world!")
lets boil it down to the simplest case: I would like to have apache interpret the spark.py script and spit out the html: "Hello world!"
Questions:
- is the script file correct as is?
- which config files do I need to change and what do I need to add to these config files?
I know for security reasons, you should not have apache run script in your root dir.