Firstly, the OS I am working in is Fedora 20.
It seems like every way that is mentioned using Django and Apache is either deprecated, or there is no documentation at all.
I have tried mod_wsgi, and I have it all installed, but there is conflicting documentation. One says you should have a django.wsgi (old Django has this), and more recent documentation say you should have wsgi.py. I have tried both methods and all sorts of different things in the httpd.conf file, nothing works, and it all comes back with Forbidden. Also when just trying the Hello World script it always return an internal server error.
I then tried uwsgi. I can use this to get a uwsgi server up, and this seems to basically work in a similar fashion to just using python3 manage.py runserver, so I installed mod_proxy_uwsgi module for Apache, and there is absolutely no documentation on using this, so I just did something like ProxyPass / wsgi//localhost:8000/ in the httpd.conf. All this does is also returning an internal server error.
The main answer I want is: How exactly do I deploy a Django 1.6 project that uses Python 3, onto Apache?
This didn't work for you? It is listed under Django 1.6... then again, Python 3.x is still kind of iffy for a lot of stuff.
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/
This has been resolved. As it turns out, SELinux was blocking httpd from accessing my Django project. I just used the following command then restarted the computer:
setsebool -P httpd_read_user_content 1
setsebool -P httpd_enable_homedirs 1
This will allow MOD_WSGI to work properly for deployment.
Related
On my dev machine I installed and configured celery within a django app and it works without issues using python3.5 and the django dev webserver.
When I deploy that app to my production server I get an error "no module named celery". On the production server runs python3.6 with apache2 and mod_wsgi.
On both machines I use django-1.11 and celery-4.1.0 within a virtualenv. I suspect that it's either an issue with python3.6 or with mod_wsgi.
I haven't found any real solution to my issue so I'm trying my luck here :)
Cheers
Michael
As a sanity check, make sure the celery is actually installed in the virtual environment you use.
If you are using virtual environment with mod_wsgi, you may need to setup python-home=<path_to_your_virtual_env> in the WSGIDaemonProcess directive.
Example:
WSGIDaemonProcess django python-path=/opt/portal/src/ python-home=/opt/venv/django home=/opt/portal/
You can use the comma-separated list if more than one directory is required in python-path
So, I figured it out. Apparently my virtualenv was pointing to another directory and not to the one apache was using. No idea how this happend. Anyway, after removing and recreating the virtualenv it worked.
Thanks for your help!
i have some reasons witch i am stuck to use django on windows machine. i was wondering how to configure django on a windows sesrver 2012 r2 with iis 8.5. so i followed the tutorial here.
i did what the tutorial says and it is pretty much straight forward what i am gonna do for any kind of application i want to run with iis.
but i get the following error the fastcgi process exited unexpectedly.
here is what i have provided as executable for wfastcgi module:
E:\venvs\...\Scripts\python.exe|E:\venvs\...\Lib\site-packages\wfastcgi.py
i removed the wfastcgi.py part after | from handler mapping and error changed to script processor could not find the config for fastcgi configuration and i figured out the error must be related to the wfastcgi.py file. but i could not find the issue here. so i was wondering what can be the issue? and what are my options are here.
has any one been able to use django on a windows machine?? jsut in case my python version is python 3.6
I had the exact same problem as you but managed to solve this by using Python 3.4.2 version. Follow the exact steps as described in this tutorial Django with IIS and avoid using Python 3.5 or above because it seems that there are compatibility issues. The stack I used was IIS version 10, Windows 10, Python 3.4.2 and Django 1.11.2.
Upgrading wfastcgi to the latest version
pip install wfastcgi --upgrade
solved it for me: Python 3.6.6, wfastcgi 3.0.0
In my Case I was facing the same issue i.e. enter image description here
Mine is a Django App used for APIs that queries data from back-end platforms. This issue was only for specific filters that the API was using in queries while for other values in filters it worked great.
My Config file did not have a fastCgi tag and I added below mentioned part to top of system.webServer in config file. Yes off course it gave few errors here and there corresponding to activityTimeout and requestTimeout. Tried increasing up-to 900 and 601 respectively and then it worked for me. But could not understand cause of the issue as query that API was running for which i was facing this issue was not taking that long at all. I would like to understand that.
<fastCgi>
<application fullPath="D:\Python34\python.exe|D:\Python34\Scripts\wfastcgi.py"
arguments=""
maxInstances="4"
idleTimeout="300"
activityTimeout="900"
requestTimeout="601"
instanceMaxRequests="10000"
protocol="NamedPipe"
flushNamedPipe="false">
</application>
</fastCgi>
I have a Django project which I would like to run on my shared webspace (1und1 Webspace) running on linux. I don't have root access and therefore can not edit apache's httpd.conf or install software system wide.
What I did so far:
installed squlite locally since it is not available on the server
installed Python 3.5.1 in ~/.localpython
installed virtualenv for my local python
created a virtual environment in ~/ve_tc_lb
installed Django and Pillow in my virtual environment
cloned my django project from git server
After these steps, I'm able to run python manage.py runserver in my project directory and it seems to be running (I can access the login screen using lynx on my local machine).
I read many postings on how to configure fastCGI environments, but since I'm using Django 1.9.1, I'm depening on wsgi. I saw a lot about configuring django for wsgi and virtualenv, but all examples required access to httpd.conf.
The shared web server is apache.
I can create a new directory in my home with a sample hello.py and it is working when I enter the url, but it is (of course) using the python provided by the server and not my local installation.
When I change the first line indicating which python version to use to my virtual environment (#!/path/to/home/ve_tc_lb/bin/python), it seems to use the correct version in the virtual environment. Since I'm using different systems for developing and deployment, I'm not sure whether it is a good idea to e.g. add such a line in my djangoproject/wsgi.py.
Update 2016-06-02
A few more things I tried:
I learned that I don't have access to the apache error logs
read a lot about mod_wsgi and django in various sources which I just want to share here in case someone needs them in the future:
modwsgi - IntegrationWithDjango.wiki
debug mod_wsgi installation (only applicable if you are root)
mod_wsgi configuration guide
I followed the wsgi test script installation here - but the wsgi-file is just displayed in my browser instead of beeing executed.
All in all it seems like my provider 1und1 did not install wsgi extensions (even though the support told me a week ago it would be installed)
Update 2016-06-12: I got a reply from support (after a week or so :-S ) confirming that they dont have mod_wsgi but wsgiref...
So I'm a bit stuck here - which steps should I do next?
I'll update the question regularly based on comments and remarks. Any help is appreciated.
Since your apache is shared, I don't expect you can change the httpd.conf but use instead your solution. My suggestion is:
If you have multiple servers you will deploy your project (e.g. testing, staging, production), then do the following steps for each deploy target.
In each server, create a true wsgi.py file which you will never put in versioning systems. Pretty much like you would do with a local_settings.py file. This file will be named wsgy.py since most likely you cannot edit the apache settings (since it is shared) and that name will be expected for your wsgi file.
The content for the file will be:
#!/path/to/your/virtualenv/python
from my_true_wsgi import *
Which will be different for each deploy server, but the difference will be, most likely, in the shebang line to locate the proper python interpreter.
You will have a file named my_true_wsgi to have it matching the import in the former code. That file will be in the versioning systems, unlike the wsgi.py file. The contents of such file is the usual contents of the wsgi.py on any regular django project, just that you are not using that name directly.
With this solution you can have several different wsgi files with no conflict on shebangs.
You'll have to use a webhost that supports Django. See https://code.djangoproject.com/wiki/DjangoFriendlyWebHosts. Personally, I've used WebFaction and was quite happy with it, their support was great and customer service very responsive.
This might be a very dumb question, so please bear with me (there's also no code included either).
Recently, I switched from PHP to Python and fell in love with Django. Locally, everything works well.
However, how are these files accessed when on a real server?
Is the manage.py runserver supposed to be used in a server environment?
Do I need to use mod_python ?
Coming from PHP, one would simply use Apache or Nginx but how does the deployment work with Python/Django?
This is all very confusing to me, admittedly. Any help is more than welcome.
manage.py runserver is only used to speed your development process, it shouldn't be run on your server. It's similar to the newly introduced php's built-in server php -S host:port.
Since you're coming from PHP you can use apache with mod_wsgi in order to serve your django application, there are a lot of tutorials online on how to configure it properly. You might want to read what wsgi is and why it's important.
Has anyone tried using uWSGI with Cherokee? Can you share your experiences and what documents you relied upon the most? I am trying to get started from the documentation on both (uWSGI and Cherokee) websites. Nothing works yet. I am using Ubuntu 10.04.
Edit: To clarify, Cherokee has been working fine. I am getting the error message:
uWSGI Error, wsgi application not found
So something must be wrong with my configurations. Or maybe my application.
Yep, I just recently set this up in Ubuntu Lucid for a Pylons app.
First, I grabbed the latest cherokee from the team PPA.
https://launchpad.net/~cherokee-webserver/+archive/ppa
Next I installed the uwsgi latest into my virtualenv my app lives in via Pip which the uwsgi docs walk you through.
http://projects.unbit.it/uwsgi/wiki/Install
My app was already deployed via mod_wsgi so I was looking to reuse my .wsgi file. I ran into an issue getting the syntax for the uwsgi call right so I got some great help on their mailing list:
http://lists.unbit.it/pipermail/uwsgi/2010-June/000347.html
So I went through the docs in the cherokee cookbook and replaced the uwsgi line with a tweaked version of what was replied in my mailing list question.
It works pretty sweet and almost outperformed mod_wsgi 2x in testing hits to a simple pylons app served page.
Hope that helps.
I got cherokee + uwsgi + django running on lucid. It was a little tricky getting going (figuring out how to point uwsgi to the wsgi file was the hardest part for me, too), but I'm quite happy with the results. I documented the steps I took at http://blog.swwomm.com/2010/06/cherokee-django.html.
There seems to be an issue with the 'make' method of installation on the uwsgi docs. Use 'python uwsgiconfig.py --build' instead. That worked for me. Cherokee, Django running on Ubuntu 10.10.