0% found this document useful (0 votes)
18 views7 pages

1 Sudo Apt Update

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

1 Sudo Apt Update

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1 sudo apt update

2 sudo apt install python3-venv python3-dev libpq-dev postgresql postgresql-


contrib nginx curl
3 sudo -u postgres psql
CREATE DATABASE mydb;

CREATE USER elyor WITH PASSWORD '123456';

ALTER ROLE elyor SET client_encoding TO 'utf8';


ALTER ROLE elyor SET default_transaction_isolation TO 'read committed';
ALTER ROLE elyor SET timezone TO 'UTC';

GRANT ALL PRIVILEGES ON DATABASE mydb TO elyor;


\q

4 apt-get install git


7 git clone
https://[email protected]/elyorjona
kaku/atdt.git
9 git pull
10 ls
14 cd KPITest
15 git pull
17 apt install --upgrade pip
18 apt install virtualenv
19 ls
20 cd ..
21 ls
22 virtualenv venv
23 ls
24 source venv/bin/activate
25 cd KPITest
26 ls
27 sudo -u postgres psql
ALTER DATABASE mydb OWNER TO elyor;
\q

28 pip install -r requirements.txt


29 python3 manage.py migrate
30 python3 manage.py createsuperuser
31 python3 manage.py collectstatic
32 apt install ufw
33 ufw allow 8000
34 python manage.py runserver 0.0.0.0:8000

Shu yerda aws consolda qanday qilinadi topamiz


Inbaund rule da 8000 port qo’shiladi (security groupni ichida)

35 pip install gunicorn


36 gunicorn --bind 0.0.0.0:8000 ATDT.wsgi
37 nano /etc/systemd/system/gunicorn.socket

[Unit]
Description=gunicorn socket

[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target

38 nano /etc/systemd/system/gunicorn.service

[Unit]
Description=gunicorn daemon
Requires=gunicorn.socket
After=network.target

[Service]
User=ubuntu
Group=www-data
WorkingDirectory=/home/ubuntu/atdt
ExecStart=/home/ubuntu/venv/bin/gunicorn \
--access-logfile - \
--workers 3 \
--bind unix:/run/gunicorn.sock \
ATDT.wsgi:application

[Install]
WantedBy=multi-user.target

39 systemctl start gunicorn.socket


40 systemctl enable gunicorn.socket
41 systemctl status gunicorn.socket
42 systemctl status gunicorn
43 curl --unix-socket /run/gunicorn.sock localhost
44 systemctl status gunicorn
45 nano /etc/nginx/sites-available/atdt
server {
listen 80;
server_name atdt.uz;

location = /favicon.ico { access_log off; log_not_found off; }


location /static/ {
root /home/ubuntu/atdt;
}
location /media/ {
root /home/ ubuntu /atdt;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}

46 sudo ln -s /etc/nginx/sites-available/atdt /etc/nginx/sites-enabled


47 nginx -t
48 systemctl restart nginx
49 ufw allow 'Nginx Full'
50 ufw delete allow 8000
51 systemctl restart gunicorn
52 sudo chown -R ubuntu22:www-data /home/ubuntu/atdt/static/
53 sudo chmod -R 755 /home/ubuntu/atdt/static/
54 systemctl restart nginx
55 systemctl restart gunicorn
56 history

AWS da sayt ishlamaydi. Nimadir qilish kerak

Security guroupga 80 port qo’shish kerak ekan

Shunda static fayllar ishlamadi formalar ishlamadi. Endi nima qilishnibirgalikda


ko’rib chiqamiz.

Deactivatesiya qilib
sudo chown -R www-data:www-data /home/ubuntu/atdt/static
sudo chown -R www-data:www-data /home/ubuntu/atdt/media
sudo chown -R www-data:www-data /home/ubuntu/atdt
sudo chown -R www-data:www-data /home/ubuntu
sudo chmod -R 755 /home/ubuntu/atdt/static
sudo chmod -R 755 /home/ubuntu/atdt/media

sudo chmod -R 755 /home/ubuntu/atdt


sudo chmod -R 755 /home/ubuntu
sudo systemctl restart nginx
sudo systemctl restart gunicorn

ushbu buyruqlarni kiritish kerak ishlaydi!!!!!!!!!!!!

Fayl yuklash ishlamay qoladi


sudo chmod 777 /home/ubuntu/atdt -R
bu fayllarni yuklaydigan qiladi.

Endi katta hajmli fayllarni yuklamaydi.


Yechimini izlaymiz
Yechimi topildi.

server {
listen 80;
server_name kpiup.tsue.uz;
client_max_body_size 100M; ni qo’shib qo’yish kerak ekan.

location = /favicon.ico { access_log off; log_not_found off; }


location /static/ {
root /home/kpi-superadmin/KPITest;
}
location /media/ {
root /home/kpi-superadmin/KPITest;
}

location / {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
}
Agar CRSF token ishlamay qolsa

CSRF_COOKIE_HTTPONLY = True
SESSION_COOKIE_HTTPONLY = True
CSRF_COOKIE_SECURE = False
CORS_ALLOW_CREDENTIALS = True

ismoniy
Jismoniy@3000

You might also like