Friday, February 16, 2018

Deployin django in nginx & uwsgi environment

1. Install uwsgi , nginx 
apt-get install uwsgi, nginx

2. Clone django helloworld program
git clone https://github.com/Jadatravu/Tutorials/

3. Copy the helloworld program into /opt folder
cp -r Tutorials/dj_nx_wsgi  /opt

sudo chown -R www-data:www-data /opt/dj_nx_wsgi

4. Create a python virtual environment and install django
cd /opt
virtualenv env
source /opt/env/bin/activate
pip install django

5. Test uwsgi
(env) osboxes@ubuntu:/opt$ uwsgi --http  :8001 --wsgi-file /opt/dj_ng_wsgi/dj_ng_wsgi/wsgi.py  --virtualenv /opt/env --chdir /opt/dj_ng_wsgi/

6. Access from browser
http://192.168.91.129:8001/hello/

7. Configure nginx
copy nginx.conf from dj_nj_wsgi folder to /etc/nginx/sites-available
make soft link
ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/nginx.conf

8.restart nginx
service nginx restart

9. start wsgi
(env) osboxes@ubuntu:/opt$ uwsgi --socket :8001 --wsgi-file /opt/dj_ng_wsgi/dj_ng_wsgi/wsgi.py  --virtualenv /opt/env --chdir /opt/dj_ng_wsgi/

10.from browser access the url.
http://192.168.91.129:8000/hello/