I'm trying to run a simple Python script using XAMPP in my MAC. I have followed this link. Anyway I'll tell what I've done in steps.
I'm running MAC OS X 10.9.5 and I have python 2.7.5 and python 3.4.1 both installed in this machine. Also I have successfully installed XAMPP 1.8.3-5 in this machine and tested with PHP and HTML pages.
Next thing I did was creating a directory named cgi-bin in the path /Volumes/Macintosh\ HD/Applications/XAMPP/xamppfiles/htdocs/ . Inside that directory I've created file name called first.py with the content with below.
#!/usr/bin/env python
print "Content-type: text/html\n"
print "Hello, world!"
Just for testing i run this file in Terminal to make sure I get the desired print out puts.
$ python /Volumes/Macintosh\ HD/Applications/XAMPP/xamppfiles/htdocs/cgi-bin/hello.py
Yes, it runs well. Then I changed the file permission as well as directory permisson.
drwxrwxrwx 5 anuja mygroup 170 Nov 14 17:40 cgi-bin/
and
-rwxr-x--x@ 1 anuja mygroup 82 Nov 14 16:05 first.py*
Next thing was configure httpd.conf file. I load the XAMPP control panel then select Manage Services tab and select Apache Web Server and click on the Configure button. From the pop up window I clicked Open Conf File.
There I comment the following line
# ScriptAlias /cgi-bin/ "/Applications/XAMPP/xamppfiles/cgi-bin/"
Then add the following directory block
<Directory "/Volumes/Macintosh\ HD/Applications/XAMPP/htdocs/cgi-bin/">
AddHandler cgi-script .cgi .py
AllowOverride All
Options +Indexes FollowSymLinks +ExecCGI
Order allow,deny
Allow from all
</Directory>
There is a similar directory block there and I kept it as it is above the given block.
<Directory "/Applications/XAMPP/xamppfiles/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
After restarting Apache server from XAMPP panel I tried to load this it using my web browser
http://localhost/cgi-bin/first.py
Finally I ended up with "Object not found" error on the browser. I tried several changes but out of luck. How can I run this python script from the web browser I get Hello, world! as out put?