I have a 'control panel' webserver account and I want to build a django powered site.
Mod_wsgi is not enabled/present, leaving CGI as my only option.
Mod_rewrite is available and I have been experimenting/hacking with these solutions, https://gist.github.com/philchristensen/5845530, Django via CGI on shared hosting. Both of these are a number of years old and may no longer be relevant, plus I have had no luck with so far.
Does any know if what I am trying to do is even possible and, if so, how it may be dine
Related
I have a Django website as an on-going development which I have running on Ubuntu 16.04.1. It is an intranet and so sits within a corporate network.
It currently works nicely with Nginx, Gunicorn and Supervisor.
However, I would now like to implement single sign on so that users who have already authenticated into their workstations don’t have to sign into the application. As I understand from, the Django documentation, setting the REMOTE_USER environment variable is key and, during my efforts, I have been able to set this variable in my current Nginx config and it authenticates to the Django site.
However, the network environment means that I am looking for a solution that uses with NTLM or Kerberos (rather than Based Auth, which I believe would make this much easier for me although I’m currently unfamiliar with all of them.)
In trying to find internet posts that would help be do this (including on here), I’m not 100% sure that it would actually be possible.
Does anyone know if it is using recent versions of nginx (1.10) ? If not, am I likely to have more success with some sort of Apache set up ( using mod_wsgi instead of Gunicorn as this post this post would insinuate.
I'm following through the Django Tutorials by HackedExistence on youtube.
Since the video is about a year old, I assume that the version differences may contribute to this problem. I'm currently on the 2nd video but this issue arose since the first.
On my browser,
http://video1.hackedexistence.com/
This link opens up the Apache 2 Test Page, and the localhost link opens up the Django Administrator page nicely.
But he sets it up so that the hacked existence link loads up the Django Admin page.
How is he able to achieve this? and what steps are needed for setting it up that way with the versions that I'm working with.
Python 2.7.3, Django 1.4.1, Apache 2.2.22 (Unix)
Running on OS X 10.6.8.
video1.hackedexistence.com is (presumably) a domain under the control of HackedExistence, and it's showing an Apache 2 test page because the server it's pointing to is not configured to show anything else. You have no control over this domain or the server it is pointing to, so you can't affect it directly.
It doesn't have anything to do with different versions of python, django, apache, or anything else; it's likely that HackedExistence chose to move on to something else, is no longer maintaining his site (or at least the content on that subdomain of it) and his tutorial now no longer works as a result.
The closest you can come is add an entry to your /private/etc/hosts file (on OSX) so that video1.hackedexistence.com resolves to 127.0.0.1 (i.e. localhost, your own computer), but this is almost certainly not what you're after. For example, if you do this, everybody else will still see the test page you're seeing now, because the /etc/hosts file is just telling your computer to treat the video1.hackedexistence.com domain as if it's pointing to your computer.
For learning web development, you can safely completely disregard this and can continue to test on your local computer.
When it comes to deploying the website for other people to view and use, you will need to buy a domain (e.g. at http://namecheap.com/), get some hosting (for python/django hosting I can recommend WebFaction , or you can use Heroku's free plan), and follow the Django deployment instructions in the official documentation (or the documentation provided by the hosting provider you choose). My advice is to focus on learning web development and get something working before you spend money on any hosting.
I don't know the videos, but I'm assuming that the author of the book owns (or owned at the time) the hackedexistence.com domain name, and had it pointing to his server so that it would be able to interpret the Django App and serve it up to public requests ... and now it looks like that configuration doesn't exist any more.
If you're asking what I think you want to ask, "how can I get a Django app viewable on the public web," well, there are lots of ways to go about doing this. If your server is Apache, https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/modwsgi/ is the way to go. Google could help you find the similar docs for other servers. Lots of answers on stack overflow as well.
If instead you're asking a different question, namely, "how can I get this app on my local machine to be viewable via some method other than localhost" (and you don't have a server), well, the answer is you'd have to get a domain that points to your local machine -- this is a question that has lots of answers elsewhere. One thing to be aware of is that Django through Apache on Mac OS X isn't terribly simple, as it requires manually installing mod_wsgi, but it's not overly difficult either. Here's Google's top link (a bit old but still relevant): http://jessenoller.com/2009/07/24/django-mod_wsgi-apache-and-os-x-do-it/
And finally, if you're asking how you can get your app to show up at hacked existence, well ... buy that domain and see the above paragraph. :)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to deploy a Django web application, and hence I need to choose a web server to serve the Python files.
I should mention that my production site will be on a single server, which will host the database and the web server. As momentum picks, I aim to move the database to dedicated server etc.
Here are my questions:
Should I use one web server or two? The context of this question is that lots of people recommend using NginX to serve static media files and Apache to serve the Python, which beckons the following questions:
Why can't we use just one server. I understand Apache may be a beast at times, therefore I would suspect people to use NginX to serve BOTH static media files and python files.
If using one server, what is better, Apache or NginX. I am experienced in Apache, but I have heard only good things about NginX.
What are the advantages to using FastCGI as opposed to mod_wsgi?
Many thanks in advance
Should I use one web server or two? The context of this question is
that lots of people recommend using NginX to serve static media files
and Apache to serve the Python, which beckons the following questions:
Why can't we use just one server. I understand Apache may be a beast
at times, therefore I would suspect people to use NginX to serve BOTH
static media files and python files.
If you currently have no other sites that are already configured in one way or another, or you need some specific features that are mutually exclusive between the various servers, I see no reason for using multiple servers. This just adds unnecessary complexity and configuration.
If using one server, what is better, Apache or NginX.
I am experienced in Apache, but I have heard only good things about NginX.
As with all "which is better" questions this is usually a matter of preference. And to get a specific answer you probably need to ask more specific questions.
If you already have experience with a specific server and you just want to get up an running quickly, then I would suggest going with what you already know for the time being. You can always switch to another web server later.
On the other hand it's a good opportunity to learn about the alternatives.
tl;dr : I would go for what is easier to configure and manage. Personally I would go for a nginx and gunicorn, mainly because it's easy and there are plenty of resources available if you should get stuck.
I wouldn't worry too much about the performance until you actually need to. All staple web servers are tried and tested so it mostly comes down to the requirements of the application and the actual load, which needs monitoring and modeling and testing for fine tuning anyways.
What are the advantages to using FastCGI as opposed to mod_wsgi?
Differences and uses between WSGI, CGI, FastCGI, and mod_python in regards to Python?
articles to read (some old, some new);
http://gunicorn-docs.readthedocs.org/en/latest/deploy.html
https://docs.djangoproject.com/en/dev/howto/deployment/
http://serversforhackers.com/editions/2014/03/25/nginx/
http://blog.dscpl.com.au/2009/05/blocking-requests-and-nginx-version-of.html
http://www.thegeekstuff.com/2013/11/nginx-vs-apache/
http://raspberrywebserver.com/raspberrypicluster/comparing-the-performance-of-nginx-and-apache-web-servers.html
http://www.bearfruit.org/2013/04/19/reddit-is-melting-our-server-heres-what-we-did-nginx-apache-django-and-mysql/
In production, Apache + mod_wsgi or Nginx + mod_wsgi?
http://www.peterbe.com/plog/fcgi-vs-gunicorn-vs-uwsgi
http://www.aosabook.org/en/nginx.html
http://c2.com/cgi/wiki?PrematureOptimization
I'm not sure who is recommending to you that you use both Nginx and Apache, but that's a horrible idea. Whichever you choose, either will simply act as the reverse proxy, serving only static resources and handing everything else off to a subprocess like uwsgi.
I prefer Nginx because it's light-weight and extremely fast out of the box. Apache can be just as good, but requires building from source and knowing exactly what configuration to use to match Nginx. However, Apache has more features and is a little easier to work with. It's really up to you and the needs of your application.
However, whichever you choose, you only need one -- not both.
I think the best choices is virtualenv, uwsgi and nginx.
I changed all my servers now and I'm really happy with performance.
Here is good tutorial on how to setup you webserver
http://senya.pl/2011/03/sexy-nginx-uwsgi-stack-for-django-with-virtualenv/
Question 1) You can use just one server, but for serving static media a solution like lighttpd or nginx will be much faster. I would stick with Apache if you really want to use only one server, it has all the flexibility you need and it is the most common webserver.
Question 2) Depends on your purpose. You can find info here: Deploying Django (fastcgi, apache mod_wsgi, uwsgi, gunicorn)
I tried to follow the suggested link by Nicowernli, but senya.pl was down at that moment.
This seems like a good alternative tutorial....
Gonna try it, just read the first 2 chapters, but seems very complete and really step by step:
http://www.abidibo.net/blog/2012/04/30/deploy-django-applications-nginx-uwsgi-virtualenv-south-git-and-fabric-part-1/
The less, the better.
The best way to deploy Django application over Nginx is use uwsgi. It's pure WSGI and built in supported by new version Nginx.
I have used gunicorn + eventlet as the Python server, and nginx as the reverse proxy with great success. Recently I switched to uWSGI and it seems to be just as good of a solution if not better. I have yet to try apache and Django although I was an apache user prior to using Django. Here is a good write up on getting it all done: http://radtek.ca/blog/django-production-deployment-via-nginx-and-gunicorn-and-virtualenv/
I've installed the coldfusion 9 server locally (the development standalone edition)
I'm trying to get the url rewriting to work, but I don't know what file it's reading (htaccess or web.config), though I'm guessing it's the later if it is reading it at all.
Any idea how to set up the server to use local(to subfolder) rewrite rules?
As has been stated on StackOverflow in other questions, the built-in webserver is primarily for convenience. To take full advantage of production-grade webserver configuration options (like mod_rewrite), your best bet is to install IIS or Apache.
Having said that, the sparse documentation on the built-in webserver can be found here.
I notice that the official recommended book "The Definitive Guide to Django" was written based on mod_python, for both editions.
However, I think most beginners would follow what most people use: mod_wsgi.
I followed their first tutorials, that is, display current time
I have the mod_wsgi and everything setup correctly. But I am still getting the default page regardless how I access to http://domain/time/
Is there any book that is written for mod_wsgi, or did t setup the environment incorrectly?
I know I can begin without using apache, but it would be a headache in the future to deploy apache again...
EDIT
I added the wsgi script and inclued that in the views.py. It seems to work. Is it the right way???
So what is the purpose of having a separate wsgi script anyway?
I know the official guide said that create a folder name such as /apache/ and create django.wsgi...
You don't need a full rewrite of the Django book for mod_wsgi. The ony thing that is different is the apache.conf and the script inside your cgi-bin directory (both aren't directly related to Django, so all the Django parts will apply for both).
But you might probably find it useful to read the general usage/configuration instructions for mod_wsgi, and probably the special notes about django too. If you have some troubles (e.g. some kind of error message in your apache.log) then you might look at the ConfigurationIssues page too.
So what is the purpose of having a separate wsgi script anyway?
Nearly all Python web applications are based on the WSGI specification, which allows your application to be used with CGI, FastCGI, mod_python, mod_wsgi, etc. So, you might have more than one of those scripts - one for each technology for example.
Another thing is, that you can also control a lot of configuration settings inside this script (e.g. forking of additional python processes for increased performance, path to additional python modules or different versions of existing modules) which are normally set by the server administrator (and not the application developer). Thats probably also the main reason why such scripts aren't included directly in the applications.
And the third thing is, that you might have several such wsgi scripts which are deploying the same application with different settings. For example, you might have your application deployed several times for different users, or with different database settings (e.g. production and testing).