Installation

Here’s the installation instructions for Enfix.

Assumptions:

  1. Ubuntu 16.04
  2. We will be using nginx as the web server, and UWSGI as the adapter. Apache and modwsgi are also possible, but not described here.
apt-get install nginx uwsgi python2.7 python2.7-dev python-virtualenv mongodb uwsgi-plugin-python \
    libjpeg62 libpng3 libjpeg62-dev libpng12-dev zlib1g-dev libfreetype6 libfreetype6-dev
cd /home
mkdir -p sites/venv/
cd sites
# Unzip Enfix packages here.

virtualenv venv/enfix_api
source venv/enfix_api/bin/activate
cd enfix_api
pip install -r requirements.txt
# Make a prod.py config.
python setup_site.py <domain_prefix>
cp wsgi.wsgi wsgi_config.py
# Create /etc/nginx/sites-available/enfix_api
ln -s /etc/nginx/sites-available/enfix_api /etc/nginx/sites-enabled/enfix_api
# Create /etc/uwsgi/apps-available/enfix_api.xml
ln -s /etc/uwsgi/apps-available/enfix_api.xml /etc/uwsgi/apps-enabled/enfix_api.xml
service uwsgi restart
service nginx restart

cd ..
virtualenv venv/enfix_ui
source venv/enfix_ui/bin/activate
cd enfix_ui
pip install -r requirements.txt
# Make a settings_local.py config.
python setup_site.py <domain_prefix>
cp wsgi.wsgi wsgi_config.py
# Create /etc/nginx/sites-available/enfix_ui
ln -s /etc/nginx/sites-available/enfix_ui /etc/nginx/sites-enabled/enfix_ui
# Create /etc/uwsgi/apps-available/enfix_ui.xml
ln -s /etc/uwsgi/apps-available/enfix_ui.xml /etc/uwsgi/apps-enabled/enfix_ui.xml
service uwsgi restart
service nginx restart

/etc/nginx/sites-available/enfix_api:

server {
    listen          80;
    server_name     <prefix>.api.enfix.com;

    location / {
        uwsgi_pass      unix:///var/run/uwsgi/app/enfix_api/socket;
        include         uwsgi_params;
        uwsgi_param     UWSGI_SCHEME $scheme;
        uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;

    }

    location /static {
        root   /home/sites/enfix_api/;
    }

}

/etc/uwsgi/apps-available/enfix_api.xml:

<uwsgi>
    <plugins>python</plugins>
    <socket>/var/run/uwsgi/app/enfix_api/socket</socket>
    <pythonpath>/home/sites/enfix_api/</pythonpath>
    <virtualenv>/home/sites/venv/enfix_api/</virtualenv>
    <module>wsgi_config:application</module>
    <master/>
    <processes>4</processes>
    <harakiri>60</harakiri>
    <reload-mercy>8</reload-mercy>
    <cpu-affinity>1</cpu-affinity>
    <max-requests>2000</max-requests>
    <limit-as>256</limit-as>
    <reload-on-as>192</reload-on-as>
    <reload-on-rss>128</reload-on-rss>
    <no-orphans/>
    <vacuum/>
</uwsgi>

/etc/nginx/sites-available/enfix_ui:

server {
    listen          80;
    server_name     <prefix>.ui.enfix.com;

    location / {
        uwsgi_pass      unix:///var/run/uwsgi/app/enfix_ui/socket;
        include         uwsgi_params;
        uwsgi_param     UWSGI_SCHEME $scheme;
        uwsgi_param     SERVER_SOFTWARE    nginx/$nginx_version;

    }
}

/etc/uwsgi/apps-available/enfix_ui.xml:

<uwsgi>
    <plugins>python</plugins>
    <socket>/var/run/uwsgi/app/enfix_ui/socket</socket>
    <pythonpath>/home/sites/enfix_ui/</pythonpath>
    <virtualenv>/home/sites/venv/enfix_ui/</virtualenv>
    <module>wsgi:application</module>
    <master/>
    <processes>4</processes>
    <harakiri>60</harakiri>
    <reload-mercy>8</reload-mercy>
    <cpu-affinity>1</cpu-affinity>
    <max-requests>2000</max-requests>
    <limit-as>256</limit-as>
    <reload-on-as>192</reload-on-as>
    <reload-on-rss>128</reload-on-rss>
    <no-orphans/>
    <vacuum/>
</uwsgi>