Install XAMPP server to run python , cgi-bin , PHP , scripts(Updated June 2017)

Опубликовано: 25 Июль 2026
на канале: Jason Cheung
33,438
127

How to set up XAMPP to run Python programs and php on your own computer. SQL works also. Only tested on windows 10.All programs can be run through localhost in browser and files stored in htdocs directory in xampp.
Xampp Version 5.6.30
Python.3.6.1

Link to Python https://www.python.org/downloads/

Link to XAMPP https://www.apachefriends.org/index.html

Should be the same versions as mine in order to work.

Make sure to save Python as C:\Python3.6 using custom installation.First line of your program must direct to where python.exe is installed.Mine is #!C:/Python3.6/python.exe .You must use parenthesis with print.

Instructions:
__________________________________________________________________
1.Install xampp and python, make sure to remember the location where everything is installed.Mine are in 1 folder.
2.When both are installed, run XAMPP.
3.add test files to htdocs mine are downloadable.
4.Open the httpd.conf file in apache by clicking config but do not start apache yet.
6. Look for AddHandler cgi-script .cgi .pl .asp and add .py to it
7.Start apache
8. open a browser, type localhost and go to it. This is your homepage.
9. To run your files type localhost/ enter in name of file. eg
localhost/hello.py
10. That's it, it should work. Just make sure to have correct shebang on top of python files which shows the location of where python.exe is. Mine is #!C:/Python3.6/python.exe
11. You now should add passwords and run it offline if needed.
12.Python files need print("content-type: text/html\n\n" ) below shebang in order to work.

my httpd file :
https://www.dropbox.com/s/yhlgltz4he6...

Python test program : https://www.dropbox.com/s/g1f3jp4iv64...
https://www.dropbox.com/s/xuex9vd17oj...

Php test program :
https://www.dropbox.com/s/q5mbjh0dmot...

Program to run in idle to find path for shebang. Just add #! before it and double check it says python or python.exe if not just change it to the result of idle program.
https://www.dropbox.com/s/f6z0je82vo6...