Running Django Python Server on AWS
You can use Apache or Nginx to deploy your Django application. If you plan to use Nginx, first install Nginx on your server and add Django configurations to your Nginx configuration. You can follow this as a good guide .
source to share
You can do this in a hacky way: create a bash script that executes the application (just by running the same command you run to run it) and run the bash script with nohup, which will detach the process from the shell and allow the application to continue running when the session is closed:
nohup ./my_bash_script.sh &
If you want to do this correctly, create a service file and run the application as a service. You can create a simple service file like this:
[Unit]
Description=My Django app
After=network.target
[Service]
PIDFile=/run/DjangoApp/pid
User=<your user>
Group=<your group>
WorkingDirectory=<working directory of your Django app>
ExecStart=<path to your bash script>
PrivateTmp=True
[Install]
WantedBy=multi-user.target
Save the file under /etc/systemd/system/djangoService.service
. You enable the service with this command:
sudo systemctl enable djangoService
And start it with this command:
sudo service start djangoService
This will keep the service running. Be aware, however, that in order to serve a proper Django application, you can use Gunicorn / wsgi to serve responses, using Nginx for a reverse proxy request.
source to share
In development mode, Django has a development server sufficient for testing. Once you've finished your web app and are ready to go, the process of setting up your app on the server can be overwhelming for some, especially if this is your first time doing it. This article provides a step-by-step guide to deploying Django-based web applications using mod_wsgi.
You can follow this article for installing mod_wsgi with Apache server. enter link here
If the one you are setting up for development only then you need to start the server in daemon mode.
on Ubuntu
run:>./manage.py runserver 0.0.0.0:8000 > /dev/null 2>&1 &
>exit
source to share