Skip to content

Instantly share code, notes, and snippets.

@pinnokio
Last active August 29, 2015 14:17
Show Gist options
  • Save pinnokio/f50589775d954b432c29 to your computer and use it in GitHub Desktop.
Save pinnokio/f50589775d954b432c29 to your computer and use it in GitHub Desktop.
***BACKEND PART***
sudo apt-get install -y --no-install-recommends \
bzr \
git \
mercurial \
subversion \
ca-certificates \
curl \
wget
sudo apt-get install -y \
python-software-properties \
software-properties-common
sudo apt-get install -y \
autoconf \
build-essential \
imagemagick \
libbz2-dev \
libcurl4-openssl-dev \
libevent-dev \
libffi-dev \
libglib2.0-dev \
libjpeg-dev \
libmagickcore-dev \
libmagickwand-dev \
libmysqlclient-dev \
libncurses-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxslt-dev \
libyaml-dev \
zlib1g-dev
sudo apt-get install -y \
python-pip \
python-virtualenv \
python-dev
sudo apt-get install -y \
redis-server \
memcached \
rabbitmq-server \
phantomjs
======Optional удобняхи==========
apt-get install -y \
vim \
nano \
htop \
tmux
=================================
useradd -m -s /bin/bash webmaster
groupadd supervisor
gpasswd -a webmaster supervisor
sudo apt-get install -y supervisor
======Supervisor configuration=====
sudo sed -i "s/chmod=0700/chmod=0770/g" /etc/supervisor/supervisord.conf
sudo sed -i "/chmod=0770/a chown=root:supervisor" /etc/supervisor/supervisord.conf
sudo service supervisor stop && \
sudo service supervisor start
=========NGINX=========
add-apt-repository ppa:nginx/stable
apt-get update
apt-get -y install nginx
=======================
=========PostgreSQL=====
echo "deb http://apt.postgresql.org/pub/repos/apt/ utopic-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install -y -q postgresql-9.3 postgresql-contrib-9.3 postgresql-server-dev-9.3
========================
=======.env file template===
# Twitter
SOCIAL_AUTH_TWITTER_KEY=HERE_MUST_BE_A_KEY
SOCIAL_AUTH_TWITTER_SECRET=HERE_MUST_BE_A_KEY
# Facebook
SOCIAL_AUTH_FACEBOOK_KEY=HERE_MUST_BE_A_KEY
SOCIAL_AUTH_FACEBOOK_SECRET=HERE_MUST_BE_A_KEY
# Google+
GOOGLE_OAUTH2_CLIENT_ID=HERE_MUST_BE_A_KEY
GOOGLE_OAUTH2_CLIENT_SECRET=HERE_MUST_BE_A_KEY
# Stripe
STRIPE_PUBLIC_KEY=HERE_MUST_BE_A_KEY
STRIPE_SECRET_KEY=HERE_MUST_BE_A_KEY
# Hook
HOOK_SECRET=HERE_MUST_BE_A_KEY
# SMTP
EMAIL_HOST=smtp.mandrillapp.com
EMAIL_HOST_USER=HERE_MUST_BE_A_USER
EMAIL_HOST_PASSWORD=HERE_MUST_BE_A_PASSWORD
# DATABASE CONNECTION
DB_ENGINE=django.db.backends.postgresql_psycopg2
DB_NAME=flerika
DB_USER=webmaster
DB_PASSWORD=HERE_MUST_BE_A_PASSWORD
DB_HOST=HERE_MUST_BE_A_HOST
DB_PORT=5432
================================
cd flerika
virtualenv env
source ./env/bin/activate
pip install -U pip setuptools
pip install -r requirements.txt
Далее либо залить дамп, либо синхронизировать и мигрировать базу указав для manage.py явно settings
Собрать статику
Медиа файлов не будет, можно забрать с production сервера
***Правки для conf/production/nginx.conf***
server_name api.domain.com
Так-же потребуется сгенерировать SSL сертификаты, либо поправить конфиги для отключения использования SSL
*******
***Правки для flerika/flerika/flerika/settings/production.py***
SITE_DOMAIN = 'domain.com'
ALLOWED_HOSTS = [
SITE_DOMAIN,
'domain.com',
]
******
sudo ln -s $(readlink -f ~/flerika/conf/production/nginx.conf) /etc/nginx/sites-enabled/flerika.conf
sudo nginx -t && sudo nginx -s reload
sudo ln -s $(readlink -f ~/flerika/conf/production/supervisor.conf) /etc/supervisor/conf.d/flerika.conf
supervisorctl update
***FRONTEND PART***
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get -y install nodejs
sudo npm install -g bower grunt-cli coffee-script
mkdir ~/.npm
echo 'export PATH="$PATH:$HOME/.npm/bin"' >> ~/.profile
npm config set prefix ~/.npm
sudo npm install -g npm
cd flerika_frontend
npm install
bower install
cp app/scripts/settings.js.example app/scripts/settings.js
Поправить файл app/scripts/settings.js
grunt build
***Правки для conf/production/nginx.conf***
server_name domain.com
Поправить секцию # REDIRECTS SECTION, там указаны домены явно
Так-же потребуется сгенерировать SSL сертификаты, либо поправить конфиги для отключения использования SSL
*******
Есть также supervisor и кусок кода на Flask для проксирования Facebook запросов на sharing, все в репе
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment