I'm running a Django application on my Amazon Linux instance using the below command:
python manage.py runserver ec2-instance-ip.us-east-2.compute.amazonaws.com:8000
I want the application to be running even after I quit the shell. How do I run this web server even after quitting the shell on Amazon Linux?
I tried using the &
as shown below, but it didn't work.
python manage.py runserver ec2-instance-ip.us-east-2.compute.amazonaws.com:8000 &
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 command Screen is basically a tool which runs the process always, even we exit.
sudo apt-get update
sudo 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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With