Django using with apache wsgi - django

I want run Django with apache wsgi. But It gives Forbidden error.
/etc/apache2/apache.conf code
WSGIScriptAlias / /home/mazlum/Django/modeller/modeller/wsgi.py
WSGIPythonPath /home/mazlum/Django/modeller
<Directory /home/mazlum/Django/modeller/modeller>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
<Directory /home/mazlum/Django/modeller/statik_dosyalar>
Order deny,allow
Allow from all
</Directory>
<Directory /home/mazlum/Django/modeller>
Order deny,allow
Allow from all
</Directory>

Related

Default Apache displaying instead of homepage

I am having issues trying to deploy my site,.I am still new in both Django , their is a tutorial I have been following on how to deploy the site, Everything works fine except it renders the default Apache page instead of my site when I restart the server.
Here is my project directory
Alias /static /home/brian/src/static
<Directory /home/brian/src/static>
Require all granted
</Directory>
Alias /media /home/brian/src/media
<Directory /home/brian/src/media>
Require all granted
</Directory>
<Directory /home/brian/src/src>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /home/brian/src/src/wsgi.py
WSGIDaemonProcess django_app python-path=/home/brian/src python-home=/home/brian/src/venv
WSGIProcessGroup django_app

ImportError: No module named vanilla_project.settings.dev

Apache. Django. Forum: http://django-machina.readthedocs.io
install with git clone and migrate
Why apache dont see settings.dev file ?
apache2.conf:
WSGIScriptAlias / /var/www/django-machina/example_projects/vanilla/wsgi.py
WSGIPythonPath /var/www/django-machina/example_projects
<Directory /var/www/django-machina/example_projects>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /var/www/django-machina/example_projects/static/
<Location "/static/">
Options -Indexes
</Location>

Django - permission denied

