Skip to content

Instantly share code, notes, and snippets.

@jameserrico
Forked from lashex/amazon-linux-python-3
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameserrico/695d9976593986976e37 to your computer and use it in GitHub Desktop.
Save jameserrico/695d9976593986976e37 to your computer and use it in GitHub Desktop.
# Install binary packages
sudo yum install gcc
sudo yum install gcc-c++
sudo yum install zlib-devel
sudo yum install openssl-devel
sudo yum install bzip2-devel
sudo yum install readline-devel
sudo yum install openssl-devel openssl
sudo yum install git
sudo yum install nginx
sudo yum install postgresql-devel
# Make folders for apps and logs
sudo mkdir /var/log/unified
sudo mkdir /usr/lib/unified
sudo chown ec2-user /var/log/unified/
sudo chown ec2-user /usr/lib/unified/
# Install Python 3.4 from source
wget https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz
tar -xvf Python-3.4.1.tgz
cd Python-3.4.1/
sudo ./configure --prefix=/opt/python3 --with-ensurepip=install
sudo make
sudo make install
# Install virtualenvwrapper
sudo /opt/python3/bin/pip3 install virtualenvwrapper
# Add the following to .bashrc, restart shell once done
export PATH=$PATH:/opt/python3/bin
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/opt/python3/bin/python3
export PROJECT_HOME=/usr/lib/unified
source /opt/python3/bin/virtualenvwrapper.sh
# Setup Git SSH deploy key for https://github.com/Unified/platform-communique
# https://help.github.com/articles/generating-ssh-keys/
# Create vitualenv for project
mkproject platform-communique
# Delete the project folder just so we can clone from Git
cd /usr/lib/unified/
sudo rm -r platform-communique/
# Clone code, install Python packages in virtualenv
git clone git@github.com:Unified/platform-communique.git
cd platform-communique/
pip install Cython>=0.22,<0.23
pip install -r requirements.txt
# Add relevant folders to virtualenv PYTHONPATH
add2virtualenv /usr/lib/unified/platform-communique/app
add2virtualenv /usr/lib/unified/platform-communique
# Daemonize gunicorn via upstart by adding the below in a new file, /etc/init/gunicorn.conf
description "gunicorn"
start on (filesystem)
stop on runlevel [016]
respawn
#setuid ec2-user
#setgid ec2-user
chdir /usr/lib/unified/platform-communique/app
exec /home/ec2-user/.virtualenvs/platform-communique/bin/gunicorn --timeout 60 main:application
# Save the file, start gunicorn
sudo start gunicorn
# Edit nginx.conf to match https://gist.github.com/jameserrico/19fa84db853e98e9c769
# Except change line 3 from /run/nginx.pid to /var/run/nginx.pid
# Due to different folder structure for pid folder between Ubuntu and Amazon Linux
sudo /etc/init.d/nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment