Welcome Guest. Please Login or Register  


You are here: Index > AMPPS > General Support > Topic : I can't run python scripts

1


Threaded Mode | Print  

 I can't run python scripts (25 Replies, Read 41420 times)
muotaz
Group: Member
Post Group: Newbie
Posts: 1
Status:
Hello All;

I am a bit new to AMPPS and Python Development.
I tried to run Python scripts on AMPPS with no luck.
Any help or hints are highly appreciated.

IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

For running python scripts you must first get familiar with mod_wsgi. Here is the tutorial to run the python scripts using mod_wsgi.

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
Hi. Another newbie here. I thank you for your work creating the product and giving it for free, but after that much work, is it that hard to make Python run by default ?

If I want to run php, I put test.php file in www directory and it works fine. I put test.py and it shows unprocessed source code, the same as it would if I opened it in a browser without AIMPS installed.

Can you just say which file to put where in order for it to work ?

I read quick configuration guide that you posted a link to, but it doesn't seem to help properly.

What I did is put the code below in C:\Program Files\Ampps\apache\conf\httpd.conf in line 634 after << # Python
Include "C:/Program Files/Ampps/python/python.conf" >>

Quote
<VirtualHost *:80>

    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot /usr/local/www/documents

    <Directory /usr/local/www/documents>
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

    <Directory /usr/local/www/wsgi-scripts>
    Order allow,deny
    Allow from all
    </Directory>

</VirtualHost>


After that, I created the file

C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi and put the code below in it. the code is from that "quick" configuration guide

Quote

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


Then I restarted apache, tried to access
http://localhost/documents/test.py
http://localhost/test.py
http://localhost/wsgi-scripts/test.py

none worked, help ? ( AMPPS installation is fresh, nothing modified )
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Quote From : memzxi December 26, 2012, 8:04 pm
Hi. Another newbie here. I thank you for your work creating the product and giving it for free, but after that much work, is it that hard to make Python run by default ?

If I want to run php, I put test.php file in www directory and it works fine. I put test.py and it shows unprocessed source code, the same as it would if I opened it in a browser without AIMPS installed.

Can you just say which file to put where in order for it to work ?

I read quick configuration guide that you posted a link to, but it doesn't seem to help properly.

What I did is put the code below in C:\Program Files\Ampps\apache\conf\httpd.conf in line 634 after << # Python
Include "C:/Program Files/Ampps/python/python.conf" >>

Quote
<VirtualHost *:80>

    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot /usr/local/www/documents

    <Directory /usr/local/www/documents>
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

    <Directory /usr/local/www/wsgi-scripts>
    Order allow,deny
    Allow from all
    </Directory>

</VirtualHost>


After that, I created the file

C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi and put the code below in it. the code is from that "quick" configuration guide

Quote

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


Then I restarted apache, tried to access
http://localhost/documents/test.py
http://localhost/test.py
http://localhost/wsgi-scripts/test.py

none worked, help ? ( AMPPS installation is fresh, nothing modified )


Hi,

Your VirtualHost is wrongly configured, you will have to change(take care of) the paths.
i.e change all
Code
/usr/local/www/documents
to
Code
"C:\Program Files\Ampps\www\wsgi-scripts"
(Yes, with double quotes).

Change 
Code
WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi
to
Code
WSGIScriptAlias /myapp "C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi"


And Remove This Tag
Code
<Directory /usr/local/www/wsgi-scripts>
    Order allow,deny
    Allow from all
    </Directory>


Restart Apache.

And try accessing http://localhost/myapp

Let us know the output.

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
Didn't work. Ended up with this code in C:\Program Files\Ampps\apache\conf\httpd.conf

Quote

<VirtualHost *:80>

    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot "C:\Program Files\Ampps\www\wsgi-scripts"

    <Directory "C:\Program Files\Ampps\www\wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi"

</VirtualHost>


What I get is the same as I put in code editor
Quote

#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"

IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Quote From : memzxi December 26, 2012, 8:04 pm

After that, I created the file

C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi and put the code below in it. the code is from that "quick" configuration guide

Quote

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]



Hi,

