install methods for mod_wsgi and apache - python

I plan to deploy a django app on apache. After having set up apache ,python and django on the dev box,i was going through the tutorials for configuring mod_wsgi. I see that there are two methods-
Installation into Apache
Installation into Python
How do they differ?Apart from the obvious difference that file location will be different,what are the other differences? Going forward,what are the implications of each?
FYI, I do not have any issue with installing/configuring mod_wsgi with
apache. I am just interested in understanding the
implications/differences between installing into python and installing
into apache.

Related

Trying to run 2 Python applications with different Python versions with mod_wsgi

I have in my Apache 2 applications: Django app and MoinMoin app. The first one is running now with Python3.4 and the second one (MoinMoin) with Python2.7
When running dpkg:
ruben#babylon:/var/log/apache2$ dpkg -l | grep wsgi
rc libapache2-mod-wsgi 3.4-4ubuntu2.1.14.04.2 amd64 Python WSGI adapter module for Apache
ii libapache2-mod-wsgi-py3 3.4-4ubuntu2.1.14.04.2 amd64 Python 3 WSGI adapter module for Apache
but Apache can't run the 2 modules at the same time. Django (Python3) is working but MoinMoin (Python2.7) not. How can I fix that?
As you were told already in:
Virtual environment not recognized in WSGIPythonPath
you cannot do that within a single Apache instance.
The simple answer as was described is to run a separate WSGI server such as mod_wsgi-express, or you can use gunicorn our something else as well, and set it up behind the main Apache instance it with Apache proxying to it.
There are a lot of details around doing this and as also suggested, you are better off asking on the mod_wsgi mailing list if you want to do this with mod_wsgi.
If don't wish to use the mod_wsgi mailing list, then you can find some information in:
http://blog.dscpl.com.au/2015/06/proxying-to-python-web-application.html
http://blog.dscpl.com.au/2015/07/redirection-problems-when-proxying-to.html
It talks about proxying to backend WSGI application running in Docker, but all the same principles apply as to setting up the proxy fronted and the issues that arise.

Can't access any pre-existing virtual hosts on apache when mod_wsgi enabled

I'm trying to configure mod_wsgi on Apache in order to deploy a Django application.
My server environment is a modified version of the LAPP stack from http://www.turnkeylinux.org/. mod_wsgi appears to be installed properly. Any apache configuration file changes for my django app have been commented out, so it seems that the problem does not lie with django.
When I enable mod_wsgi none of my pre-existing virtual hosts on ports 80, 443, 12322 (phpPgAdmin) are visible. Disabling mod_wsgi and re-starting Apache brings everything back to life. Apache Tomcat running on port 8080 is fine whether mod_wsgi enabled or not.
Versions are:
Apache 2.2,
mod_wsgi 3.3,
python 3.2 (although 2.7 is installed as well)
I'm probably missing something obvious in the apache config but any help would be appreciated

Django Deployment - Apache setup

I'm working on deploying a django app and I'm looking at a few tutorials which install apache within the virtualenv.
http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
http://michal.karzynski.pl/blog/2013/09/14/django-in-virtualenv-on-webfactions-apache-with-mod-wsgi/
My question is that if I'm trying to deploy to a server that already has Apache installed on it, would installing a separate version of apache within the environment (as you would Django in general) overwrite any of the Apache settings currently on the server?
Using virtualenv doesn't mean installing a separate version of Apache. In fact, that's not even possible, because virtualenv is for Python libraries only.
Your Django app plus all its libraries lives in the virtualenv, but you use the system's Apache to serve it.

Trying to use Django, do I need to install Apache manually if Wamp already did

To make my question clear:
I have had wamp installed, and it brought Apache. Will this Apache be used by others like Django?
If the wamp Apache is enough for others, its Apache is in wamp directory C:\wamp\bin\apache, not sth like C:\programs file...It is ok for django
If I have to install Apache manually for django, will the step be install Apache, install mod_wsgi?
Any help would be greatly appreciated
Strictly interpreted, Django doesn't "use" Apache. Apache is just one way to direct requests (via mod_wsgi, for example) to your django app and returns the result to the user.
The existing Apache install will be fine. It doesn't matter where it is as long as it's running and reachable.
You will need to install mod_wsgi and configure it so that it knows about your Django app.
You can find documentation for configuring Apache and mod_wsgi here:
https://docs.djangoproject.com/en/1.5/howto/deployment/wsgi/modwsgi/
You don't need Apache at all at this point. For development, things work much better if you use the built in development server, as described in the tutorial.

How to configure Django, PostgreSQL, Apache and Python?

I am of the PHP background and just have started to learn Django and Python (and loving it). I always used to install WAMP server for PHP development.
Now I dont know how do I configure Django to use PostgreSQL i.e how to make both communicate with each other. I have run some 'hello world' scripts with django. Curretly I have installed Python, django and PostgreSQL. here is the version information
Python : 2.7.2 & 3.2 (i have installed both)
Django : 1.3.1
PostgreSQL : 9.1.2
Apache : 2.2 (..this is from WAMP server)
Os : Ms Windows 7 32-bits (x86)
Since django has builtin development server is it at all necessary to have apache installed and use it instead of that one? If we use the built-in server how we are supposed to configure it for PostgreSQL?.
It is not necessary to have apache installed to develop on django. In fact it is often easier to use the development server because it is single threaded, lightweight, and extremely easy to use. python manage.py runserver 0.0.0.0:8080 to run on localhost port 8080, and your code is easily debuggable.
In django you dont configure your server for a database. You configure your project for a database. All database configurations are kept in the settings.py file located in your main project. Page one of the tutorial explains how to set up a database for your django prject. YOu have to specify, database name, host, port, user and password in your settings.py file.
https://docs.djangoproject.com/en/dev/intro/tutorial01/#database-setup
I would suggest walking through the django tutorial as it addresses most of the issues in setting up development on a new django project.
https://docs.djangoproject.com/en/dev/intro/tutorial01/
I recently deployed a Django based project and found this tutorial to be very helpful and concise.
Django virtualenv Apache2 mod_wsgi
And if you have CentOS, then you can install mod_wsgi as mentioned here:
Django Deployment - Setup mod_wsgi on CentOS
Getting Django to run on Apache requires getting Python to interpret that, you can do this with WSGI. follow the tutorial found here:
https://code.djangoproject.com/wiki/django_apache_and_mod_wsgi
there are other methods to deploy this, you can find here:
https://docs.djangoproject.com/en/dev/howto/deployment/

Categories

Resources