I started from the Django template application in OpenShift, pushed it to OpenShift, and it ran without issue. After making a couple minor changes to settings.py and /.openshift/action_hooks/deploy, the application no longer runs (404 not found). In the command window, during deployment, I see CLIENT_ERROR: WSGI application not found. The build/deploy succeeds and finishes deployment.
As stated before, the home page now returns a 404. The logs indicate that application.py is not found. If I SSH into the deployment folder, I can find the file exactly where it is reported missing. Any ideas?
What changes did you make? If you changed the entry point you need to update your OPENSHIFT_PYTHON_WSGI_APPLICATION environment variable as per this release article: https://www.openshift.com/blogs/openshift-online-march-2014-release-blog
Related
I have a django app running in a virtualenv on Windows 10 WSL1 (Ubuntu). The python version is 3.6.8.
When using the django development web server, python manage.py runserver, everything is fine. I access that with http://localhost:8000/<my app name>/
But when using apache2, version 2.4.29, months-old javascript code shows up in the browser debugger in a VMxxx file (though I haven't yet found an eval() that supposedly is the cause of the VMxxx being generated).
Also, old server-side code shows up: an old javascript error that resulted from the django python code sending the wrong content type - a bug that was fixed a couple of weeks ago.
I'm accessing apache2 with http://localhost/<my app name>/
I disabled mod_cache:
a2dismod cache
Module cache already disabled.
Also ran htcacheclean -r -l1k and manually looked at the page cache directory, which was empty.
I clear the Chrome cache on every page load, but also get the same errors when using a different browser (Firefox) that wasn't even installed when this old code that's showing up was written.
I put in a HTTP header to request no caching:
<meta http-equiv="Cache-Control" content="no-store" />
The closest thing to a cache that I have configured in Django settings is
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db',
no CACHES settings.
And, of course, I stopped and restarted Apache.
service apache2 stop
service apache2 start
All to no effect.
Where is this old code coming from?
Duh! I had copied (not moved) the entire directory tree to a different location, but didn't update the apache2 configuration, so it was still pointing to the old location.
I'm leaving this up in case someone else makes the same mistake.
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.
I am using a digital ocean virtual server to host a django web app. when you create the droplet, it creates a default app in the directory /home/django/django_project/django. However seeing as this isn't the app I want to host, I put my application files into the directory /home/myproject/myapp and updated the gunicorn and nginx configs to point there. However once updating the urls for this app, I am trying to see it online and noticed that the 404 looked like this:
which states that the URLconf is defined in django_project.urls which I had since deleted out of that 'home/django directory. I have reloaded and restarted gunicorn and nginx in an attempt to get django to realize that the project django_project doesn’t exist any more, but no luck. Has anyone run into this before or have any suggestions as to what I should try next?
I'm using Openshift with Django/Python 3. As of yesterday, I've been unable to update my server. When I push a change, the push is successful. Using SCP to view the files on the server, the updated files are present. Using rhc git-pull downloads the correct files as well. However, the templates are the only thing that actually get changed on the app by the push. No changes to python files cause an effect on the app.
When I try to use 'rhc tail', I get the following error:
OSError: [Errno 98] Address already in use
Searching this error leads me to believe there are multiple server processes running for my app. I'm not sure how to run suggested diagnostics, as I don't control the server. Any ideas? Restarting the app does not fix it. Running rhc stop appears to successfully stop the app, yet my website works unhindered. (I've never tried stopping before, but assume it's supposed to kill the website.)
I found this post this afternoon by somebody having the same problem. It looks like Openshift changed some things on us. I didn't get the memo :(.
Read here:
Openshift March Blog post
#MSDOS, it is similar to your answer but I wanted to post the generic answer that is probably affecting most people.
For me, I just had to rename app.py (my old wsgi entry point) to wsgi.py and everything worked as it should. :) Now I have to figure what they changed to the cron jobs :(
Solved by executing 'rhc app force-stop', then 'rhc app start'. I don't know what caused the problem, but force-stopping it killed the website, and it worked with the new code after starting it again.
I think I solved the problem.
I was using an old django repository, based on https://github.com/openshift/openshift-community-cartridge-python-3.3/blob/master/template/app.py (the link is dead, I mentioned here just for information).
In these old community cartridges, there was a app.py file that started CherryPy or httpd, but now the official django repository doesn't have app.py anymore. (check https://github.com/openshift/django-example)
The app.py doesn't exist anymore because httpd service was added automatically. That's why we were having OSError: [Errno 98] Address already in use.
Removing the app.py from my repository solved the problem.
I was receiving error 500 because my Django application was having errors, not my Python cartridge. That's why I wasn't understanding what was happening. I did a find . -name *.log* in my cartridge and read all logs.
Now my app is working. Good luck!
I'm new at this and stuck. What would cause Django to run without error when I do python manage.py runserver but then throw Internal Server Error when I try to access it through the web? I have another project giving the Congratulations on your first Django-powered page, and I got the same result with the same .wsgi file initially with this project.
It wasn't until I tried to install this script in massivecoupon project that I got Internal Server Error:
http://github.com/coulix/Massive-Coupon---Open-source-groupon-clone
UPDATE:
I set Debug to True in settings.py and now I am getting the django error:
ViewDoesNotExist at /
Could not import massivecoupon.engine.views. Error was: No module named libs
You can use in command line
[user]$ python manage.py check
Regards
Quick answer: check your apache/tomcat access.log and error.log
Next, the other (not really dup) question I quoted above may be a different situation, but I recommend looking into the same things:
Your PYTHONPATH may not contain your project directory, or your DJANGO_SETTINGS_MODULE may not contain 'mysite.website', at least from apache's point of view. Whatever user apache runs as for your website needs to have that set up for it, like in its .profile. Or if you're using mod_python, they need to be set up in the .htaccess or apache's httpd.conf. Or if you're using mod_wsgi, it needs to be in the wsgi setup file -- passenger_wsgi.py or the like -- whatever apache's module will be looking for.
Next:
check if the files it needs to access are accessible by what apache runs your django site as
make sure your database is accessible by that user
and that the database setup/password is accessible by that user
make sure you have SITE_ID=1 set
make sure that you have a site record added into the database
First off check the Apache error log. If there is nothing in Apache error log, due to it being an internal error to your code or Django while handling a request, set DEBUG to True in Django site settings file and restart Apache so details of error display in the browser.