Pinax
Pinax is an open-source platform built on the Django Web Framework.
By integrating numerous reusable Django apps to take care of the things that many sites have in common, it lets you focus on what makes your site different.
Contents |
Setup
There are great instructions on how to install Pinax at the project home page. All the instructions on this page refer to Pinax 0.9 or later and will help you install the social site package.
Step 0: Install virtualenv and activate
Make sure you have virtualenv version 1.4.7+ installed and working. This isn't hard to get or install. Then you should activate the virtualenv before going any further.
$ virtualenv /path/to/pinax/env/pinax-env-VERSION $ source /path/to/pinax/env/pinax-env-VERSION/bin/activate
Note that virtualenv will create a new directory in the location of your choosing. The version of python that exists in that directory will probably be the system default python for Dreamhost. If you need a newer version, such as 2.6 or 2.7, you will need to download, make, and install it in your home directory.
Step 1: Django
You'll want to install Django in your virtual environment. This will keep it separate from other projects on your site and give you flexibility on the installed version. Dreamhost has a version of Django installed and supported and you are welcome to use that and skip this step entirely. Otherwise do the following:
(pinax-env)$ pip install django --upgrade
Step 2: Install Pinax and Setup Project
Download Pinax and install using the following commands to install all the required packages for Pinax.
(pinax-env)$ pip install Pinax (pinax-env)$ pinax-admin setup_project -b social ./mysite (pinax-env)$ cd ./mysite (pinax-env)$ ln -s /path/to/pinax/env/pinax-env-VERSION/bin/activate activate
The symlink is a handy way to access your virtualenv when you're working on your deployed site live.
Step 3: Install Dependencies
In this step you'll want to install a few dependencies or you'll end up with some crazy error messages.
(pinax-env)$ pip install Paste (pinax-env)$ pip install mysql-python
If you installed a new python build in your home directory you will need the mysql-python package to access any mysql databases you want to connect with. The Paste package will be what you use to catch error messages and is required for the next step.
Step 4: Create your passenger_wsgi.py
You'll need to have a passenger_wsgi.py file in your root directory. It should look almost identical to the following example. This file should be placed in the directory for your site url. DO NOT place it in your ./public or ./mysite directories. It should be in the same folder as both of those.
import sys, os
DEBUG = False
cwd = os.getcwd()
site_name = 'mysite' # THE NAME OF YOUR PROJECT
site_home = os.path.join(cwd,site_name)
pinax_env_bin = os.path.join(cwd,'pinax-env/bin') # THE RELATIVE PATH TO YOUR VIRTUALENV BIN DIRECTORY
#Check that the version of python is 2.6 or greater
#if sys.hexversion < 0x2060000:
# os.execl("/home/user/bin/python2.6", "python2.6", *sys.argv)
# Invoke the virtualenv
INTERP = '%s' % (os.path.join(pinax_env_bin,'python'))
if sys.executable != INTERP:
os.execl(INTERP, INTERP, *sys.argv)
sys.stdout = sys.stderr
sys.path.append(site_home)
sys.path.append(os.path.join(site_home,'apps'))
sys.path.append(os.path.join(cwd,'pinax-env/lib/python2.6/site-packages/pinax'))
sys.path.append(os.path.join(cwd,'pinax-env/lib/python2.6/site-packages/pinax/apps'))
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = '.'.join([site_name,"settings"])
import django.core.handlers.wsgi
from paste.exceptions.errormiddleware import ErrorMiddleware
application = django.core.handlers.wsgi.WSGIHandler()
#Define a test application to check that the ErrorMiddleware is working
def testapplication(environ, start_response):
status = '200 OK'
output = 'Hello World! Running Python version %s\n\n' % (sys.version)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
#Check that the ErrorMiddleware works by uncommenting the next line
#raise("error")
start_response(status, response_headers)
return [output]
application = ErrorMiddleware(application, debug=DEBUG)
Note: You'll want to read the articles on Passenger_WSGI and virtualenv and Passenger_WSGI 500 Error Workaround to get everything right for your setup.
Step 5: Sync and run your site
Finally you'll want to sync your databases and get your site running:
(pinax-env)$ python manage.py syncdb (pinax-env)$ pkill python
Now your new pinax project should be up and running!