setting up django with wsgi on centos, alternative to wsgi

Hello amazing people, after many a brainstorm, discussion and consideration I have decided on django for a project. The documentation for django has been great thus far, and things have come together quite nicely. All went well until I found my simple little application to be ready to be used in production.

I need the program to be hosted on a centos 7 server, preferrably using python3.6, and hosted as a wsgi application with httpd. I however, am not really all that up to speed with servers and apache and wsgi and all of that, and all of my attempts ended up in things like disabling selinux, 500 internal server errors, manually compiling a bunch of programs (including mod_wsgi itself?), and I’m wondering if there’s an easier way to install django for a production server. maybe a middleground between using the development server and the complicated procedure to set it up with wsgi.

Any suggestions are very much appreciated.

Some of the general issues you describe are CentOS / RedHat issues (like dealing with SELinux). If SELinux is a layer of protection you’re interested in using, then you probably should learn how to work with it rather than just disabling it. (However, if it’s not a protection layer you’re going to want, I don’t see any problems with disabling it.)

A few people around here have recommended gunicorn as the “Django server” as being easier to install / configure. (I can’t say - we use uwsgi. I will admit that uwsgi can be a bit “fiddly” to set up, but it works well for us.)

We also use nginx instead of Apache httpd. I think nginx is easier to configure.

But, none of it is trivial. I’ve commented before that a production-quality deployment is probably the hardest thing you’ll ever do with Django - and that’s mostly because there’s no “one way” to do it. You’ll make a lot of decisions without a tremendous amount of guidance, and that’s because of all the deployment options and the interactions between your intended deployment and the environment in which it’s going to run.

And you’re going to learn a lot along the way…

1 Like

Thank you for this information :slight_smile: In this case I think I’ll have to come to the conclusion that I’m just not qualified to set up a server at this time.

You may not have the current knowledge, but I doubt you’re “not qualified”.

We do help with deployment issues here too. If you want to walk through the process with us providing assistance along the way, you’re more than welcome to do so. Anyone who has done a deployment remembers how much “fun” it can be…

Well If you don’t mind I would really appreciate that effort. I really need this to work, but can’t justify spending a lot more time on this :). At this point I’ve added third party repositories to centos to install python3.6, and virtualenv-3.6. I have mariadb installed, as well as httpd. I’ve compiled and installed the mod_wsgi module for httpd, and that has currently been loaded and is running. The django version I’ve also gotten installed is 3.1.7 (which i’ve installed through pip), and I’ve created a project with “django-admin startproject .”. setting up a development server with manage.py runserver 0.0.0.0:80 works as it should, but whatever I try I can’t get it to work with apache yet. I started following the steps listed in the guide at:
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/modwsgi/
However, If I want to make this as easy as possible for myself (I don’t have a lot of experience setting up servers), I think my next step would be not to continue with the steps for mod_wsgi and apache, but with the steps located on
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/gunicorn/
? Thanks a lot in advance, I’m hoping I’ll eventually be able to at least show a working server without having to worry about security too much :slight_smile:

<opinion>I think it would be easier if you switched from Apache to nginx.<opinion>

Uninstall Apache, install nginx, and see the docs at Deploying Gunicorn — Gunicorn 20.1.0 documentation

Then, if you’re still having errors, post a complete description of the error (including the full text of any error message(s) you may receive) here, and we’ll see what we can do.

I’ll get to it immediately :slight_smile: I’m not really bound to apache so that would work for me. hopefully that’ll prove to be a bit less painful ^ ^