---
title: "Pyramid Quickstart"
date: "2015-03-18"
category: "python"
slug: "pyramid-quickstart"
---

## Overview

[Pyramid](http://www.pylonsproject.org/) is a Python web framework and the spiritual successor to Pylons and Zope. Pyramid is supported on [[determining-platform-version]] using [[changing-python-versions]] 2.7+ with [[passenger-supported-apps]].

## Quickstart

All commands are run from the [[accessing-terminal]].

1. **Prerequisite:** Create a [[passenger-application-layout]] filesystem layout:
    - cd /var/www && mkdir -p pyramid/{tmp,public}
        
2. **Optional:** Select a Python version using [[changing-python-versions]]:
    - cd pyramid && pyenv local 3.3.5
        
3. Install Pyramid:
    - pip install pyramid --no-use-wheel
        
4. Create a startup file named `passenger_wsgi.py`. This is a simple "Hello World" application with routing:
    
    from wsgiref.simple\_server import make\_server
    from pyramid.config import Configurator
    from pyramid.response import Response
    
    def hello\_world(request):
     return Response('Hello %(name)s!' % request.matchdict)
    
    config = Configurator()
    config.add\_route('hello', '/hello/{name}')
    config.add\_view(hello\_world, route\_name='hello')
    application = config.make\_wsgi\_app()
    
    if \_\_name\_\_ == '\_\_main\_\_':
     server = make\_server('0.0.0.0', 8080, app)
     server.serve\_forever()
    
5. Connect `public/` to a [[creating-subdomain]].
6. Tell Passenger to serve this as a Python application:
    - echo "PassengerPython /.socket/python/shims/python" > public/.htaccess
        
7. Access your Pyramid application.

## Viewing Launcher Errors

If the application fails to launch, check `passenger.log`. See [[viewing-launcher-errors]].

## Restarting

Use the standard [[restarting-passenger-processes]] method to restart the application.

## See Also

- Pyramid [documentation](http://docs.pylonsproject.org/projects/pyramid/en/latest/)
- [Django vs Flask vs Pyramid](https://www.airpair.com/python/posts/django-flask-pyramid)
- [Demo](http://pyramid.sandbox.apnscp.com/hello/foo) running on Sol, a v6 platform
