Skip to content

oneprofittips/install_aio_webapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 

Repository files navigation

ΠŸΠ΅Ρ€Π²Ρ‹ΠΌ Π΄Π΅Π»ΠΎΠΌ  создадим для прилоТСния ΠΏΠ°ΠΏΠΊΡƒ для прилоТСния

Π‘ΠΎΠ·Π΄Π°ΠΈΠΌ Π²ΠΈΡ€Ρ‚ ΠΎΠΊΡ€ΡƒΠΆΠ΅Π½ΠΈΠ΅
pip install virtualenv
python3 -m venv env
активация source env/bin/activate
дСактивация deactivate

pip install uvloop

Установка gunicorn
pip install gunicorn
ΠŸΡ€ΠΎΠ±Π½Ρ‹ΠΉ запуск 
1. Π‘ΠΎΠ·Π΄Π°Π΅ΠΌ ΠΊΠΎΠ½Ρ„ΠΈΠ³ Ρ„Π°ΠΉΠ» gunicorn.conf.py 
2. Π‘Ρ‚Ρ€ΠΎΠΊΠ° запуска 
  1.1 gunicorn main_api:my_web_app --bind localhost:8080 --worker-class aiohttp.GunicornUVLoopWebWorker --workers 2
  ΠΈΠ»ΠΈ с ΠΏΠΎΠΌΠΎΡ‰ΡŒΡŽ ΠΊΠΎΠ½Ρ„ΠΈΠ³ Ρ„Π°ΠΉΠ»Π°
  1.2 gunicorn main_api:my_web_app -c gunicorn.conf.py

Установка Nginx 
apt install nginx
Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ Π² ΠΏΠ°ΠΏΠΊΠ΅ /etc/nginx/sites-available/   Ρ„Π°ΠΉΠ» для сайта 
ΠΈ впишСм Ρ‚ΡƒΠ΄Π° ΠΊΠΎΠ½Ρ„ΠΈΠ³ΡƒΡ€Π°Ρ†ΠΈΡŽ 

server {
    listen 80;
    server_name 111.222.333.44; # здСсь ΠΏΡ€ΠΎΠΏΠΈΡΠ°Ρ‚ΡŒ ΠΈΠ»ΠΈ IP-адрСс ΠΈΠ»ΠΈ Π΄ΠΎΠΌΠ΅Π½Π½ΠΎΠ΅ имя сСрвСра
    access_log  /var/log/nginx/example.log;
 
    location /static/ {
        root /home/user/myprojectenv/myproject/myproject/;
        expires 30d;
    }
 
    location / {
        proxy_pass http://127.0.0.1:8000; 
        proxy_set_header Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Π‘ΠΎΠ·Π΄Π°Π΄ΠΈΠΌ  ссылку 
ln -s /etc/nginx/sites-available/<ИМЯ ЀАЙЛА> /etc/nginx/sites-enabled/

ΠŸΡ€ΠΎΠ²Π΅Ρ€ΠΊΠ° Π½Π° синтаксичСскиС ошибки
nginx -t

ΠšΠΎΠΌΠ°Π½Π΄Ρ‹ управлСния Nginx
systemctl stop nginx
systemctl restart nginx
systemctl start nginx
systemctl reload nginx
systemctl disable nginx
systemctl enable nginx

Настройка супСрвизора
apt-get install supervisor

Π’ Ρ„Π°ΠΉΠ»Π΅ cd /etc/supervisor/supervisord.conf  Π΄ΠΎΠ±Π°Π²ΠΈΠΌ Π² ΠΊΠΎΠ½Π΅Ρ†
[program:app]
command=/root/app/appenv/bin/gunicorn app:inst_app --bind 0.0.0.0:5000 --worker-class aiohttp.GunicornUVLoopWebWorker --workers=4
directory=/root/app
user=root
autorestart=true
redirect_stderr=true

Π’ΠΊΠ»ΡŽΡ‡ΠΈΠΌ супСрвизор
update-rc.d supervisor enable

Запустим
service supervisor start
/etc/init.d/supervisor restart
ΠžΡΠ½ΠΎΠ²Π½Ρ‹Π΅ ΠΊΠΎΠΌΠ°Π½Π΄Ρ‹ супСрвизора
supervisorctl reread
supervisorctl update
supervisorctl status <имя Ρ„Π°ΠΉΠ»Π° ΠΊΠΎΠ½Ρ„>
supervisor restart <имя Ρ„Π°ΠΉΠ»Π° ΠΊΠΎΠ½Ρ„>

Π£Π±ΠΈΡ€Ρ‚ΡŒ процСсс killall gunicorn


PG
apt-get install postgresql
su - postgres
psql

CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published