Fuller Deployment Instructions?

292 views
Skip to first unread message

Dan Caseley

unread,
May 24, 2013, 11:50:24 AM5/24/13
to moz...@googlegroups.com
I'm trying to install MozTrap on an AWS box for our company, but I'm struggling with the "Deployment" instructions.

I picked Ubuntu Server, as I'm plentifully comfortable with apt-get.
I was able to clone the git repo, run the install-reqs, the syncdb, the runserver. Being a text-only server, I couldn't test the output of "manage.py runserver" - that it ran was a good sign. From there, I needed to sort the apache / alternative to host the WSGI. This is where I fell down. I chose apache because it's the one I had most experience with. The django layer between the two is causing problems. The apache server serves an HTTP/500 and the apache log says it can't find the django dependency in the WSGI file.

Are there any more detailed instructions after the build?

Here's a pretty-much blow for blow of what I did from a clean Ubuntu 12.04.


sudo apt-get update
sudo apt-get upgrade
sudo apt-get install mysql-server php5-mysql libmysqlclient-dev python2.7-dev build-essential git


sudo python distribute_setup.py
sudo sh setuptools-0.6c11-py2.7.egg
sudo python get-pip.py

sudo pip install virtualenv
sudo pip install virtualenvwrapper

export WORKON_HOME=~/Envs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh

git clone --recursive git://github.com/mozilla/moztrap
cd moztrap
git checkout 1.4.7
mkvirtualenv moztrap
bin/install-reqs

mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO ubuntu@localhost;
exit

echo "CREATE DATABASE moztrap CHARACTER SET utf8" | mysql
./manage.py syncdb --migrate
./manage.py create_default_roles
./manage.py runserver

sudo apt-get install apache2
sudo apt-get install libapache2-mod-wsgi

#Run a2dissite to remove the 000-default apache site
#Create a new sites-available file, pointing at the WSGI
#Run a2ensite on the file to get the site up

Dan Caseley

unread,
May 26, 2013, 4:27:39 PM5/26/13
to moz...@googlegroups.com
After spending a while trying & failing with this, I threw the box away and started over using this guide:
This flows nicely, but runs aground due to limited info towards the end.

I fixed it though, and I'm replying to my own post in hopes that it helps a Googler of the future.

These are the steps I took from a clean launch of the Ubuntu Server 12.04 AMI to working system.
The only thing that went vaguely wrong was the bin/install-reqs - running it as sudo didn't give the current user the rights over certain things. Running it without sudo failed the first time round. I've left the non-sudo version in, but in real life, I ran it first with sudo, then without. It works, but it's ugly. I'm hoping someone else can fix it.
Stuff between +++'s are manual instructions. Stuff between ==='s are copy-n-pastes. The rest should be plain runnable.


sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo reboot

sudo apt-get install mysql-server php5-mysql libmysqlclient-dev python2.7-dev build-essential git python-setuptools nginx python-dev

sudo easy_install pip
sudo pip install virtualenv virtualenvwrapper gunicorn

source /usr/local/bin/virtualenvwrapper.sh

git clone --recursive git://github.com/mozilla/moztrap
cd moztrap
mkvirtualenv moztrap
bin/install-reqs

cd moztrap/settings/
sudo cp local.sample.py local.py

sudo nano local.py
++++++
Personas off
COMPRESS_ENABLED and COMPRESS_OFFLINE uncommented and set to True 
++++++

mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO ubuntu@localhost;
exit

echo "CREATE DATABASE moztrap CHARACTER SET utf8" | mysql
cd ../..
./manage.py syncdb --migrate (answer yes to create django super admin)
./manage.py create_default_roles
./manage.py collectstatic
./manage.py compress

sudo mkdir /var/www
sudo cp -R . /var/www/moztrap/

cd ~/
echo "cd /var/www/moztrap/" > startMozTrap.sh
echo "nohup gunicorn moztrap.deploy.wsgi:application --bind=127.0.0.1:8001 > ~/moz.out 2> ~/moz.err < /dev/null &" >> startMozTrap.sh
chmod +x startMozTrap.sh

sudo nano /etc/nginx/sites-available/moztrap
========
server {
    listen 80;
    gzip on;
    gzip_http_version 1.1;
    gzip_vary on;
    gzip_comp_level 6;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    location /static/ {
        alias /var/www/moztrap/collected-assets/;
        expires max;
    }

    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
        proxy_intercept_errors off;
    }
}
========

cd /etc/nginx/sites-enabled
sudo rm default
sudo ln -s ../sites-available/moztrap

sudo service nginx restart
./startMozTrap.sh
Reply all
Reply to author
Forward
0 new messages