How to run the django web server even after closing the shell on Amazon Linux How to run the django web server even after closing the shell on Amazon Linux linux linux

How to run the django web server even after closing the shell on Amazon Linux


Running python manage.py ... is how you run in development, but it's not how you run on a web server. You need to deploy your application.

Take a look at Apache and mod_wsgi.


Install screen with below commandScreen is basically a tool which runs the process always, even we exit.

sudo apt-get updatesudo apt-get install screen

For details you can see: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-screen-on-an-ubuntu-cloud-server

Create a screen for you command, so your command can run as a daemon.

screen -S <processName> //Process name could be any random name for your process.

To enter inside screen.

screen -r <processName> 

Now you are inside screen and can run your command here.

python manage.py runserver ec2-instance-ip.us-east-2.compute.amazonaws.com:8000

Now exit screen: ctrl+a and then d

You can create multiple screens as many you want and can any time list them by command:

screen -ls

!important: this is not recommended for Production server.Look this to run Python app on production server: https://docs.djangoproject.com/en/2.0/howto/deployment/