The contents were right before which you copied from "quick" configuration guide.

Edited by tidus : December 27, 2012, 1:23 pm

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
Didn't understand what you meant here.

This is my test.py which is in C:\Program Files\Ampps\www\myapp\test.py and I get the same text if open the browser at localhost/myapp/test.py
Quote
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"



Content of C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi is the same, I didn't changed it after first creating the file and pasting the code
Quote
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Quote From : memzxi December 27, 2012, 1:57 pm
Didn't understand what you meant here.

This is my test.py which is in C:\Program Files\Ampps\www\myapp\test.py and I get the same text if open the browser at localhost/myapp/test.py
Quote
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"



Content of C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi is the same, I didn't changed it after first creating the file and pasting the code
Quote
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]



What is the output of http://localhost/myapp ?

BTW Python scripts doesn't work like PHP here.

In virtualhost when we configure
Code
WSGIScriptAlias /myapp "C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi"
http://localhost/myapp becomes the alias to myapp.wsgi. Hope you get it now. :)

Also the below code won't work... here you here using directly the CGI(not mod_wsgi). :)

Instead of below code,
Code
#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"


write the following code.
Code
#!"C:\Program Files\Ampps\python\python.exe"
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"


Before you run test.py, Go to AMPPS Application -> Apache Tab -> Configuration Tab. Find Line
Code
AddHandler cgi-script .cgi .pl
change it to
Code
AddHandler cgi-script .cgi .pl .py
Save the File. Restart Apache.
Copy test.py and paste it to C:\Program Files\Ampps\www\cgi-bin\test.py and
access http://localhost/cgi-bin/test.py

Edited by tidus : December 27, 2012, 2:23 pm

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
I installed AMPPS freshly just in case.

1. In folder C:\Program Files\Ampps\www created new folder "wsgi-scripts"
2. in newly created folder C:\Program Files\Ampps\www\wsgi-scripts created file "myapp.wsgi" contents below

Code

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


3. Opened the file C:\Program Files\Ampps\apache\conf\httpd.conf
4. In file C:\Program Files\Ampps\apache\conf\httpd.conf line 637 pasted the code

Code

<VirtualHost *:80>
    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot "C:\Program Files\Ampps\www\wsgi-scripts"

    <Directory "C:\Program Files\Ampps\www\wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi"

</VirtualHost>


5. In folder C:\Program Files\Ampps\www created new folder "myapp"
6. In folder C:\Program Files\Ampps\www\myapp put file test.py contents below

Code

#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"


7. Open in browser http://localhost/myapp/test.py screenshot below, just the code I put in file

Board Image

No sign of working so I'm trying CGI method.

STRANGE THING HAPPENED.

As you said
Quote
Go to AMPPS Application -> Apache Tab -> Configuration Tab. Find Line


I went there to search for a line, scrolled down and saw there went my code there which I put to C:\Program Files\Ampps\apache\conf\httpd.conf I guess that's some other file. So I pasted the code here hoping it would work, restarted apache, unfortunately the output is the same as in screenshot.

Continuing to try with CGI method.

Quote
Before you run test.py, Go to AMPPS Application -> Apache Tab -> Configuration Tab. Find Line
Code
AddHandler cgi-script .cgi .pl

change it to
Code
AddHandler cgi-script .cgi .pl .py

Save the File. Restart Apache.

Copy test.py and paste it to C:\Program Files\Ampps\www\cgi-bin\test.py and

access http://localhost/cgi-bin/test.py




It worked! Thanks a bunch!

Still wondering why WSGI method didn't work. Besides, what is the differences between the two ?

IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

To start scripting with mod_wsgi :

Quote
1. In folder C:\Program Files\Ampps\www created new folder "wsgi-scripts"

2. in newly created folder C:\Program Files\Ampps\www\wsgi-scripts created file "myapp.wsgi" contents below

Code

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


3. Opened the file C:\Program Files\Ampps\apache\conf\httpd.conf
4. In file C:\Program Files\Ampps\apache\conf\httpd.conf line 637 pasted the code

Code

