sudo apt update && sudo apt upgrade
)python
)sudo apt install python
) and check againpip
)sudo apt install pip
) and check againpip install django --break-system-packages
)pip install uwsgi --break-system-packages
)django-admin
), (uwsgi
)/bin
folder cd /home/keju/.local/bin/
sudo mv django-admin /bin/django-admin
sudo mv uwsgi /bin/uwsgi
django-admin startproject savessh
)cd savessh
)python manage.py runserver 192.168.178.100:8000
) (Replace the IP adress with the one of your server, leave port 8000)ALLOWED_HOSTS = ['192.168.178.100']
test.py
in your user folder, not the project folder, with the following content: def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World!"]
uwsgi --http :8000 --wsgi-file test.py
)uwsgi --http :8000 --module savessh.wsgi
)sudo apt install nginx
)sudo nano /etc/nginx/sites-available/savessh.conf
) # The upstream component nginx needs to connect to
upstream django {
server unix:///home/keju/savessh/savessh.sock;
}
# Configuration of the server
server {
listen 80;
server_name savessh.com;
charset utf-8;
# max upload size
client_max_body_size 75M;
# Django media and static files
location /media {
alias /home/keju/savessh/media;
}
location /static {
alias /home/keju/savessh/static;
}
# Send all non-media requests to the Django server
location / {
uwsgi_pass django;
include /home/keju/savessh/uwsgi_params;
}
}
sudo nano /etc/nginx/nginx.conf
)user www-data;
to your username, in this case user keju;
anduwsgi_params
file (sudo nano /home/keju/savessh/uwsgi_params
) uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param REQUEST_SCHEME $scheme;
uwsgi_param HTTPS $https if_not_empty;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
sites-available
to sites-enabled
(sudo ln -s /etc/nginx/sites-available/savessh.conf /etc/nginx/sites-enabled/
)import os
at the very beginning before from pythlib import Path
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
at the very end after STATIC_URL = '/static/'
python manage.py collectstatic
)sudo systemctl restart nginx.service
)/static/favicon.ico
(or the name of your file in the static folder) (http://192.168.178.100:80/static/favicon.ico
) and you should see that imageuwsgi --socket savessh.sock --module savessh.wsgi
and visit your website again with port 80, you should see the default Django landing pageuwsgi --socket savessh.sock --module savessh.wsgi --chmod-socket=664
uwsgi --socket savessh.sock --module savessh.wsgi --chmod-socket=666
sudo nano savessh_uwsgi.ini
) and add the following content [uwsgi]
# Full path to Django project's root directory
chdir = /home/keju/savessh/
# Django's WSGI file
module = savessh.wsgi
# Full path to Python virtual env
#home = /home/keju/env/md
# Enable uWSGI master process
master = true
# Maximum number of worker processes
processes = 10
# The socket (use the full path to be safe)
socket = /home/keju/savessh/savessh.sock
# Socket permissions
#chmod-socket = 666
# Clear environment on exit
#vacuum = true
# Daemonize uWSGI and write messages into given log
daemonize = /home/keju/uwsgi-emperor.log
uwsgi --ini savessh_uwsgi.ini
cd /home/keju/
mkdir vassals
sudo ln -s /home/keju/savessh/savessh_uwsgi.ini /home/keju/vassals/
uwsgi --emperor /home/keju/vassals --uid www-data --gid www-data
sudo nano /etc/systemd/system/emperor.uwsgi.service
[Unit]
Description=uwsgi emperor for savessh website
After=network.target
[Service]
User=keju
Restart=always
ExecStart=/bin/uwsgi --emperor /home/keju/vassals --uid www-data --gid www-data
[Install]
WantedBy=multi-user.target
sudo systemctl enable emperor.uwsgi.service
sudo systemctl start emperor.uwsgi.service
sudo systemctl status emperor.uwsgi.service
sudo systemctl stop emperor.uwsgi.service
sudo apt install snapd
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --nginx
and follow the instructions 'wss://'+ window.location.host + '/ws/chat/'
sudo nano /etc/nginx/sites-available/savessh.conf
) # WebSocket handling
location /ws/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_redirect off;
proxy_pass http://127.0.0.1:8001/ws/;
}
daphne -p 8001 savessh.asgi:application
)