Skip to content

Setting up a server

yeealex93 edited this page Jun 1, 2012 · 11 revisions

1. Install python and git

  1. sudo apt-get install python
  2. sudo apt-get install git, git-doc, and git-core
  3. Generate an ssh key and add it to your github profile (for a walkthrough, go to your dashboard on github, go to profile -> SSH Public Keys -> Need help with public keys? )

2. Clone the dataflow project

  1. Clone the repo into the directory of your choice (we've been using /var/www/)
  2. From the main project directory, run the python install script: sudo -s python install.py
  3. Create a FILES directory to store files for reductions. In settings.py (in the main dataflow directory), update FILES_DIR to point at the FILES directory you created.
  4. Possible issues at this stage:
    • Installing psycopg2 / getting the dependencies (the install script ought to take care of this)

3. Test it out with the django development server

  1. From the main project directory, run python manage.py runserver [IPaddress:port]
  2. Run python manage.py syncdb once you have set up a database (either postgresql or sqlite3 - see settings.py)
  3. Possible issues at this stage:
    • sys.path does not have all of the necessary paths in manage.py

4. Setting up apache

  1. Check in the project's apache folder for a .wsgi file. This file needs to:

    • set the environmental variable DJANGO_SETTINGS_MODULE to PROJECT_NAME.settings
    • import django.core.handlers.wsgi
    • set up a wsgi handler object, application = django.core.handlers.wsgi.WSGIHandler()
    • possible issue: sys.path does not have all of the necessary paths.
  2. Add a dataflow site in /etc/apache2/sites-available and /etc/apache2/sites-enabled. This is a file that looks like:

    <VirtualHost *:80>
    ServerName 129.2.64.185
    
    DocumentRoot /var/www/
    Alias /static/ "/var/www/DATAFLOW/static/"
    Alias /site_media/ "/var/www/DATAFLOW/static/"
    <Directory "/var/www/DATAFLOW/static/">
    Order allow,deny
    #Options Indexes
    Allow from all
    #IndexOptions FancyIndexing
    </Directory>
    <Directory /var/www/DATAFLOW/>
    Options +FollowSymLinks +Includes +Indexes
    Order deny,allow
    Allow from all
    </Directory>
    <Directory /var/www/DATAFLOW/apps/tracks/>
    Allow from all
    </Directory>
    
    KeepAlive Off
    
    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    #LogLevel info
    
    SetEnvIf X-Forwarded-SSL on HTTPS=1
    WSGIScriptAlias / /var/www/DATAFLOW/apache/django.wsgi
    </VirtualHost>
    
  • You can simply copy this file, changing the paths to match the location of the cloned project, and changing the IP address
  1. Change the port in etc/apache2/sites-available/default to something other than 80. Alternately, set the dataflow port to something other than 80 in both sites-available and sites-enabled.
  2. Add the line ServerName [IP address] to the file /etc/apache2/httpd.conf

5. At this point, apache should be functioning

  1. Try running your server with /usr/sbin/apache2ctl start
    • The commands 'stop' and 'restart' are also available
  2. Check out the project at [IPaddress:port]
  3. If the server is not running properly, or you are getting non-apache errors (e.g., Django errors) on visiting the project site, check the error log (/var/log/apache2/error.log)