<VirtualHost *:80>
    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot "C:\Program Files\Ampps\www\wsgi-scripts"

    <Directory "C:\Program Files\Ampps\www\wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi"

</VirtualHost>


Till step 4, you are correct.

Quote
5. In folder C:\Program Files\Ampps\www created new folder "myapp"
6. In folder C:\Program Files\Ampps\www\myapp put file test.py contents below

Code

#!/usr/bin/python
print "Content-type: text/html\n\n"
print "Hello World from PythonStandard Hello World from a Python"


5th & 6th step is not needed.

Quote
7. Open in browser http://localhost/myapp/test.py screenshot below, just the code I put in file


Instead of accessing http://localhost/myapp/test.py just access http://localhost/myapp

Because now your wsgi script is mounted at /myapp.

Quote
Still wondering why WSGI method didn't work. Besides, what is the differences between the two ?


There are actually many ways run python on web. This link can explain properly about it. http://docs.python.org/2/howto/webservers.html

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
I thought CGI will be enough, but I want to work with Django, so still I will need to set up WSGI.

tidus, I looked at your last message, repeated steps 1-4 ant tried to access localhost/myapp and it doesn't work. Have you tested it yourself ? Because I have multiple times with fresh installs of ampps 1.9 and couldn't get it working.

I know there are many methods to run python, but I only need one working WSGI.
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

Copy the following contents in Ampps/conf/python.conf and Save.:

Code
LoadModule wsgi_module modules/mod_wsgi.so
DirectoryIndex  index.wsgi default.wsgi index.py default.py
WSGIPythonPath "C:/Program Files/AMPPS/python/Lib;C:/Program Files/AMPPS/python/Lib/site-packages;C:/Program Files/AMPPS/python/DLLs"
WSGIPythonHome "C:/Program Files/AMPPS/python"


Try running the same script again.

Edited by tidus : January 15, 2013, 5:11 am

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

To install Django you can follow their doc :
https://docs.djangoproject.com/en/1.4/topics/install/

mod_wsgi module is already loaded in AMPPS which is required by Django.

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
Quote From : tidus January 15, 2013, 5:09 am
Hi,

Copy the following contents in Ampps/conf/python.conf and Save.:

Code
LoadModule wsgi_module modules/mod_wsgi.so
DirectoryIndex  index.wsgi default.wsgi index.py default.py
WSGIPythonPath "C:/Program Files/AMPPS/python/Lib;C:/Program Files/AMPPS/python/Lib/site-packages;C:/Program Files/AMPPS/python/DLLs"
WSGIPythonHome "C:/Program Files/AMPPS/python"


Try running the same script again.


Nope, still doesn't work.

Quote
Not Found

The requested URL /myapp was not found on this server.


I think the problem might be because of placing wsgi-scripts in www. I tried to place instead in C:\Program Files\Ampps\wsgi-scripts but it didn't help either
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

And did you try the Django docs ?

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
It's not about django, I can't even print a line with python. I was able to run django by it's own runserver, but I guess I will change to php for my project instead of python as it's pain in the ass.
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

Just checked it again. Its working fine i.e I am able to print Hello World.
I refered http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
memzxi
Group: Member
Post Group: Newbie
Posts: 8
Status:
Hmz, maybe I was doing something wrong. If you have some spare time consider making a video, just recording your screen while you install ampps and doing the things until hello world is printed. It would help a lot for newbies like me. I don't need it now as I decided to go with php with this project, but I might come back to check python
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Quote From : memzxi January 21, 2013, 6:35 pm
Hmz, maybe I was doing something wrong. If you have some spare time consider making a video, just recording your screen while you install ampps and doing the things until hello world is printed. It would help a lot for newbies like me. I don't need it now as I decided to go with php with this project, but I might come back to check python


Yes. Sure.

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
chrisjensen23
Group: Member
Post Group: Newbie
Posts: 1
Status:
OK, so I got it working on my mac and thought I would share what I did to get it to work.  I followed most of what was in this thread, but with some modifications:

1- Install Ampps

2 - make a folder in your Ampps installation folder, in my case it was here:
    /Applications/AMPPS/www/wsgi-scripts

