Skip to content

Configuring For Apache

swannodette edited this page Sep 13, 2010 · 10 revisions

mod_wsgi

You will need to install mod_wsgi. Once you decided where shiftspace will live, your Apache configuration file for your site will look something like this:

# change this point to where your python libraries live (site-packages/dist-packages)
WSGIPythonPath /path/to/python/site-packages

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        # where you'll be serving static files from
        DocumentRoot /var/www/static
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/static>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        # where you'll put your script that creates the ShiftSpace wsgi application
        WSGIScriptAlias /shiftspace /path/to/server.py

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

server.py should look something like the following:

import os
import server.server # load the actual ShiftSpace server.py module

ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
application = server.server.startWsgi(siteConf=os.path.join(ROOT_PATH, 'site.conf'))

You should have a site.conf file at the same level as your server.py that looks like the following:

[config]
environment: 'embedded'

Static Files

ShiftSpace needs to know where your static files will be served from. There are a couple of environment variables that you need to be aware of in order for ShiftSpace to know where to draw content from. Inside of the shiftspace/config/env directory create a JSON file called deploy.json that looks something like the following:

{
  "SERVER": "http://url/to/shiftspace/",
  "MEDIA_PATH": "http://url/to/media/",
  "IMAGES_PATH": "http://url/to/images/",
  "SPACES_PATH": "http://url/to/spaces/",
  "GLOBAL_CSS": "styles/SSGlobalStyles.css",
  "DEPLOY": true
}

Building the ShiftSpace script

Now that you have an evironment file you can build the ShiftSpace client userscript. You can do this with the following command:

python shifty.py build -e deploy -p shiftspace -o shiftspace.user.js

Depending on your server permissions you may need to run this as the superuser.

Serving Static Files

The urls don’t need to map at all the structure of the ShiftSpace directory. Note that in the Apache site configuration file above we define the document root to a directory called static. You should create symlinks from here to the following ShiftSpace directories:

  • builds
  • client
  • externals
  • images
  • spaces
  • styles

Session Permissions

Make sure that you have all of the ShiftSpace dependencies installed.

Make sure that shiftspace/server/sessions has the proper permissions so that session data can be written to that directory. If you would like sessions to be handled differently you’ll need to refer to the CherryPy sessions documentation.

chown -R www-data:www-data sessions

couchdb-lucene

It’s important that couchdb-lucene be able to write to the directory where it keeps it indexes. The best thing to do is explicitly define the path where you want the indexes to live in your couchdb local.ini configuration file:

; CouchDB Configuration Settings                                                                                                                                                                          

; Custom settings should be made in this file. They will override settings                                                                                                                                
; in default.ini, but unlike changes made to default.ini, this file won't be                                                                                                                              
; overwritten on server upgrade.                                                                                                                                                                          

[couchdb]
;max_document_size = 4294967296 ; bytes                                                                                                                                                                   
os_process_timeout=60000 ; 60 seconds for couchdb-lucene                                                                                                                                                  

[httpd]
;port = 5984                                                                                                                                                                                              
;bind_address = 127.0.0.1                                                                                                                                                                                 

[log]
;level = debug                                                                                                                                                                                            

[update_notification]                                                                                                                                            
indexer=/path/to/java -Dcouchdb.lucene.dir=/path/to/indexes -jar /path/to/couchdb-lucene-0.4-jar-with-dependencies.jar -index

; To create an admin account uncomment the '[admins]' section below and add a                                                                                                                             
; line in the format 'username = password'. When you next start CouchDB, it                                                                                                                               
; will change the password to a hash (so that your passwords don't linger                                                                                                                                 
; around in plain-text files). You can add more admin accounts with more                                                                                                                                  
; 'username = password' lines. Don't forget to restart CouchDB after                                                                                                                                      
; changing this.                                                                                                                                                                                          
;[admins]                                                                                                                                                                                                 
;admin = mysecretpassword                                                                                                                                                                                 

[external]
; CHANGE THIS LINE, username should be set to your username                                                                                                                                               
fti=/path/to/java -Dcouchdb.lucene.dir=/path/to/indexes -jar /path/to/couchdb-lucene-0.4-jar-with-dependencies.jar -search

[httpd_db_handlers]
_fti={couch_httpd_external, handle_external_req, <<"fti">>}

And make sure couchdb can write to the indexes directory:

chown -R couchdb:couchdb /path/to/indexes
chmod -R 0770 /path/to/indexes

Testing it out

Since you made the static files in builds available via symlink, you should be able to point FireFox to http://yourserver/builds/shiftspace.user.js. Make sure GreaseMonkey is enabled so you can install the userscript. Go to any old page on the web. Press the shiftspace+space key combination and you should see the console open up. Use the Login tab to register a new user. You be logged in automatically upon creating the user.

Create a note shift and save it.

Refresh the page. You should still be logged in and if you open the console you should see your shift.

Troubleshooting

Trouble shooting information will go here.