Sunday, July 11, 2010

Kates Playground Harcore Vids

Flask on Mac OS X install, test 10.6 and

I wanted to try finally mod_wsgi to develop Python web applications on my Mac Mini. Installation of mod_wsgi using MacPorts proved to be very simple. The subsequent need to configure Apache2
is expensive enough, so here I sometimes like to describe in detail:
0th under System Preferences / Sharing the Web share disable the turn off Apple's Mac OS X included Apache 2 server.
first Installation of mod_wsgi with MacPorts: > sudo port install mod_wsgi If not available, Apache2 is installed in this process.

second Starting and Testing Apache:
> sudo / opt/local/apache2/bin/apachectl k-star t After starting Apache you can
http://localhost
open the browser. It should be "It works!" are shown.
third Apache start automatically at system startup:
> sudo launchctl load-w / Library/LaunchDaemons/org.macports.apache2.plist

4th Activation of the user directories so that web pages are the user name under
http://localhost/ ~ / Sites
be displayed: This requires the line

in the file
/ opt/local/apache2/conf/httpd.conf be uncommented
. Then in the file

/ opt/local/apache2/conf/extra/httpd-userdir.conf
the lines
# # Include user configurations
#
Include / private/etc/apache2/users / *. conf
add. Must then be restarted Apache2:
> sudo / opt/local/apache2/bin/apachectl-k restart
(Also see How to get a Apache, PHP, MySQL (MAMP) setup
.)
5th Activation of the mod_wsgi module for Apache2: be given must be added the line LoadModule
wsgi_module modules / mod_wsgi.so
to the file
/ opt/local/apache2/conf/httpd.conf
. Then restart Apache.
6th Create a
wsgi
applications:
To test you can first create the following simple
wsgi application:
> pico hello.wsgi
import sys def
application (environ, start_response) !

status = '200 OK 'output
=' Hello World \\ n '
output + = str (sys.path)
response_headers = [('Content-type', 'text / plain'),
('Content-Length', str (len (output)))]
start_response (status, response_headers)
return [output]
you are
"Hello World!"
back and in addition the system path under which examines the wsgi module for Python modules (See also mod_wsgi - Quick Configuration Guide ).

7th Setting up a Virtual Host
for
wsgi applications: For this, the line

Include conf / extra / httpd-vhosts.conf
in the file
/ opt/local/apache2/conf/httpd.conf be uncommented

. In the file the lines
\u0026lt;VirtualHost *:80>
ServerName www.mydomain.org
ServerAlias mydomain.org
ServerAlias my. dyndns.org
ServerAdmin webmaster@mydomain.org
WSGIScriptAlias / / Users / username / Sites / webapp / hello.wsgi
WSGIScriptReloading On
\u0026lt;Directory /Users/username/Sites/webapp>
Order allow, deny Allow from

all \u0026lt;/ Directory>
\u0026lt;/ VirtualHost>

insert. It is
mydomain.org for the domain name, my.dyndns.org
for there may
dynamic DNS - entry. (How to use Virtual Hosts can do better with DynDNS is at Virtual hosts and DynDNS combine it
. The Wildcard feature mentioned there, however, costs $ 15 a year).
WSGIScriptAlias indicates that the root address "/"
the virtual server the
wsgi application hello.wsgi
in the directory / Users / username / Sites / webapp
calls. During development, it makes sense
WSGIScriptReloading activate, so you do not need to restart for every change of the wsgi application to the Apache server. More in mod_wsgi - Quick Configuration Guide . be restarted after configuring the virtual hosts, the Apache server again. However, given the work Domain name yet. To do this yet in the file / private / etc / hosts the lines 127.0.0.1 mydomain.org
127.0.0.1 www.mydomain.org be added (See Creating a virtual host in Mac OS X 10.5 ).
8th Calling http://mydomain.org or
http://www.mydomain.org with the browser:
If all went well you should now
"Hello World!" see in the browser, including the Python system path.

0 comments:

Post a Comment