My Django project is not being served while running on Apache 2.2.
All I can see is the folder structure upon hitting the URL of the domain name.
I've mod_wsgi installed but I think it's not linked well.
Can anybody tell what may be the problem?
Here's the URL of the website
http://ccbstca.ccbst.info/
UPDATE 1
You need to install and enable mod_wsgi for apache. And specify WSGIScriptAlias in apache virtual host config. This link might help:
http://thecodeship.com/deployment/deploy-django-apache-virtualenv-and-mod_wsgi/
ORIGINAL
I think You need to name your wsgi script file as a python file (.py)
And following wsgi code might just help:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ppbase.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
If you can post your apache virtual host config file, it would help in answering this.
Related
I have a Flask application that I'm trying to configure for a production environment. So far, during testing python app.py inside of a virtualenv works fine.
However, I'm beginning to configure the application to begin using UWSGI. When I attempt to start the Flask app using
$ uwsgi -s /tmp/myapplication.sock --manage-script-name --mount /myapplication=app:app
--virtualenv /path/to/my/venv
I get a
ModuleNotFoundError: No module named 'flask_httpauth'
I was wondering if anyone has experience w/ that authentication module and if they have any advice on what I should do. I'm unsure of why the development server starts without an issue, but the uwsgi server (that I pass the same virtualenv that's used for the dev server) runs into import issues
I was able to resolve this issue by setting the home path to my virtualenv directory (.venv in my case):
# uwsgi.ini
home = /Users/floatingrock/Desktop/projects/google_v2/.venv/
If you're wondering, I got the full path using pwd.
I'm trying to figure out if I have set up my mod_wsgi in Embedded mode or Daemon mode and found this page "Reloading Source Code" on the mod_wsgi wiki. It provides a handy script which will tell you what your setup is.
However I'm just not sure about the below sentence from the guide?
"If you are not sure whether you are using embedded mode or daemon
mode, then substitute your WSGI application entry point with sic[the below script]"
What or where is my 'WSGI application entry point'? Where can I copy the script to?
Thanks
Ubuntu: 12.04.5 LTS
Apache: 2.2.22
mod_wsgi Version: 3.3-4ubuntu0.1
i would say WSGI application entry point is the wsgi.py script which is the Gate (stands also for Gateway) from apache into django app and vise versa
it is like
browser < - > server < - > wsgi < - > django
without wsgi the server can serve (render) normal html files but not django app. for this, you need wsgi (Web Server Gateway interface) which is a Gate between django and server
hope this helps
It means wherever the WSGIServerAlias is pointing to, so for Django the wsgi.py file.
I have a Django app set up with Apache and mod_wsgi and it's working fine. I have a Zinnia blog under the same app functioning at the /blog/ subdirectory. So, the blog is www.mysite.com/blog/. What I wanna do is have blog.mysite.com/ point to the /blog/ subdirectory. I'm stumped because I don't know if I should do this through Django or Apache. So, any ideas?
This has to be done with Apache config.
I think you have to setup a Reverse Proxy, which will listen to blog.mysite.com domain and proxy requests to www.mysite.com/blog/.
Unfortunately I'm not an Apache pro, so can't help you with configuration.
Completely from memory and can't test it right now, but in the VirtualHost for blog.mysite.com mount it as:
WSGIScriptAlias / /some/path/wsgi.py/blog
In other words, you still mount it with mod_wsgi, but add '/blog' to the end of the target WSGI script path. This should from memory cause Apache and mod_wsgi to remap things so that '/blog' automatically gets added as part of the URL seen by the Django application. Thus it should map to the blog mapped at that location in the URL namespace in the Django urls.py.
Do note that because you are doing it with a distinct WSGIScriptAlias, it will actually load up a second copy of your Django site in memory in a different sub interpreter than the first one. If that is undesirable, you can use WSGIApplicationGroup directive to override which application group they are both running in and set them to be the same. Preferably use mod_wsgi daemon mode if you aren't already and have them run distinct from the Apache child worker processes as well, as that is generally better than using embedded mode.
I am deploying a Django app on webfaction. All code are uploaded, but sometimes there are still some modification I need to make. My workflow is edit local file in Pycharm and sync the change to remote server (Apache). So, for example, do I need to restart apache every time after changing views.py for the change to take effects?
If you are using modpython yes, you have to reload apache every time or your modules will not be reloaded.
If you are using apache and mod_wsgi then touching the wsgi module is enough.
As other already suggested nginx + gunicorn (or better nginx + uwsgi) are better options than apache + mod_python to serve your django app.
In fact, you do not have to, you just have to « touch » the wsgi.py file (if you are using the mod_wsgi apache2 module). You can do it by uploading the wsgi.py file every time you upload something.
I wanted to start getting into developing with Django, however, I am unable to figure out how to make it work. I have installed apache2, I have tried many tutorials on configuring apache to run Django, but I just do not understand how it all works together. Can someone give me a dummies guide on how to install it, how things work, and why?
The best way to link between Django and Apache is using WSGI. You will need to install the mod_wsgi apache module to do this.
Next step: modify the apache configuration file to designate where you want the root of your django website.
WSGIScriptAlias / /path/to/mysite/apache/myApp.wsgi
Next, you should create the wsgi file. This is what initializes your django application. An example wsgi file looks like this
import sys
import os
sys.path.insert(0,os.path.normpath(os.path.dirname(os.path.abspath(__file__))))
sys.path.insert(0,'/path/to/directory/containing/application')
import django.core.handlers.wsgi
os.environ['DJANGO_SETTINGS_MODULE'] = 'twitmycity.settings'
application = django.core.handlers.wsgi.WSGIHandler()
Once you have this, restart apache
sudo /etc/init.d/apache2 restart
Now, point your browser to the root directory where you established the wsgi handler. This should bring you to the root to your django application. I hope this helps!
Also note, when you make a change to your application, you need to refresh the modified time on the wsgi file to prevent wsgi from just using a cache version of the django application. To do this, execute
touch myApp.wsgi