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

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!

Related

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

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

How do I host my Django app on the intranet?

I have successfully developed a Django app. The requirement is to deploy the app over an on-premise server. The application is accessible on the intranet using the development environment. Is any web server is preferred to deploy this application locally (or) should I leave the terminal running the server as it is so that the users can access the application as they are already doing it? I am using a unix server.
If the question is actually on deployment model, I suggest to take a look at django docs on deployment. Depending on load, uWSGI/Gunicorn [+ nginx] will be good choice.
Independent of tools you use, no need to leave running terminal on your server. There's a lot of tools to "daemonize" processes. Simplest would be supervisor

Is it normal that the Django site I recently deployed on Apache is always on?

I recently deployed a Django site on a DigitalOcean droplet through Apache. I did python manage.py runserver through ssh and now the Django site is running. However, it stayed on even after the ssh session expired (understandable because it's still running on the remote server) but how do I shut it down if I need to?
Also, due to this, I don't get error messages on the terminal if something goes wrong like I do when I develop locally. What would be a fix for this?
Your question is confusing. If you deployed it with Apache, it's running through Apache and not through runserver. You might have additionally started runserver, but that is not what is serving your site.

How to deploy Flask Web app in Production server from PyCharm

I am new to Flask Web with Python. I developed a simple Flask with Pycharm. Now I want to deploy it on my college server. I remember when I develop php web app I used to copy it to www folder in var and run it from there.
Can someone explain me how do I deploy python web app in Linux production server.
First, you need to figure out what your server provides from its sysadmin. There are tens of ways to do this, and all of them have different answers.
Given that you have used php on the system before, I'll assume you are using Apache httpd.
First, you would need to have a wsgi provider installed (e.g. mod_wsgi) , and then wire your application into the wsgi provider.
See the mod_wsgi page and flask docs for more information on how to precisely do this.
https://code.google.com/p/modwsgi/
http://flask.pocoo.org/docs/0.10/deploying/
Another option is to have python bring its own webserver and optionally have a proxy redirect / load balance.

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.

Categories

Resources