I have a Python3 website on IIS8 server and WindowsServer2012 and would like to add django to it. I have started learning django and made some small examplaes on my localhost and now want to integrate django into the IIS.
It is important to note that I just want to see that it works on my IIS and then turn it off, so that I can move all the site to django on localhost, while the current site is still functioning correctly.
I got confused regarding different ways. Where would be a good starting point for this integration (note, this is Windows Server 2012)?
Related
I have a Python application that's that has been working correctly as backend for my website, up to now I have been running it using "python manage.py runserver IP:8000" in CMD. However I would like it to start using HTTPS, but when I try to access through my browser on https://IP:PORT I get the following error:
You're accessing the development server over HTTPS, but it only
supports HTTP.
The server I am running all of this is a Windows Center 2019 DataCenter, normally on a linux environment I would just use NGINX+GUNICORN.
I was browsing possible solutions and stumbled upon this, however I already am using IIS to host a website (My frontend), so I needed to figure out how to host several websites for the same IP, I have now found this.
Long story short, I configured the new IIS website for it to access my django, I then changed the hostname since both frontend and the new backend will using the same ip and ports (80, 443).
But now I have hit a spot where I'm confused due to my lack of experience in IIS and networking. I can't seem to understand how the request will go through to my Python-Django APP.
Something important to mention on how I access the Django APP in the past.
Lets say my front end is https://pr.app.com, whenever any request needed to be made to the backend. I would ask for said information in http://pr.app.com:8000/APIService/..../
This is how the binding for my frontend looks like
And this is the binding for the new backend where I changed the hostname as the second guide linked said
Any guidance or help would be most appreciated,
Thanks in advance
*Update
So I tried pausing my frontend website and used these bindings on the new backend website, I was able to get a screen of Django meaning it seems to be working or at least communicating.
Now I would need to have the hostname of the backend (pr.abcapi.com) somehow refer or redirect to the hostname of the frontend (pr.abc.com).
How could I achieve this?
I'm fairly new to Django so please excuse my ignorance.
I'm starting my first build of a web app on my remote web server. I am currently SSH'ing to the server and have started the Django project. I just launched the development server for the Django project, and it automatically serves at http://127.0.0.1:8000/.
My question is- what is the proper way to build a Django web app remotely on a server? Am I supposed to build the app on my computer and then transfer the project to my web server after it is complete? Or is there a way for me to access the development server without messing with the domains/ip addresses of the websites that are live on my web server?
Thanks!
This isn't really a Django specific question as the same basic methodology goes for any software development project.
Create different settings files for development and production. For Django this will involve setting the ALLOWED_HOSTS in your production settings as you mentioned as well as other settings. This checklist is helpful for this step. Use environment variables to hide secrets and set them in your development and production machines as appropriate.
Use a version control system such as git and push changes locally and then pull them onto your production server then run your Django server.
Do one better and setup a CI/CD pipeline to automate this
Yes, you're supposed to build working project on your computer :)
You probably cant efficiently write something good on the remote server.
Then you will probably create the git repository, for example on gitlab.
Then you will work on your computer building your project.
When you want to see it on the remote server, you will pull your project there.
It will be a little tricky for a first time to correctly deploy it, but it's not really that bad + there are a lot of good instructions out there, for ex:
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
I hope I correctly understood your question.
I'm relatively new to web development, but I have a couple years experience working with python, so I figured I would build my first production site using django.
I've spent the last few days learning the basics and building a test site running on my local machine. Today, I've been trying to deploy my site to production; however, I've hit a pretty large stumbling block.
The django documentation suggests using mod_wsgi for apache deployments. I followed the install instructions here, only to realize that I don't have access to make any changes to apache - I'm currently on a shared hosting plan.
Apparently, to perform the install, I would have to upgrade to a VPS plan, which costs a lot more.
Any advice for a new web developer trying to get a proof-of-concept web app together (preferably with feedback gathered from real users) on a budget?
I think I have two options:
Eat the cost on my current web hosting plan. Try to find a cheaper host that specializes in django hosting. I've been looking at the following (suggestions here would be wonderful):
Heroku
DigitalOcean
A2Hosting
Try some sort of manual deployment. Is this possible or has anybody ever made this work? I can't seem to find any resources about this.
I was able to install django on my web server and my site just seems like a collection of files at this point. Can I simply move this directory tree to my site using an ftp? And handle the database migration manually?
Can I just run django on my web server via ssh instead of from my local machine? Essentially just rebuild my site in production? I know this isn't a smart idea with a normal production site, but as a proof of concept, I don't mind some downtime if my code is buggy.
Thanks!
If you are just starting Heroku is probably perfect for you. It's super easy to set up, you don't have to handle the server configuration yourself and it has a free tier to do some tests until you are ready to go.
If you are OK with doing some more advanced server/service configuration, you can use Google Cloud, Azure or AWS. This last one has a one year free tier. If you go this route, I suggest using gunicorn/uwsgi + nginx instead of Apache mod_wsgi.
I need to deploy my django app on a shared server, where I don't have root access (e.g. httpd.conf) andn all I have is the folder public_html.
Now, I followed the sites describing using fcgi to deploy django (e.g. this). However, the pages load very slowly, I guess the reason is that django needs to be reloaded upon every request? Essentially, I would like a server that runs permanently and simply gets requests from apache.
Before trying out the solution with sockets and so on, I would like to ask for some professional opinions.
thanks!
FCGI sucks. Even its author admits it.
Using Apache ? Try mod_wsgi. It's the most professional deployment solution for apache.
Using Nginx or something else ? Then consider uWSGI. or gunicorn.
Link to a benchmark.
I'm running Django through mod_wsgi and Apache (2.2.8) on Ubuntu 8.04.
I've been running Django on this setup for about 6 months without any problems. Yesterday, I moved my database (postgres 8.3) to its own server, and my Django site started refusing to load (the browser spinner would just keep spinning).
It works for about 10 mintues, then just stops. Apache is still able to serve static files. Just nothing through Django.
I've checked the apache error logs, and I don't see any entries that could be related. I'm not sure if this is a WSGI, Django, Apache, or Postgres issue?
Any ideas?
Thanks for your help!
It sounds a lot like there's something happening between django and your newly housed database.
Just to eliminate apache from the mix, you should run it as the dev server (on some random port to stop people using it) and see if you still have issues. If you do, it's the database. If it behaves, it could be apache.
Edit, This looks interesting. You can test that by applying his patch (commenting out the .close()) but there are other similar bugs floating around.
Found it! I'm using eventlet in some other code and I imported one of my modules into a django model. So eventlet was taking over and putting everything to "sleep".