SImply add .py extension to the AddHandler directive in httpd.conf
change
- Code: Select all
AddHandler cgi-script .cgi .pl
to
- Code: Select all
AddHandler cgi-script .cgi .pl .py
if you like to run Python Scripts (*.py) from anywhere inside your server. Restart Xampp after editing httpd.conf
Or simply put your Python Scripts into /opt/lampp/cgi-bin and you can call them via
http://localhost/cgi-bin/scriptname.py (you may replace "localhost" by another domain name, if Xampp also runs on a public server).
In BOTH cases, you MUST supply a working "Shebang Line" (the very first line of your scripts) to every Python Script, which points to the Python interpreter. Example:
- Code: Select all
#!/usr/bin/python
As python is NOT part of Xampp, it must be installed somehow else. All Linux distributions are coming with a standard python interpreter, if it is not installed by default, you have to install it via your system specific installation tools.