You are on page 1of 13

SETUP GEREGE ENVIRONMENT ON MAC

1). First of all, we need to install Homebrew

Open terminal and type:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the
installation process.

2). Install MySql 5.7 by typing:

brew install mysql@5.7

Configure and link mysql from brew services list:

brew tap homebrew/services

brew services start mysql@5.7

brew link mysql@5.7 --force

Check the mysql correctly configured:

mysql –V

Configure password for mysql root user:

mysqladmin -u root password 'yourpassword'.

Done.

3). Install pip and django.

sudo easy_install pip

Sudo pip install django==1.7.11

4). Clone & Download gerege packages

4.1). Go to your workspace and type:


sudo git clone https://git.nmma.co/Gerege/gerege.git

4.2) Create “packages” directory inside gerege/

mkdir gerege/packages

cd gerege/packages

sudo git clone https://git.nmma.co/NMG/nmteccontrib

cd ..

5). Install mysqlclient to connect mysql with django

pip install mysqlclient

Or

Download file below and extract

https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e578
96815dbb1988ad/mysqlclient-1.3.13.tar.gz

Go to Downloads folder and navigate to the file

Cd ~/Downloads/mysqlclient-1.3.13

Python setup.py build

Sudo python setup.py install

6). Install requirement files using pip

sudo pip install -r requirements.txt

7). scripts хавтсанд байгаа init_project shell-ийг ажиллуулна.

./scripts/init_project

Yes,yes,yes....

"Do you wish to change permission for www-data user?"

No

8) . /application/gerege/local_settings.py болон /core/gerege_core/local_settings.py хавтсууд руу орж


өгөгдлийн сангийн тохиргоог хийнэ (edit files).

хэрвээ тус бүрийн local_settings.py файлууд байхгүй бол доорх байдлаар үүсгэнэ.
application/gerege/local_settings.py:

#!/usr/bin/env python

# -*- coding: utf-8 -*-

CORE_DB_NAME = ‘gerege’

CORE_DB_USER = ‘mysql-iin username’

CORE_DB_PASSWORD = ‘mysql-iin password’

DB_NAME = ‘gerege’

DB_USER = 'mysql-iin username'

DB_PASSWORD = 'mysql-iin password’

SITE_DB_PREFIX = 'gerege_'

INSTALLED_APPS = () # your custom INSTALLED_APPS

MIDDLEWARE_CLASSES = () # your custom MIDDLEWARE_CLASSES

DEBUG = True

STABLE = False

core/gerege_core/local_settings.py:
#!/usr/bin/env python

# -*- coding: utf-8 -*-

DB_NAME = ‘gerege’

DB_USER = 'mysql-iin username'

DB_PASSWORD = 'mysql-iin password’

SITE_DB_PREFIX = 'gerege_'

INSTALLED_APPS = () # your custom INSTALLED_APPS

MIDDLEWARE_CLASSES = () # your custom MIDDLEWARE_CLASSES

DEBUG = True

STABLE = False

9). Install your favorite mysql database navigator. I recommend using Sequel Pro (Standard for mac)

Download from the official website and install https://sequelpro.com/download

Open Sequel Pro and setup following:

Name: gerege

Host: 127.0.0.1

Username: root

Password: your-fucking-password

And click Connect.


10). "gerege" нэртэй utf8_unicode_ci database үүсгэнэ.

If you are using Sequel Pro:

Database - > Add Database

11). gerege database -д table-үүд үүсгэнэ.

./core/manage.py virginize

You must get this error #1:

ValueError: Unable to configure handler 'file': [Errno 2] No such file or directory:


'/Users/nbst/Documents/gerege/core/.store/logs/info.log'

Create that specific directories and file.

You must get this error #2:

if settings_dict['HOST'].startswith('/'): AttributeError: 'NoneType' object has no attribute 'startswith'


django

Erase gerege/core/gerege_core/settings.py contents and copy this:

# -*- coding: utf-8 -*-

# vim:foldmethod=marker

import os

import sys

import local_settings

PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))

GEREGE_ROOT = os.path.dirname(PROJECT_ROOT)

sys.path.append(os.path.join(GEREGE_ROOT, 'contribs'))
def get_local(attr_name, default_value=None):

if hasattr(local_settings, attr_name):

return getattr(local_settings, attr_name)

return default_value

COMMAND = len(sys.argv) > 1 and sys.argv[1] or False

RUNNING_MODE = 'server'

if sys.argv[0].endswith('manage.py'):

RUNNING_MODE = 'shell'

if COMMAND == 'runserver':

RUNNING_MODE = 'localhost'

# DATABASES {{{1

