2

These are the actions that I have taken and I still can't seem to run the script on PHP on my windows 8.1 platform.

Please do note that I have installed Python and have tested it. I am running python 2.7

(1) Step 1: Edited the Apache httpd.conf scripts to run cgi .py scripts

AddHandler cgi-script .cgi .pl .asp .py

(2) Step 2: Added a test script in cgi-bin folder of xampp. It is called

    #!/Python27/python
    print "Content-type: text/plain\n\n"
    print "Hello world"

(3) Step 3: Created a PHP Code called Python.php

  $python =  exec('python C:\xampp\cgi-bin\BridgePHP.py');
  echo "Python is printing: " .  $python;

(4) I get the following output in my browser:

  Python is printing:

(5) I tested by running using the standard command prompt and the word "Hello World" was printed

I am unsure why php script is unable to run the python script. Is there any other settings that I should do?

1 Answer 1

2

I have finally figured this out:

I will have to restart the server whenever I add a new cgi script in the server. This worked.

In this case BridgePHP.py

Sign up to request clarification or add additional context in comments.

1 Comment

please share the new cgi script. I am also facing same problem. Thanks in advance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.