Page 1 of 2 | 1 | 2 | > | >> | All |
Posted By: tidus on November 23, 2012, 5:42 am | Post: 1 |
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 |
Posted By: memzxi on December 26, 2012, 8:04 pm | Post: 2 |
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 ) |
Posted By: tidus on December 27, 2012, 7:46 am | Post: 3 |
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 Code "C:\Program Files\Ampps\www\wsgi-scripts" Change Code WSGIScriptAlias /myapp /usr/local/www/wsgi-scripts/myapp.wsgi 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 |
Posted By: tidus on December 27, 2012, 1:23 pm | Post: 5 |
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 |
Posted By: tidus on December 27, 2012, 2:22 pm | Post: 7 |
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" 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 Code AddHandler cgi-script .cgi .pl .py 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 |
Posted By: memzxi on December 30, 2012, 9:23 pm | Post: 8 |
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 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 ? |
Posted By: tidus on December 31, 2012, 7:46 am | Post: 9 |
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 |
Posted By: tidus on January 15, 2013, 5:09 am | Post: 11 |
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 |
Posted By: tidus on January 15, 2013, 5:41 am | Post: 12 |
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 |
Posted By: tidus on January 21, 2013, 5:39 pm | Post: 14 |
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 |
Posted By: tidus on January 21, 2013, 6:30 pm | Post: 16 |
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 |
Posted By: tidus on January 21, 2013, 6:36 pm | Post: 18 |
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 |
Posted By: chrisjensen23 on March 26, 2014, 4:07 pm | Post: 19 |
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 ) |
Posted By: tidus on July 23, 2014, 7:27 am | Post: 21 |
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 |
Posted By: Akirami on December 8, 2014, 12:09 pm | Post: 23 |
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. |
Posted By: KenScape on August 27, 2016, 8:05 pm | Post: 25 |
Perd01: I wonder what that does |