DATABASES = {

'default': {

'ENGINE': 'django.db.backends.mysql',

'NAME': get_local('DB_NAME'),

'USER': get_local('DB_USER'),

'PASSWORD': get_local('DB_PASSWORD'),

'HOST': '', # empty string for localhost

'PORT': '', # empty string for default

'TEST_CHARSET': 'utf8',
'TEST_COLLATION': 'utf8_unicode_ci',

#'OPTIONS': {'init_command': 'SET storage_engine=INNODB'},

SITE_DB_PREFIX = get_local('SITE_DB_PREFIX', 'gerege_')

# MIDDLEWARE_CLASSES {{{1

MIDDLEWARE_CLASSES = (

'nmteccontrib.ajaxcontent.middleware.AjaxContentMiddleware',

'django.contrib.sessions.middleware.SessionMiddleware',

'apps.general.middleware.BeforeMiddleware',

'django.middleware.common.CommonMiddleware',

'django.middleware.csrf.CsrfViewMiddleware',

'django.middleware.clickjacking.XFrameOptionsMiddleware',

'apps.users.middleware.UserMiddleware',

'apps.general.middleware.AfterMiddleware',

) + get_local('MIDDLEWARE_CLASSES', ())

# INSTALLED_APPS {{{1

INSTALLED_APPS = (

# django contribs

'django.contrib.staticfiles',

'django.contrib.sessions',

# contribs
'nmteccontrib.ajaxcontent',

'nmteccontrib.django_crontasks',

'nmteccontrib.assets',

'nmteccontrib.mail',

'nmteccontrib.pagination',

# project apps

'apps.general',

'apps.users',

'apps.sites',

'apps.companies',

'apps.invoices',

) + (get_local('INSTALLED_APPS', ()), ())['test' in sys.argv]

# LOGGING {{{1

# A sample logging configuration. The only tangible logging

# performed by this configuration is to send an email to

# the site admins on every HTTP 500 error when DEBUG=False.

# See http://docs.djangoproject.com/en/dev/topics/logging for

# more details on how to customize your logging configuration.

LOG_NAME = 'info'

LOGGING = {

'version': 1,

'disable_existing_loggers': False,

'filters': {

'require_debug_false': {

'()': 'django.utils.log.RequireDebugFalse'
}

},

'formatters': {

'simple': {

'format': '%(levelname)s %(asctime)s %(message)s'

},

},

'handlers': {

'mail_admins': {

'level': 'ERROR',

'filters': ['require_debug_false'],

'class': 'django.utils.log.AdminEmailHandler'

},

'console': {

'level': 'DEBUG',

'class': 'logging.StreamHandler',

'formatter': 'simple'

},

'file': {

'level': 'INFO',

'class': 'logging.FileHandler',

'formatter': 'simple',

'filename': os.path.join(os.path.join(PROJECT_ROOT, '.store', 'logs', 'info.log')),

},

},

'loggers': {

'django.request': {

'handlers': ['mail_admins'],

'level': 'ERROR',
'propagate': True,

},

'info': {

'handlers': ['file', 'console'],

'level': 'INFO',

'propagate': True,

},

# EMAIL {{{1

EMAIL_USE_TLS = True

EMAIL_HOST = get_local('EMAIL_HOST', 'smtp.gmail.com')

EMAIL_HOST_USER = get_local('EMAIL_HOST_USER', 'newmediagroupit@gmail.com')

EMAIL_HOST_PASSWORD = get_local('EMAIL_HOST_PASSWORD', 'newMEDIA123')

EMAIL_PORT = get_local('EMAIL_PORT', 587)

EMAIL_SENDER = get_local('EMAIL_SENDER', EMAIL_HOST_USER)

# CACHE CONFIGURATION {{{1

CACHES = get_local('CACHES', {

'default': {

'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',

'LOCATION': os.path.join(PROJECT_ROOT, '.store', 'cache'),

'TIMEOUT': 60 * 60 * 24 * 30, # a month

'KEY_PREFIX': 'gerege-core',

})
# FREEZED CONFIGS {{{1

# GLOBAL

NMTECCONTRIB = {}

ALLOWED_HOSTS = ['app.gerege.biz', 'app.gerege.agency']

ADMINS = (

('Delgermurun', 'delgermurun.p@nmtec.co'),

('Batnasan', 'batnasan.b@nmtec.co'),

DISABLE_REGISTER = get_local('DISABLE_REGISTER', False)

SITE_ROOT = os.path.join(GEREGE_ROOT, 'sites')

SITE_STATIC_ROOT = os.path.join(GEREGE_ROOT, 'sites_static', 'sites')

SITE_MEDIA_ROOT = os.path.join(GEREGE_ROOT, 'application', '.store', 'media')

RESTRICTED_SUB_DOMAINS = get_local('RESTRICTED_SUB_DOMAINS', ['app', 'launch', 'www', 'dev',


'_default', 'static'])

DOMAIN = get_local('DOMAIN', 'gerege.biz')

DEBUG = get_local('DEBUG', False)

STABLE = get_local('STABLE', True)


ROOT_URLCONF = 'gerege_core.urls'

WSGI_APPLICATION = 'gerege_core.wsgi.application'

SECRET_KEY = '-$rgcj1cb!tl07)9sa8r&%zv+$08u%=t_xx6i7$)j%9(-9i8#1'

TESTING = 'test' in sys.argv

RUNNING_DEVSERVER = 'runserver' in sys.argv

# TEMPLATE, STATIC, MEDIA

TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates'),)

TEMPLATE_DEBUG = DEBUG

STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, 'static'),)

STATIC_ROOT = os.path.join(PROJECT_ROOT, '.store', 'static')

STATIC_URL = get_local('STATIC', '/static/')

MEDIA_ROOT = os.path.join(PROJECT_ROOT, '.store', 'media')

MEDIA_URL = get_local('MEDIA', '/media/')

# LANGUAGE

TIME_ZONE = 'Asia/Ulaanbaatar'

LANGUAGE_CODE = 'mn'

USE_I18N = True

USE_L10N = True

USE_TZ = False
LOGIN_URL = '/login/'

LOGIN_REDIRECT_URL = '/'

ASSETS_AUTO_COMPRESS = False

NMTECCONTRIB = {}

CRON_TASKS = (

'apps.general.cron.AdminPasswordChangeCron',

'apps.general.cron.CleanupCron',

And run it again!

You may get this error again:

ValueError: Unable to configure handler 'file': [Errno 2] No such file or directory:


'/Users/nbst/Documents/gerege/core/.store/logs/info.log'

Then create that specific directories and file.

12). Create site

./core/manage.py create-site sitename

DONE!

You might also like