1

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?

AnujAroshA
  • 4,623
  • 8
  • 56
  • 99
  • Things got much better after changing Directory path by removing the escape character and adding + mark before FollowSymLinks. Now seems server runs using XAMPP not installed/identified Python. Because when I load the link, in browser, it display me the whole Python page content. – AnujAroshA Nov 25 '14 at 13:25
  • Forget about XAMPP and used MAPP and I did able to achieve this task like a piece of cake. – AnujAroshA Dec 11 '14 at 08:26

0 Answers0