How to make Laragon/apache run python scripts?


  • | 189 points

    Hi,

    So I installed Laragon Lite on windows 10 and added python 3.6.
    The problem is when I run a basic .py script it doesnt work. It shows me the content of the file instead
    #!bin\python\python-3.6.1
    print("hello laragon")

    I added to httpd.conf the following line
    AddHandler cgi-script .py
    But I receive this message
    *Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    I tried others paths instead of bin\python\python-3.6.1 but I still receive the same error message

    I guess there is a way to tell apache where to find the python interpreter to run .py scripts but I can't figure it out.

    Thanks for your help


  • | 189 points

    Does anyone have an answer to this issue please?


  • | 74 points

    After I added the AddHandler in httpd.conf (as you described) it worked for me!
    This is my example .py file:

    #!C:\laragon\bin\python\python-3.6.1\python.exe
    print("content-type: text/html\n\n" )
    print("<br><B>hello python</B>")

    I guess the initial link to the python exe is missing in your case.

    My .py file is in the www folder.


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.