I'm trying to setup Django (Django 1.9.6) on Apache (Apache 2.4.10) in my vps (ubuntu server 15.04).
I followed this guide: HERE
Unfortunately when I try to visit my website, the server return this error (403 Forbidden):`
[authz_core:error] AH01630: client denied by server configuration: /home/user/proj/proj/wsgi.py
I searched everywhere for a solution but everything I tried didn't work.
this is my /etc/apache2/sites-available/000-default.conf file:
Alias /static /home/user/proj/Gestione/static
<Directory /home/user/proj/Gestione/static>
Order deny,allow
Allow from all
</Directory>
<Directory /home/user/proj/proj>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
WSGIDaemonProcess proj python-path=/home/user/proj:/home/user/.local/lib/python3.4/site-p$
WSGIProcessGroup proj
WSGIScriptAlias / /home/user/proj/proj/wsgi.py
Then i found this code on /etc/apache2/apache2.conf, I don't know if this could create problems:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
This is my wsgy.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
application = get_wsgi_application()
I'm NOT using virtualenv
Thanks for help
In Apache 2.4, you should use Require all granted instead of Order deny,allow and Allow from all.
It looks like you are using the old style in two places in 000-default.conf. Try updating it to:
<Directory /home/user/proj/Gestione/static>
Require all granted
</Directory>
<Directory /home/user/proj/proj>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Apache vhosting ubuntu one named entry serving all urls

I have 2 URL's and two django webapps to serve. Using the following example configuration, a get request for www.server2.com results in the page for www.server1.com.
Example Incoming URLS: ( verified in apache logs)
www.server1.com
www.server2.com
vhost confs:
* server1
<VirtualHost *:80>
ServerName www.server1.com
ErrorLog /.../apache/error.log
AliasMatch ^/([^/]*\.css) /opt/ef/static/css/$1
<Directory "/.../apache">
Allow from all
</Directory>
Alias /media/ /...f/media/
Alias /static/ /...f/static/
<Directory /.../static>
Order deny,allow
Allow from all
</Directory>
<Directory /../media>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
WSGIScriptAlias / /...apache/server.wsgi
**server2
<VirtualHost *:80>
ServerName www.server2.com
ErrorLog /.../apache/error.log
AliasMatch ^/([^/]*\.css) /opt/ef/static/css/$1
<Directory "/.../apache">
Allow from all
</Directory>
Alias /media/ /...f/media/
Alias /static/ /...f/static/
<Directory /.../static>
Order deny,allow
Allow from all
</Directory>
<Directory /../media>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
WSGIScriptAlias / /...apache/server.wsgi
Am I matching incorrectly?

problem using WSGIApplicationGroup %{GLOBAL} in apache configuration

im using django with apache and mod_wsgi
i am facing a problem when i use WSGIApplicationGroup %{GLOBAL} in apache configuration file (.conf) . i dont know if i am using this directive correctly or i need to use it in another way , the problem is that i needed to add this directive to fix a problem for xapian as described in this ticket (http://trac.xapian.org/ticket/185) after that the search started to work but all my sites contents got mixed up, meaning site1 content appears on site2.when i removed WSGIApplicationGroup %{GLOBAL} , sites are rendering properly again but search stopped working.
here is my .conf file contents:
NameVirtualHost my_ip_address:80
WSGIApplicationGroup %{GLOBAL}
<VirtualHost my_ip_address:80>
ServerName www.site1.com
ServerAlias site1
WSGIScriptAlias / "/home/sa/www/site1/apache/django.wsgi"
<Directory "/home/sa/www/site1/apache">
Allow from all
</Directory>
Alias /site_media/ "/home/sa/www/site1/media/"
<Directory "/home/sa/www/site1/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
</VirtualHost>
WSGIApplicationGroup %{GLOBAL}
<VirtualHost my_ip_address:80>
ServerName www.site2.com
ServerAlias site2
WSGIScriptAlias / "/home/sa/www/site2/apache/django.wsgi"
<Directory "/home/sa/www/site2/apache">
Allow from all
</Directory>
Alias /site_media/ "/home/sa/www/site2/media/"
<Directory "/home/sa/www/site2/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"
<Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
</VirtualHost>
WSGIApplicationGroup %{GLOBAL}
< VirtualHost my_ip_address:80 >
ServerName www.site3.com
ServerAlias site3
WSGIScriptAlias / "/home/sa/www/site3/apache/django.wsgi"
<Directory "/home/sa/www/site3/apache">
Allow from all
</Directory>
Alias /site_media/ "/home/sa/www/site3/media/"
<Directory "/home/sa/www/site3/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"
<Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
</VirtualHost>
WSGIApplicationGroup %{GLOBAL}
<VirtualHost my_ip_address:80>
ServerName www.site4.com
ServerAlias site4
WSGIScriptAlias / "/home/sa/www/site4/apache/django.wsgi"
<Directory "/home/sa/www/site4/apache">
Allow from all
</Directory>
Alias /site_media/ "/home/sa/www/site4/media/"
<Directory "/home/sa/www/site4/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"
<Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
</VirtualHost>
WSGIApplicationGroup %{GLOBAL}
<VirtualHost my_ip_address:80>
ServerName www.site5.com
ServerAlias site5
WSGIScriptAlias / "/home/sa/www/site5/apache/django.wsgi"
<Directory "/home/sa/www/site5/apache">
Allow from all
</Directory>
Alias /site_media/ "/home/sa/www/site5/media/"
<Directory "/home/sa/www/site5/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
Alias /media/ "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/"
<Directory "/usr/local/lib/python2.6/dist-packages/django/contrib/admin/media/">
Order allow,deny
Options Indexes FollowSymLinks
Allow from all
IndexOptions FancyIndexing
</Directory>
</VirtualHost>
has anybody faced this issue
any suggestions
thanks
Django's implementation prevents multiple Django instances running in same interpreter (application group). Thus if running multiple Django sites on same Apache server and must set WSGIApplicationGroup to %{GLOBAL}, then you MUST use daemon mode and delegate each Django site to a separate daemon process group. Daemon mode is preferred anyway.
Ensure you read:
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide
http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
The latter explaining part why daemon mode is good as far as making code reloading easier.