Skip to content

Installing pyDash with Nginx and Gunicorn

Jonathan Chan edited this page Apr 27, 2018 · 8 revisions

1. Installation

We will install pyDash and run it using Nginx and Gunicorn. There are other ways you can server wsgi as using uWsgi etc so you can look into those as well if you do not want to use gunicorn.

Fedora & Pidora

Run:

sudo yum -y install git python-pip nginx

Centos

Centos 6

Run:

sudo yum -y install http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

sudo yum -y install git python-pip nginx

Centos 5

Run:

sudo yum -y install http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

sudo yum -y install git python-pip nginx

Debian & Ubuntu & Raspbian

Run:

sudo apt-get install git python-pip nginx

2. Setup

Please make sure you change the SECRET_KEY, please see https://docs.djangoproject.com/en/dev/ref/settings/ for more details.

Run:

cd /home
sudo git clone https://github.com/k3oni/pydash
cd pydash
edit pydash/settings.py and change the SECRET_KEY value
sudo pip install -r requirements.txt gunicorn
sudo ./manage.py syncdb

Enter the user information, to create your login user:

 You just installed Django's auth system, which means you don't have any superusers defined.
 Would you like to create one now? (yes/no): yes
 Username (leave blank to use 'root'): admin (Enter your desired username)
 Email address: [email protected] (Enter your email address)
 Password: xxxxx (Enter your desired password)
 Password (again): xxxxx (Enter your password again)

3. Add Nginx configuration

Centos 5&6, Fedora, Pidora

Add the config pydash.conf file under /etc/nginx/conf.d/:

 server {
     listen 80;

     server_name your_server_name;
     access_log /var/log/nginx/pydash_access_log;

     location / {
         proxy_pass http://127.0.0.1:8000;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-Proto $remote_addr;
     }
 }    

Start Gunicorn in the background and Nginx:

 cd /var/www/pydash/pydash
 gunicorn wsgi &
 service nginx start

Ubuntu, Debian, Raspbian

Add the config lines under /etc/nginx/sites-enabled/default. If pyDash is the only web application you want to run you can delete all the lines in the default file and add only the following:

 server {
     listen 80;

     server_name your_server_name;
     access_log /var/log/nginx/pydash_access_log;

     location / {
         proxy_pass http://127.0.0.1:8000;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_set_header X-Forwarded-Proto $remote_addr;
     }
 }    

Start Gunicorn in the background and Nginx:

 cd /var/www/pydash/pydash
 gunicorn wsgi &
 service nginx start