my django apache deployment serve django templates as static html
I am getting below tags on my webpage
{% if cmd %} {{ cmd }} {% endif %} {% if command %} {{ command}}
Running python script baby....wait...
{% endif %} {% if documents %}
{% for document in documents %} {% endfor %}
{% else %}
No documents.
{% endif %} {% csrf_token %}
{{ form.non_field_errors }}
Is there something wrong with my deployment configuration
I am using Apache2 on my locale ubuntu box for deployment.
Finally I got it working with below details
Create a .wsgi file(like mysite.wsgi) for you project with below information at any location preferably inside project
import os
import sys
path = '/home/synerzip/Documents/pavanWork/mysite'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Create a .conf file inside /etc/apache2/sites-available/
<VirtualHost *:80>
WSGIScriptAlias / /path/to/.wsgi # file which is created in above step
ServerName mysite.com # Name of your site
Alias /static/ /path/to/your/project /static/files
<Directory /path/to/your/project />
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restart apache server
my deployment's settings: Project structre:
sites/
└── motivate-me.local
├── project
│ ├── api
│ │ ├── __pycache__
│ │ └── v1
│ │ └── __pycache__
│ └── project
│ └── __pycache__
└── static
├── admin
│ ├── css
│ ├── img
│ │ └── gis
│ └── js
│ └── admin
└── rest_framework
├── css
├── img
└── js
django.wsgi:
import os
import sys
sys.path.append('/home/mikhail/sites/motivate-me.local/')
sys.path.append('/home/mikhail/sites/motivate-me.local/project/')
sys.path.append('/usr/local/lib/python3.3/dist-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
My hosts:
127.0.0.1 localhost
127.0.0.2 www
127.0.0.3 loss-weight.local
127.0.0.4 test.local
127.0.0.5 motivate-me.local
127.0.1.1 ube-work
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My virtual host:
<VirtualHost 127.0.0.5:80>
ServerAdmin webmaster@motivate-me.local
ServerName motivate-me.local
ServerAlias motivate-me.local
WSGIScriptAlias / /home/mikhail/sites/motivate-me.local/project.wsgi
WSGIPassAuthorization on
DocumentRoot /home/mikhail/sites/motivate-me.local
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/mikhail/sites/motivate-me.local/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /static/ /home/mikhail/sites/motivate-me.local/static/
<Location "/static/">
Options -Indexes
</Location>
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
my django apache deployment serve django templates as static html
I am getting below tags on my webpage
{% if cmd %} {{ cmd }} {% endif %} {% if command %} {{ command}}
Running python script baby....wait...
{% endif %} {% if documents %}
{% for document in documents %} {% endfor %}
{% else %}
No documents.
{% endif %} {% csrf_token %}
{{ form.non_field_errors }}
Is there something wrong with my deployment configuration
I am using Apache2 on my locale ubuntu box for deployment.
Finally I got it working with below details
Create a .wsgi file(like mysite.wsgi) for you project with below information at any location preferably inside project
import os
import sys
path = '/home/synerzip/Documents/pavanWork/mysite'
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Create a .conf file inside /etc/apache2/sites-available/
<VirtualHost *:80>
WSGIScriptAlias / /path/to/.wsgi # file which is created in above step
ServerName mysite.com # Name of your site
Alias /static/ /path/to/your/project /static/files
<Directory /path/to/your/project />
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
restart apache server
my deployment's settings: Project structre:
sites/
└── motivate-me.local
├── project
│ ├── api
│ │ ├── __pycache__
│ │ └── v1
│ │ └── __pycache__
│ └── project
│ └── __pycache__
└── static
├── admin
│ ├── css
│ ├── img
│ │ └── gis
│ └── js
│ └── admin
└── rest_framework
├── css
├── img
└── js
django.wsgi:
import os
import sys
sys.path.append('/home/mikhail/sites/motivate-me.local/')
sys.path.append('/home/mikhail/sites/motivate-me.local/project/')
sys.path.append('/usr/local/lib/python3.3/dist-packages')
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings'
from django.core.handlers.wsgi import WSGIHandler
application = WSGIHandler()
My hosts:
127.0.0.1 localhost
127.0.0.2 www
127.0.0.3 loss-weight.local
127.0.0.4 test.local
127.0.0.5 motivate-me.local
127.0.1.1 ube-work
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My virtual host:
<VirtualHost 127.0.0.5:80>
ServerAdmin webmaster@motivate-me.local
ServerName motivate-me.local
ServerAlias motivate-me.local
WSGIScriptAlias / /home/mikhail/sites/motivate-me.local/project.wsgi
WSGIPassAuthorization on
DocumentRoot /home/mikhail/sites/motivate-me.local
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/mikhail/sites/motivate-me.local/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /static/ /home/mikhail/sites/motivate-me.local/static/
<Location "/static/">
Options -Indexes
</Location>
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 ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
0 commentaires:
Enregistrer un commentaire