Step by Step (in progress) - kstrack-grose/Git-Project GitHub Wiki
-
We're working on computers running Ubuntu, with Python 2.7 and Apache2. We're also working exclusively within root.
-
Download WSGI.
-
Add these lines to your Apache configuration file (which can be found at "/etc/apache2/apache2.conf"):
AliasMatch /([^/]*\.css) /var/www/reposaurus/static/styles.css #or wherever your css file is Alias /media/ /var/www/reposaurus/static/media/ #or wherever your media directory is Alias /favicon.ico /var/www/reposaurus/static/media/favicon.xcf #or wherever your favicon is WSGIScriptAlias /reposaurus /var/www/reposaurus/wsgifiles/dinopark4kiri.wsgi #the first parameter here is the alias you wish to operate under #the second is the direct path to the wsgi file WSGIScriptAlias /showfiles /var/www/reposaurus/wsgifiles/dinofile.wsgi #same thing, for a second file (optional! Or have three! Or fourteen! Go crazy!) #directory the wsgi files are in Order allow,deny Allow from all
Remember to restart Apache after you edit the config file: while in "/etc/apache2", enter "service apache2 restart" into the command line.
-
Make a WSGI file in the directory stated above. This directory does have to be in "/var/www", but after that, it doesn't matter.
-
For making WSGI files, see the Bundle, or the WSGI directory, for ideas and suggestions. You can also look on the WSGI page of the wiki here. A very basic program looks like this:
def application(environ, start_response): output = "Hello World" start_response('200 OK', [('Content-type', 'text/html')]) return output
-
Play around! Learn things! You can create forms to submit text, files, passwords--between WSGI and cgi, a lot of tools are already at your disposal.
-
If you are uploading any files, Apache will need a directory within /var/www/wsgifiles (or whatever you name it) to call its own. Create a directory and then chown it by entering this into the command line: "chown www-data ". www-data is basically Apache's username on Ubuntu.
-
Add in HTML by appending the contents of the HTML file to a list that the WSGI file returns. Make sure the paths for your HTML files, images, CSS files, and WSGI are all correct and are correctly referenced in the Apache2 configuration file.