I have developed a project (named pubnet) in django and is trying deploy it 
on production server(currently my ubuntu 14.04 machine for user testing). 
The project did work on built-in django server during development but on 
deploying, it fails to work. All it displays is the apache index.html page 
on localhost and not the django welcome page. 

Here are the steps that I have performed:
*INSTALLATIONS:*

   - installed apache2
   - installed 
   ​lib​
   apache2-mod-wsgi
   - installed mysql-server
   - created a database named pubnet
   - created a django project named pubnet inside /var/www/html/


*FILES CREATED/ALTERED:*

   - *vi /etc/apache2/sites-available/pubnet.conf*

 <VirtualHost *:80>

ServerName pubnet
ServerAlias pubnet.com
ServerAdmin root

DocumentRoot /var/www/html/pubnet

Alias /media/ /var/www/html/pubnet/media/
Alias /static/ /var/www/html/pubnet/static/

<Directory /var/www/html/pubnet>
    require all granted
</Directory>

WSGIDaemonProcess pubnet.com processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup pubnet.com

WSGIScriptAlias / /var/www/html/pubnet/pubnet/pubnet.wsgi

<Directory /var/www/html/pubnet/pubnet>
   require all granted
</Directory>

ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/custom.log combined

</VirtualHost>

   - *vi /var/www/html/pubnet/pubnet/pubnet.wsgi*

import os
import sys
sys.path = ['/var/www/html/pubnet'] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'pubnet.settings'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

   - *vi /var/www/html/pubnet/pubnet/wsgi.py:*
   
import os
import sys
import django.core.handlers.wsgi

# Calculate the path based on the location of the WSGI script.
apache_configuration= os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append(project)

# Add the path to 3rd party django application and to django itself.
sys.path.append('/var/www/html/pubnet')
os.environ['DJANGO_SETTINGS_MODULE'] = 'pubnet.apache.override'

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pubnet.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

   - *vi /etc/hosts:*

*127.0.0.1       localhost*
*192.168.13.80   pubnet.com <http://pubnet.com>*

   - *sudo a2ensite pubnet*
   - *sudo service apache2 reload*
   - *sudo service apache2 restart*
   

   - *settings.py:*

ALLOWED_HOSTS = ['localhost', '127.0.0.1', '127.0.1.1', '192.168.13.80', '
pubnet.com']

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'pubnet',
        'USER': 'root',
        'PASSWORD': 'PASSWORD',
        'HOST': '127.0.0.1',   # Or an IP Address that your DB is hosted on
        'PORT': '3306',
    }
}

*​NOTE: *While working on it last Saturday, it started working and I was 
also able to display the django admin page on the browser. However, very 
strangely on Monday it failed to work. Since then I have tried almost all 
links and the suggestions in google, installed, uninstalled everything but 
failed to make it work. 

Any help would be highly appreciated.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5d36aaf5-01de-402e-9a1a-02fd6c61bdbf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to