I am new to django and this is my first project in django. So far, I have developed a django app. It is working fluently in my local machine but I’m unable to deploy it online.
I have seen many tutorials on internet for deploying the app on server. But none of them seems to be working to me. May be I’m doing something wrong over here.
https://www.youtube.com/watch?v=hBMVVruB9Vs https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/ https://www.digitalocean.com/community/tutorials/how-to-deploy-a-local-django-app-to-a-vps https://www.digitalocean.com/community/tutorials/how-to-run-django-with-mod_wsgi-and-apache-with-a-virtualenv-python-environment-on-a-debian-vps
I followed these tutorials and tried to deploy the app on the server but I always gets 403 forbidden error. I tried to remove this error and referred other stackoverflow answer as well but no success..
403 Forbidden error with Django and mod_wsgi
Apache mod_wsgi error: Forbidden You don't have permission to access / on this server
Django on apache wtih mod_wsgi (Linux) - 403 Forbidden
Installing Django with mod_wsgi
Here is the structure that i created for my django project. I have two apps in my django project and I’m connecting my one app connect with DNS xyz.com
and my second app connect with its subdomain abc.xyz.com
.
Structure
project_folder
|
|->app1
| |->urls.py
| |->template_folder
| |->static_folder
|->app2
| |->urls.py
| |->template_folder
| |->static_folder
|->project_name
|->urls.py
|->wsgi.py
project_name/urls.py
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'^app1/', include('app1.urls')),
url(r'^app2/', include('app2.urls')),
]
app1/urls.py
urlpatterns = patterns('',
url(r'^$', views.index, name='index'),
url(r'^example1/', views.example1),
url(r'^example2/', views.example2),
)
app2/urls.py
urlpatterns = patterns('',
url(r'^example3/', views.example3),
url(r'^example4/', views.example4),
)
Basically what I’m trying to do is that my app1
runs on xyz.com
and my app2
runs on abc.xyz.com
(sub domain). So that all app in the project having same user login. If a user login from one app it will be logged in the second app also.
On my local machine the app runs as
http://localhost:8000/app1/example1
http://localhost:8000/app1/example2
http://localhost:8000/app2/example3
http://localhost:8000/app2/example4
Here is my apache2 conf file that i create on my server
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName xyz.com
DocumentRoot /home/user_name/project_folder/
<Directory />
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher | .py
PythonDebug On
</Directory>
<Directory /home/user_name/project_folder/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /home/user_name/project_folder/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/user_name/project_folder/access.log combined
</VirtualHost>