3 - In the httpd.conf file found here:
    /Applications/AMPPS/conf

configure Apache to allow WSGI scripts, I added the following lines to the virtualhost portion of the httpd.conf

Code
<Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"


So the whole virtualhost tag looked like this:
Code
<VirtualHost 127.0.0.1:80>
<Directory "/Applications/AMPPS/www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
    </Directory>
    ServerName localhost
    ServerAlias localhost 127.0.0.1
    ScriptAlias /cgi-bin/ "/Applications/AMPPS/www/cgi-bin/"
    DocumentRoot "/Applications/AMPPS/www"
    ErrorLog "/Applications/AMPPS/apache/logs/error_log"
    CustomLog "/Applications/AMPPS/apache/logs/access.log" combined
   
    <Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"
   
</VirtualHost>


4 - Edit the python.conf file, located here:
    /Applications/AMPPS/conf

to look like this:
Code
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule wsgi_module>
DirectoryIndex index.wsgi default.wsgi index.py default.py
</IfModule>
WSGIPythonPath "/Applications/AMPPS/python/Lib;/Applications/AMPPS/python/Lib/site-packages;/Applications/AMPPS/python/DLLs"
WSGIPythonHome "/Applications/AMPPS/python"


5-Make a test WSGI application and save it as myapp.wsgi so it should reside in the following folder:
    /Applications/AMPPS/www/wsgi-scripts/

Paste the following code into the myapp.wsgi file that you created:
Code
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


6 - Restart Apache in Ampps (if it is already open) or Start it for the first time.

7 - load your python test app at http://localhost/myapp

That should do it! 

Quote From : memzxi December 26, 2012, 8:04 pm
Hi. Another newbie here. I thank you for your work creating the product and giving it for free, but after that much work, is it that hard to make Python run by default ?

If I want to run php, I put test.php file in www directory and it works fine. I put test.py and it shows unprocessed source code, the same as it would if I opened it in a browser without AIMPS installed.

Can you just say which file to put where in order for it to work ?

I read quick configuration guide that you posted a link to, but it doesn't seem to help properly.

What I did is put the code below in C:\Program Files\Ampps\apache\conf\httpd.conf in line 634 after << # Python
Include "C:/Program Files/Ampps/python/python.conf" >>

Quote
<VirtualHost *:80>

    ServerName localhost
    ServerAlias 127.0.0.1
    ServerAdmin webmaster@example.com

    DocumentRoot /usr/local/www/documents

    <Directory /usr/local/www/documents>
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi

    <Directory /usr/local/www/wsgi-scripts>
    Order allow,deny
    Allow from all
    </Directory>

</VirtualHost>


After that, I created the file

C:\Program Files\Ampps\www\wsgi-scripts\myapp.wsgi and put the code below in it. the code is from that "quick" configuration guide

Quote

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


Then I restarted apache, tried to access
http://localhost/documents/test.py
http://localhost/test.py
http://localhost/wsgi-scripts/test.py

none worked, help ? ( AMPPS installation is fresh, nothing modified )
IP: --   

I can't run python scripts
chiffenok
Group: Member
Post Group: Newbie
Posts: 1
Status:
Hi, everybody. Finally I configured Ampps like it's written in the post 19 but what should I do to run simple script in Browser like this test.py:
Code

#!/usr/local/ampps/python/bin/python
# -*- coding: UTF-8 -*-

# enable debugging
import cgitb
cgitb.enable()

print "Content-Type: text/plain;charset=utf-8"
print

print "Hello World!"

On which folder should I put this file ? wsgi-scripts? Which address should I print in browser ?
Linux, Ampps 2.4
IP: --   

I can't run python scripts
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Hi,

The folder will be /usr/local/ampps/www/cgi-bin and keep the file extension .cgi


-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

I can't run python scripts
shovan
Group: Member
Post Group: Newbie
Posts: 7
Status:
I followed instruction in post 19 & 20. I followed your instruction but I get following error

Code

Internal Server Error

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

Please contact the server administrator at admin@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.


Quote From : tidus July 23, 2014, 7:27 am
Hi,

