Unable to runserver when I close my SSH connection with AWS EC2 - python

Hope anyone with these areas of expertise can help me.
Basically, I am trying to run my Django project inside the EC2 instance in Amazon Web Service. I have placed the files and tried to run the server with
python3 manage.py runserver 0.0.0.0:8000
The steps I used to configure my EC2 is by referring to this website: https://medium.com/saarthi-ai/ec2apachedjango-838e3f6014ab. I followed all the steps and I was able to deploy my project.
However, once I close my SSH connection, I won't be able to access the website anymore. Is there a solution to this?
Regards,
YX

When you exit(close connection) from SSH. It will close all user activity which are running on.
So you need to deploy your Django project on server with specified port. So project have accessible anytime from any where as per defined policy.
Please follow the following link to deploy your django project on ec2.
you need to configure Gunicorn with Nginx to host your
project on EC2
https://www.pythoncircle.com/post/235/how-to-setup-django-app-on-ec2-instance-aws/
If you have experienced person on AWS than you need to follow following instruction.
https://aws.amazon.com/getting-started/projects/deploy-python-application/
Thanks

Related

how can i make someone on another network access my website with django

hello guys I'm trying to make another one to access my Django website I host it on my localhost by type
python manage.py runserver 0.0.0.0:8000
and i set the ALLOWED_HOSTS = ['*']
when I trying to connect with my IP it's says refused to connect.
can someone help me
you are only hosting your server in your local network therefore no-one outside of this network can access your server. To make them access it you would have to make it accessible over the internet for example via hosting it on aws or another cloud hoster.

How to host Django 1.10 Web Application on WHM via cpanel?

I want to host my Django 1.10 web application on WHM(VPS). for that i have installed Django and another necessary tools on WHM(VPS) by ssh login. and i also have uploaded my Django application code through cpanel in public_html directory.
When i run python manage.py runserver <ip_address:8000> from ssh terminal, i am able to access that application. but when i close the ssh terminal, it terminates all the running process. so could not access application after that.
So, Is there any way that without running python manage.py script i can access Django application?
Any help would be highly appreciated.
Thank you.
Django comes with a built-in development server, it's not really meant to be used when deploying to a remote VPS.
There are some great resources to help you along, but what you're likely going to want to do is deploy your app on a stack using gunicorn or uwsgi as an application server and a web server like Nginx or apache 2 as a reverse proxy.
I personally use Nginx and uwsgi.
There are some great resources explaining how to deploy a Django server. Have a look at this one from digital ocean, it was a great help when I needed to set up a production server correctly: https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04
best of luck with it!

Deploying Django app to AWS EC2 using Nginx and Gunicorn

I am a newbie to web I developed a small web app using python and Django things are working fine with local development server. Now I want to deploy my app to an AWS EC2 instance with Nginx and Gunicorn. Every tutorial I found on the internet explains things using a linux platform. Unfortunately, I am using a windows.
I have never used Git or Linux, will I be able to do things from Windows machine itself?
Use PUtty and follow this.
After connecting to you linux instance everything command will be on linux.
It does not matter which platform you are using, just make sure on AWS, you should create linux instace and follow those tutorial on deploying with gUnicorn and Nginx.

Python Application URL

I created a Django Python application in localhost and setup virtualenv for running python application. I run this application from terminal and can access with this url- http://127.0.0.1:8000/ . On hosting time (server) how can i access this application using url?
I suggest you to check out this page of the django documentation if you haven't already: https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/
Deployment of a web application is not as easy as running the python development server, that is extremely simpler and is discouraged to be used on a server by the django documentation itself.
On a theoretic point of view, the reason why you can't access remotely the development server is because it binds the server on local only access: to make it accessible from an external computer you need to bind it to listen on 0.0.0.0 instead of 127.0.0.1, then you will be able to reach it on example.com:8000 depending on what the server's domain is and what port you choose. To use 0.0.0.0 you call manage.py runserver like this:
./manage.py runserver 0.0.0.0:8000
but avoid to do it, and opt for a more robust deployment :)
If your trying to deploy your application for the first time, and you want to get a feel of accessing your app from url, try heroku, https://www.heroku.com/
Easy and you don't have to worry about setting up everything.

Django + alwaysdata.com Noob Question

I'm learning Django and working on sample sites.. I registered at alwaysdata but am unable to view the site after I go 'manage.py runserver' in the SSH (this is after I've created the project and navigated to the appropriate directory, of course).
I appreciate any help.
Thanks
Have you taken a look at the wiki entry regarding the django dev server? Google translate seems to indicate that you need to request some ports open first, and that once you've got them assigned you can pass in one of those port numbers to runserver to run it on that port.
If you need the translated-to-English version, here's a link
I am also an alwaysdata customer. Daniel DiPaolo gave you the right links to get it working on ssh with the dev server. The google translation seems correct to me. You need to request a port range in order to use the dev server on ssh.
But this is intended only for debugging purpose and should run for a short while.
Here is how to deploy with fastCGI which is the regular way to deploy a Django site on alwaysdata.
http://wiki.alwaysdata.com/wiki/D%C3%A9ployer_une_application_Django.
Google give a decent translation
AlwaysData is running a forum at http://forum.alwaysdata.com/ mostly in French but questions in English are welcomed.
The devserver included with django is for testing purposes, only on your local machine and should not be used on a web host. From the docs:
DO NOT USE THIS SERVER IN A PRODUCTION
SETTING. It has not gone through
security audits or performance tests.
(And that's how it's gonna stay. We're
in the business of making Web
frameworks, not Web servers, so
improving this server to be able to
handle a production environment is
outside the scope of Django.)
If i have somehow misinterpreted your question, i apologise.
When you enter manage.py runserver you're running the development web server on the loopback interface (127.0.0.1). You could test this out by running wget 127.0.0.1 on the same server that the development web server is running.
If you want it to be on the internet so you could access it from outside that server, you'd have to specify your public ip. For example, to run the web development server on ip 1.1.1.1 and port 8080 (personally recommend using a non-standard port):
manage.py runserver 1.1.1.1:8080
To find out your public ip, try running ifconfig on SSH.
Also, you might have to check out the firewall settings with your ISP/server provider.

Categories

Resources