Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Setting the CollectionSpace connection properties in main.cfg

     

    Code Block
    langbash
    # update hostname for CSpace server, etc.
        vi main.cfg
    
        #main.cfg
    
        [info]
        shouldReloadConfig = True
    
        [cspace_authn_connect]
        shouldReloadConfig = True
        realm              = org.collectionspace.services
        uri                = cspace-services/accounts/0/accountperms
        hostname           = pahma-dev.cspace.berkeley.edu (for example)
        protocol           = http
        port               = 8180
    
        [cspace_services_connect]
        realm             = org.collectionspace.services
        hostname          = pahma-dev.cspace.berkeley.edu (for example)
        protocol          = http
        port              = 8180
    
  • Set the WSGI mount point in wsgi.py

     

    Code Block
    langbash
    vi wsgi.py
    
        [...]
        WSGI_BASE = '/pahma_project'
        [...]
    
  • Update project-specific parameters in settings.py
    • Time zone and language
    • Static url
    • Names of your webapp(s) in INSTALLED_APPS

      Code Block
      langbash
      vi settings.py
        [...]
        # Local time zone for this installation. Choices can be found here:
        # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
        # although not all choices may be available on all operating systems.
        # In a Windows environment this must be set to your system time zone.
        TIME_ZONE = 'America/Los_Angeles'
      
        # Language code for this installation. All choices can be found here:
        # http://www.i18nguy.com/unicode/language-identifiers.html
        LANGUAGE_CODE = 'en-us'
        [...]
        STATIC_URL = '/pahma_project_static/'
        [...]
        # add webapps here, e.g. ireports...
        INSTALLED_APPS = (
          [...]
          # cspace example webapps
          'hello',
          'service',
      
          # add any webapps of your own here and in urls.py
          #'ireports',
        )
      
          [...]
      
  • Add the base urls for your webapps to urls.py

     

    Code Block
    langbash
    cd ../cspace_django_site/
    vi urls.py
    
    urlpatterns = patterns('',
              # urls for CSpace authentication and example webapps
    
              url(r'^$', 'hello.views.home', name='home'),
              url(r'^accounts/login/$', views.login, name='login'),
              url(r'^admin/', include(admin.site.urls)),
              url(r'^service/', include('service.urls')),
    
    	  # add the base urls for any wepapps of your own here and in settings.py
              # Example (without # character):
              #url(r'^ireports/', include('ireports.urls')),
               )
    
  • Create the static root folder (if necessary) and collect static files:

     

    Code Block
    langbash
    cd ../../pahma_django_project
    sudo mkdir static_root
    sudo sh -c "source ../venv26/bin/activate; python manage.py collectstatic"
    

    At the prompt, type yes to continue

  • Initialize the sqlite3 database and log files



    The CSpace authentication webapp needs this. Needs to be done for each of your projects. Note that when Django was installed on your server, the sysadmin will normally have created a project directory with a test app to verify the Django installation.

    Code Block
    langbash
    cd ../pahma_django_project
    sh -c "source ../venv26/bin/activate; python manage.py syncdb"
    
    Warning

    Ed. note - In the documentation for setting up a development environment, we suggest that users create an sqlite3 superuser: "You will see a prompt asking if you'd like to create a superuser. Choose 'yes' and select something memorable for the username and password. (This is a superuser for the Django application and can be helpful if things break.)" Should the same advice apply for a production environment?



    More documentation about manage.py.

  • set permissions



    Change to the django directory:

    Code Block
    langbash
    cd ../../django
    



    Set the following permissions:

    Code Block
    langbash
    sudo chown apache:apache *_project/db.sqlite3
    sudo chcon -t httpd_sys_rw_content_t *_project/db.sqlite3
    
    sudo chown -R apache:apache *_project
    sudo chcon -t httpd_sys_rw_content_t *_project/
    
    sudo chmod g+w *_project/db.sqlite3
    sudo chmod g+w *_project
    



    Change to the pahma_django_project directory.

    Code Block
    langbash
    cd pahma_project
    



    Continue changing permissions:

    Code Block
    langbash
    sudo chown apache:apache logs/*
    sudo chcon -t httpd_sys_rw_content_t logs/*
    
    sudo chown -R apache:apache logs
    sudo chcon -t httpd_sys_rw_content_t logs
    
    sudo chmod g+w logs/*
    sudo chmod g+w logs
    
    sudo chown -R apache:apache static_root/*
    sudo chcon -t httpd_sys_rw_content_t static_root/*
    
    sudo chown -R apache:apache static_root
    sudo chcon -t httpd_sys_rw_content_t static_root
    
    Warning

    Ed. note - Python needs to be able to write to static_root, not Apache. Are these last four lines correct? Also, sudo chown -R apache:apache logs seems to supercede sudo chown apache:apache logs/*. Do we need both?

...