Maker/DIY
Engenharia Elétrica
Alguns programinhas
Economia
Assuntos Nerds
Fotografia
git clone [webapp github url]
virtualenv -p python3 myenv
from app import app
if __name__ == "__main__":
app.run()
if __name__ == "__main__":
app.run()
python wsgi.py
pg_dump -d database_name -U username -h hostname > filename.dump
deactivate
[Unit]
Description=Gunicorn instance to serve myproject
After=network.target
[Service]
User=username
Group=www-data
WorkingDirectory=/home/username/myproject
Environment="PATH=/home/maru/myproject/myenv/bin"
ExecStart=/home/maru/myproject/myenv/bin/gunicorn --workers 4 --bind unix:myproject.sock -m 007 wsgi:app
[Install]
WantedBy=multi-user.target
sudo systemctl start myproject
sudo systemctl enable myproject
You will see something like this:
Created symlink /etc/systemd/system/multi-user.target.wants/myproject.service → /etc/systemd/system/myproject.service.
sudo systemctl status myproject
server {
listen 80;
server_name myproject.com www.myproject.com;
location / {
include proxy_params;
proxy_pass http://unix:/home/username/myproject/myproject.sock;
}
}
sudo ln -s /etc/nginx/sites-available/myproject /etc/nginx/sites-enabled
sudo nginx -t
If everything is OK the output looks like this:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
sudo systemctl restart nginx
Create a new subdomain in digitalocean droplet
Create directory:
sudo mkdir -p /var/www/example.com/html
sudo chown -R $USER:$USER /var/www/example.com/html
sudo chmod -R 755 /var/www
Create the DB on your new local server
If DB exists => dump and restore.
Else => in the terminal run python and after import your app and run code:
$ python
>>>from app import db
>>>db.create_all()
© Copyright 2019 marumaker.com