Skip to content

Instantly share code, notes, and snippets.

@gau1991
Last active August 29, 2015 14:13
Show Gist options
  • Save gau1991/6a95684698aaea79654e to your computer and use it in GitHub Desktop.
Save gau1991/6a95684698aaea79654e to your computer and use it in GitHub Desktop.
Installation Moztrap Test Suite with Nginx

Mozstrap Installation instruction: Tested on Ubuntu 12.04 and 14.04 with Nginx installed

  1. Install Dependencies:
apt-get update
apt-get install git mysql-server libmysqlclient-dev python-pip python-dev
  1. Clone moztrap:
git clone --recursive git://github.com/mozilla/moztrap
  1. Install virtualenvwrapper:
pip install virtualenvwrapper
  1. Install Moztrap dependencies:
cd moztrap
source "/usr/local/bin/virtualenvwrapper.sh"
bin/install-reqs
  1. Create Database:
mysql -e "CREATE DATABASE moztrap CHARACTER SET utf8"
mysql -e "grant all privileges on moztrap.* to moztrap@localhost IDENTIFIED BY 'password'"

Note: Replace password with your password for moztrap database

  1. Set the Moztrap settings:
cp moztrap/settings/local.sample.py moztrap/settings/local.py
vim moztrap/settings/local.py
  1. Setup database:
./manage.py syncdb --migrate
./manage.py create_default_roles
  1. Setup Nginx configuration:
vim /etc/nginx/sites-available/moztrap

and copy following settings:

upstream moztrap {
  server 127.0.0.1:8000;
}

server {
  # listen 80 default_server;
  server_name moztrap.rtcamp.net;

  access_log  /var/log/nginx/moztrap_access.log;
  error_log   /var/log/nginx/moztrap_error.log;
 
  root /root/moztrap;

  location / {
    try_files $uri $uri/index.html $uri.html @moztrap;
  }

  location @moztrap {
    proxy_read_timeout 300;
    proxy_connect_timeout 300;
    proxy_redirect     off; 

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;

    proxy_pass http://moztrap;
  }
}

Activate site configuration and reload Nginx

ln -s /etc/nginx/sites-available/moztrap /etc/nginx/sites-enabled/moztrap
service nginx reload
  1. Start Moztrap server:
nohup ./manage.py runserver > /dev/null &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment