0
votes

I am trying to deploy my application on webserver(django with apache2 and mod_wsgi). But i got 403 forbidden error while running the site..(Forbidden You don't have permission to access / on this server. Apache/2.4.7 (Ubuntu) Server at 104.131.127.196 Port 80). The structure of my web application looks as:

CASINOVA
|-- Casinova
|   |-- db.sqlite3
|   |-- index.html
|   |-- manage.py
|   |-- casinova
|   |   |-- __init__.py
|   |   |-- __init__.pyc
|   |   |-- settings.py
|   |   |-- settings.pyc
|   |   |-- urls.py
|   |   |-- urls.pyc
|   |   |-- wsgi.py
|   |   `-- wsgi.pyc
|   `-- static

sudo nano /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>
Alias /static /var/www/html/CASINOVA/Casinova/static/
<Directory /var/www/html/CASINOVA/Casinova/static>
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
<Directory /var/www/html/CASINOVA/Casinova>
<Files wsgi.py>
    Require all granted
</Files>
</Directory>
WSGIDaemonProcess Casinova python-path=/var/www/html/CASINOVA/Casinova:/var/www/html/CASINOVA/venv/Casinova/lib/python2.7/si$
WSGIProcessGroup Casinova
WSGIScriptAlias / /var/www/html/CASINOVA/Casinova/casinova/wsgi.py

ServerName 0.0.0.0
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/CASINOVA/Casinova
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
AddHandler cgi-script .py

sudo vi /etc/apache2/apache2.conf

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>
<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
ServerName mydomain.com

vi /etc/hosts.py

127.0.0.1 localhost
104.131.127.196 Casinova
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

#ls -l /var/www/html

drwxr-xr-x 4 root root  4096 Mar 29 08:42 CASINOVA
-rw-r--r-- 1 root root 11510 Mar 30 03:05 index.html
-rw-r--r-- 1 root root    20 Oct 28 01:42 info.php

i have posted the contents from the files default.conf, apache2.conf and hosts.py. What is the mistake in that??

1
Have a look at tail -n 50 /var/log/apache2/error.log, it will gives you hint on what permissions is missing.Cyrbil
The error was "Options ExecCGI is off in this directory". I have cleared it by replacing "Options Indexes FollowSymLinks Includes ExecCGI" with Options Indexes FollowSymLinks MultiViews.. But same forbidden error occurs @Cyrbilshalin
@shalin Probably a stupid question. How can one create the django project structure like in the first code sample in your question?r0xette

1 Answers

0
votes
<Directory /var/www/html/CASINOVA/Casinova/static>
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>

My guess, set ExecCGI for your Django directory, not for /static.

<Directory /var/www/html/CASINOVA/Casinova>
Options ExecCGI
</Directory>