AWS

 1. Python manage.py  check --deploy [ deploy checks to be made before putting on server]

2.We can configure the domain name with Route 53 service provided by aws

3.  to make the file read-only in mac -- chmod 400 filname.py

4. sudo apt-get update  --- to update everything

5. sudo apt-get upgrade -y   -- to update all the packages

6. New way to create virtualenvironment ---    python -m venv env  

7. Gunicorn is a python module so we can install with pip3 install gunicorn

8. Ngnix comes from ubuntu system sudo apt-get install -y nginx

9. supervisor is used because it makesure that your server will run on background 

10. supervisor will make sure that gunicorn will always run on background

11. to install supervisor sudo apt-get install -y supervisor
12. Now we have to make config file for supervisor so that supervisor can read that config file and do the operations and that is in directory  cd /etc/supervisor/conf.d/

then create a file sudo touch gunicorn.conf

- sudo nano gunicorn.confs

Then paste below things in that particular file


[program:gunicorn]

directory=/home/ubuntu/whizcophase1

command=/home/ubuntu/env/bin/gunicorn --workers 3 --bind unix:/home/ubuntu/whizcophase1/app.sock core.wsgi:application

autostart=true

autorestart=true

stderr_logfile=/var/log/gunicorn/gunicorn.err.log

stdout_logfile=/var/log/gunicorn/gunicorn.out.log

[group:guni]

programs:gunicorn


13. now tell the supervisor to read the gunicorn.conf file

sudo mkdir /var/log/gunicorn

sudo supervisorctl reread


14 Now tell the supervisor to start the gunicorn on the background

sudo supervisorctl update

sudo supervisorctl status 


15. So our next step is configure ngnix to read from this socket file

cd -- go to the home directory

cd /etc/ngnix/sites-available/

sudo touch django.conf

sudo nano django.conf


server {

   listen 80;

    server_name ec2-3-110-160-28.ap-south-1.compute.amazonaws.com;

    location / {

       include proxy_params;

        proxy_pass http://unix:/home/whizcophase1/app.sock;

}

}

now test this by 

sudo nginx -t

sudo ln django.conf /etc/nginx/sites-enabled/



SOLUTION TO THE THAT SOCK FILE PERMISSION DENIED NGINX BAD GATE WAY IS 


- GO TO sudo nano /etc/nginx/nginx.conf


- REPLACE WWW-DATA WITH RISHABH(YOUR USER)











Comments

Popular posts from this blog

Django

JS

chat model