Wednesday 24 June 2015

How to configure Mezzanine with MySql and wsgi ?

1. Firstly write these commands on terminal

    1.sudo mkdir /var/www/lyfstyle/
    2.sudo mkdir /var/www/lyfstyle/apache

2. sudo vi /var/www/lyfstyle/apache/apache.wsgi
    --Paste this code in apache.wsgi--

    import os
    import sys
   
    path = '/var/www'
    if path not in sys.path:
        sys.path.insert(0, '/var/www/lyfstyle')
        sys.path.append('/var/www/lyfstyle/lyfstyle_env/mezzanine_lyfstyle')
   
    os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
   
    import django.core.handlers.wsgi
    application = django.core.handlers.wsgi.WSGIHandler()

OR 

import os
import sys

path = '/var/www/lyfstyle'

if path not in sys.path:
    sys.path.insert(0, '/var/www/lyfstyle/mezzanine_lyfstyle')
    sys.path.append('/var/www/lyfstyle')

os.environ['DJANGO_SETTINGS_MODULE'] = 'mezzanine_lyfstyle.settings'

#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler()

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


3. Open .conf file by this command ('sudo nano /etc/apache2/sites-available/000-default.conf')
    #And Paste this code   

    listen 8080
    <virtualHost *:8080>
        ServerName dev.lyfstyle
        DocumentRoot /var/www/lyfstyle/mezzanine_lyfstyle
   
        AliasMatch ^/([^/]*\.css) /var/www/lyfstyle/mezzanine_lyfstyle/static/css/
       # create alias for media and static directories
        Alias /media/ /var/www/lyfstyle/mezzanine_lyfs104.236.21.57tyle/media/
        Alias /static/ /var/www/lyfstyle/mezzanine_lyfstyle/static/
   
        <Directory /var/www/lyfstyle/mezzanine_lyfstyle/static>
            Order deny,allow
            Allow from all
        </Directory>
   
        <Directory /var/www/lyfstyle/lyfstyle_env/mezzanine_lyfstyle/media>
            Order deny,allow
            Allow from all
        </Directory>
   
        <Directory /var/www/lyfstyle/mezzanine_lyfstyle>
            Order allow,deny
            Allow from all
        </Directory>
   
        WSGIDaemonProcess mysite.local processes=2 threads=15 display-name=%{GROUP}
        WSGIProcessGroup mysite.local
   
        WSGIScriptAlias /  /var/www/lyfstyle/apache/apache.wsgi
   
    </VirtualHost>

4.After run this command:
   a. sudo a2enmod wsgi


5.  After create Project:
    a. mezzanine-project mezzanine_lyfstyle
    b. cd mezzanine_lyfstyle
    c. python manage.py syncdb
    d. python manage.py collecttemplates
    e. python manage.py collectstatic

6. If you want to change Database like Mysql, sqlite, etc,
   a. open mezzanine_lyfstyle (folder)
   b. open local_settings.py
   c. Than replace this line
      ENGINE": "django.db.backends.sqlite3"
      by
      ENGINE": "django.db.backends.mysql"
     
      And Enter these Settings
     
      NAME: "DBName create in phpmyadmin",
   
      USER: "Username of phpmyadmin",
   
      PASSWORD: "Password of phpmyadmin",


No comments:

Post a Comment