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>
Related
I did set up two websites (hosted locally). I'm on windows so config may look odd.
WSGIPythonHome "C:/var/www/magazyn/env39"
WSGIPythonPath "C:/var/www/magazyn/venv/Lib/site-packages;C:/var/www/magazyn/rootkat/"
ServerName www.magazyn-stolarz.pl
LoadFile "C:/Python39/python39.dll"
LoadModule wsgi_module "C:/var/www/magazyn/env39/lib/site-packages/mod_wsgi/server/mod_wsgi.cp39-win_amd64.pyd"
WSGIScriptAlias /awizacje "C:/var/www2/awizacje/rootkat/awizacje/wsgi.py"
WSGIScriptAlias / "C:/var/www/magazyn/rootkat/magazyn/wsgi.py"
<Directory "C:/var/www2/awizacje/rootkat/awizacje/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /statica "C:/var/www2/static/"
<Directory "C:/var/www2/static/">
Require all granted
</Directory>
<Directory "C:/var/www/magazyn/rootkat/magazyn/">
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static "C:/var/www/static/"
<Directory "C:/var/www/static/">
Require all granted
</Directory>
With that configuration base site works perfectly ("pc-name/") but the second one ("pc-name/awizacje") does not. Main url works like it should but every button sends me to ("pc-name/button-url") and not ("pc-name/awizacje/button-url"). I have set ROOT_URLCONF = 'awizacje.urls' in settings.py. Is there something I am missing? Any way I should change settings to take base url into account?
The problem were hardcodded urls. I changed it so it will use django urls into account.
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
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>
I'm running a small django website with wsgi and apache on an ubuntu server.
I made a minor change to one of my template files in my Django app, and the change is not showing up on my server. However, if I run python manage.py runserver, and curl -l 127.0.0.1:8000, I can see the change. I've tried restarting apache, with no luck.
My urls.py for the page is just
url(r'^page/', TemplateView.as_view(template_name="page.html")),
I've verified that the change is not present by checking on other devices and using incognito mode.
My wsgi.py contains
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_site.settings")
application = get_wsgi_application()
And my /etc/apache2/sites-enabled/000-default.conf contains
<VirtualHost *:80>
ServerName www.site.com
ServerAlias site.com
ServerAdmin webmaster#site.com
Alias /static /opt/django_site/django_site/static
<Directory /opt/django_site/django_site/static>
Require all granted
</Directory>
<Directory /opt/django_site/django_site/django_site>
<Files wsgi.py>
Alias /static /opt/django_site/django_site/static
<Directory /opt/django_site/django_site/static>
Require all granted
</Directory>
<Directory /opt/django_site/django_site/django_site>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess django_site processes=2 threads=15 display-name=%{GROUP} python-path=/opt/django_site:/opt/django_site/django_site/lib/python2.7/site-packages
WSGIProcessGroup django_site
WSGIScriptAlias / /opt/django_site/django_site/django_site/wsgi.py
</VirtualHost>
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>