I am trying to execute a Python program using Apache. However, Apache will only serve the file and not actually execute it. The permissions on the file are r/w/x and it is
**For apache2 version 2.4
sudo apt-get install python
sudo apt-get install apache2
edit file /etc/apache2/conf-enables/serve-cgi-bin.conf
====comment old section and add code below:
ScriptAlias /cgi-bin/ /var/www/cgi-bin/
AddHandler cgi-script .py
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
=========================================
edit file /etc/apache2/apache2.conf ***add code below:
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
Options All
Require all granted
Note!
use for apache2.4
file python keep in directory: /var/www/cgi-bin/
You can test :go to http://localhost/cgi-bin/.py
referrence https://www.linux.com/blog/configuring-apache2-run-python-scripts