The folder will be /usr/local/ampps/www/cgi-bin and keep the file extension .cgi
IP: --   

I can't run python scripts
Akirami
Group: Member
Post Group: Newbie
Posts: 1
Status:
Quote From : chrisjensen23 March 26, 2014, 4:07 pm
OK, so I got it working on my mac and thought I would share what I did to get it to work.  I followed most of what was in this thread, but with some modifications:

1- Install Ampps

2 - make a folder in your Ampps installation folder, in my case it was here:
    /Applications/AMPPS/www/wsgi-scripts

3 - In the httpd.conf file found here:
    /Applications/AMPPS/conf

configure Apache to allow WSGI scripts, I added the following lines to the virtualhost portion of the httpd.conf

Code
<Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"


So the whole virtualhost tag looked like this:
Code
<VirtualHost 127.0.0.1:80>
<Directory "/Applications/AMPPS/www">
    Options FollowSymLinks Indexes
    AllowOverride All
    Order deny,allow
    allow from All
    </Directory>
    ServerName localhost
    ServerAlias localhost 127.0.0.1
    ScriptAlias /cgi-bin/ "/Applications/AMPPS/www/cgi-bin/"
    DocumentRoot "/Applications/AMPPS/www"
    ErrorLog "/Applications/AMPPS/apache/logs/error_log"
    CustomLog "/Applications/AMPPS/apache/logs/access.log" combined
   
    <Directory "/Applications/AMPPS/www/wsgi-scripts">
    Order allow,deny
    Allow from all
    </Directory>

    WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"
   
</VirtualHost>


4 - Edit the python.conf file, located here:
    /Applications/AMPPS/conf

to look like this:
Code
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule wsgi_module>
DirectoryIndex index.wsgi default.wsgi index.py default.py
</IfModule>
WSGIPythonPath "/Applications/AMPPS/python/Lib;/Applications/AMPPS/python/Lib/site-packages;/Applications/AMPPS/python/DLLs"
WSGIPythonHome "/Applications/AMPPS/python"


5-Make a test WSGI application and save it as myapp.wsgi so it should reside in the following folder:
    /Applications/AMPPS/www/wsgi-scripts/

Paste the following code into the myapp.wsgi file that you created:
Code
def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]


6 - Restart Apache in Ampps (if it is already open) or Start it for the first time.

7 - load your python test app at http://localhost/myapp

That should do it! 


Hi there,

After 2 days, i succeded run mod_wsgi whit AMPPS (OS X Yosemite).

The only thing i make is that change:

Code

<VirtualHost 127.0.0.1:80>


to
Code

*:80


and

Quote
ServerAlias localhost 127.0.0.1

to
Code
ServerAlias localhost *


And the whole Virtualhost (httpd.conf):
Quote

<VirtualHost *:80>
<Directory "/Applications/AMPPS/www">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName localhost
ServerAlias localhost *
ScriptAlias /cgi-bin/ "/Applications/AMPPS/www/cgi-bin/"
DocumentRoot "/Applications/AMPPS/www"
ErrorLog "/Applications/AMPPS/apache/logs/error_log"
CustomLog "/Applications/AMPPS/apache/logs/access.log" combined

<Directory "/Applications/AMPPS/www/wsgi-scripts">
Order allow,deny
Allow from all
</Directory>

WSGIScriptAlias /myapp "/Applications/AMPPS/www/wsgi-scripts/myapp.wsgi"
 
</VirtualHost>


Hope it can help someone else.
IP: --   

I can't run python scripts
Perd01
Group: Member
Post Group: Newbie
Posts: 1
Status:
This thread gave me a lot of info to configure AMMPS. However I couldn't get it to work with WSGI until I discovered after checking the error log that the myapp script had to be changed slightly (add b in front of "Hello World"). Than it worked, at least for me....

def application(environ, start_response):
    status = '200 OK'
    output = b'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

IP: --   

I can't run python scripts
KenScape
Group: Member
Post Group: Newbie
Posts: 5
Status:
Perd01: I wonder what that does
IP: --   

« Previous    Next »

Threaded Mode | Print  

1


Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is April 27, 2024, 10:25 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.031