Getting forbidden You don't have permission to access / on this server - django

i'm trying to deploy django application using apache & mod_wsgi on centos 7.
I have added the following lines in the httpd.conf file:
Alias /robots.txt /home/centos/sunlife/static/robots.txt
Alias /favicon.ico /home/centos/sunlife/static/favicon.ico
#Alias /media/ /path/to/mysite.com/media/
Alias /static/ /home/centos/sunlife/static/
<Directory /home/centos/sunlife/static>
Require all granted
</Directory>
#<Directory /path/to/mysite.com/media>
#Require all granted
#</Directory>
WSGIScriptAlias / /home/centos/sunlife/sunlife/wsgi.py
<Directory /home/centos/sunlife/sunlife>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
While trying to access the ip, I am getting Forbidden You don't have permission to access / on this server.

Related

Static files 404 in production

None of my static files are loading after deploying my app. When I check in the dev tools they're all 404.
I ran python3 manage.py collectstatic
settings.py
STATIC_URL = '/static/'
STATIC_ROOT = '/srv/example/static/'
My static folder has the following permissions and ownership:
drwxr-xr-x 8 root root 4096 Nov 17 23:28 static
My /etc/apache2/sites-enabled/example.conf:
<VirtualHost *:80>
ErrorLog ${APACHE_LOG_DIR}/example-error.log
CustomLog ${APACHE_LOG_DIR}/example-access.log combined
WSGIDaemonProcess example processes=2 threads=25 python-ho>
WSGIProcessGroup example
WSGIScriptAlias / /srv/example/example/wsgi.py
Alias /robots.txt /srv/example/static/robots.txt
Alias /favicon.ico /srv/example/static/favicon.ico
Alias /static /srv/example/static/
Alias /media /srv/example/media/
<Directory /srv/example/example>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
<Directory /srv/example/static>
Require all granted
</Directory>
<Directory /srv/example/media>
Require all granted
</Directory>
</VirtualHost>
did you check after "collectstatic" that the files are in the folder /static/?
I am not sure if it matters ... but my Alias has no slash at the end:
Alias /static /.../...../static

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>

Unable to connect to WSGI daemon process 'sampleapp'

I tried to install django in ubuntu server and i had 503 error in error.log
my apache2.conf is:
<VirtualHost x.xxx.xxx.xxx:8080>
ServerAlias www.samplesite.com
ServerAdmin info#samplesite.com
DocumentRoot /var/www/sampleapp/
ScriptAlias /cgi-bin/ /var/www/sampleapp/cgi-bin/
Alias /vstats/ /var/www/sampleapp/stats/
Alias /error/ /var/www/sampleapp/document_error
#SuexecUserGroup admin admin
CustomLog /var/log/apache2/domains/sampleapp.ir.bytes bytes
CustomLog /var/log/apache2/domains/sampleapp.ir.log combined
ErrorLog /var/log/apache2/domains/sampleapp.ir.error.log
WSGIProcessGroup sampleapp
WSGIScriptAlias /sampleapp /var/www/sampleapp/sampleapp/wsgi.py
WSGIDaemonProcess sampleapp python-path=/var/www/sampleapp:/var/www /sampleapp/envme/lib/python3.4/site-packages
<Directory /var/www/sampleapp/static/>
Require all granted
</Directory>
<Directory /var/www/sampleapp/media/>
Require all granted
</Directory>
<Directory /var/www/sampleapp/sampleapp/>
<Files wsgi.py>
require all granted
</Files>
</Directory>
<Directory /var/www/sampleapp/>
AllowOverride All
Options +Includes +Indexes +ExecCGI
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and i have this error in my error.log:
(13)Permission denied: [client x.xxx.xx.xxx:59504] mod_wsgi (pid=26905): Unable to connect to WSGI daemon process 'sampleapp' on '/var/run/apache2/wsgi.26899.0.1.sock' as user with uid=1005.
I lost 2 days trying to solve it,
You can refer this url,
http://code.google.com/p/modwsgi/wiki/ConfigurationIssues#Location_Of_UNIX_Sockets
Adding this,
WSGISocketPrefix run/wsgi
will solve the error. The solution is to change where the socket files are kept to a location where Apache user can read them.