Skip to content

kungfuloung/kfl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

this is goodddd

Djages = Django + Mongodb + RESTful API

Djages is an app base on django-nonrel and mongodb-engine. You can easily create a web app with power of Django, Mongodb and a RESTful API framework.

Requirement (for local dev)

For Djages, all you need is python and a virtual environment. On Mac, you can follow this post. and execute following command for PIL (you may need homebrew to execute brew install):

$ brew install libjpeg

On Ubuntu, you can just do

$ sudo apt-get install python-software-properties python g++ git make python-pip python-virtualenv python-imaging build-essential python-dev libxml2-dev libxslt-dev python-lxml libssl-dev libpam0g-dev nginx apache2 libapache2-mod-wsgi libgraphicsmagick++-dev libjpeg8-dev

For PIL in ubuntu, you may need to do this.

# sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
# sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
# sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

Create a virtual enviroment for Djages.

$ virtualenv djagesenv

and activate it

$ source ./djagesenv/bin/activate

or use mkvirtualenv if you have installed virtualenvwrapper

$ mkvirtualenv djagesenv

to deactivate virtualenv

$ deactivate

You may need to install mongodb. Tutorial: OS X, Ubuntu

Getting Start (for local dev)

$ git clone https://github.com/optfantasy/djages
$ cd djages
$ pip install -r requirements.txt
# If you encounter error when install PIL, the following command might help you:
# $ pip install -U PIL --allow-external PIL --allow-unverified PIL
# !! YOUR_APP_NAME should be all in lowercase without underscore or other special chars.
$ ./startnewsite YOUR_APP_NAME
$ ./manage runserver

Create Superuser (for local dev)

$ ./manage createsuperuser

Setup Your Git Repository

Suppose you have a git repository: https://github.com/example/repository, with username git_user.

  1. Edit fabile.py. Change
env.repo_url = "https://github.com/optfantasy/djages"

to

env.repo_url = "https://git_user@github.com/example/repository"
  1. Edit .git/config Change
url = git@github.com:optfantasy/djages.git

to below if you use github:

url = git@github.com:example/repository.git

or this if you use bitbucket:

url = ssh://git@bitbucket.org/example/repository.git
  1. Commit your change and push to git repository for next step.

Deploy to Ubuntu Server -- Setup

Suppose you have an ubuntu server with IP/domain example.com.

  1. Edit file "deploy": change YOUR_SERVER_IP_OR_DOAMIN to "example.com" and MONGO_DB_IP to "localhost".

  2. Generate a SSH key pair at your local computer. Remember the public key path, it will be used in next step.

$ ssh-keygen -t rsa -C "your_email@example.com"
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): YOUR_APP_NAME.pem [Press enter]
$ ssh-add YOUR_APP_NAME.pem

The file YOUR_APP_NAME.pem can be shared with your coworker, so that they can also deploy server.

  1. Initialize site environment by given a username who has sudo permission and file path of public key.
$ ./deploy init USER_WITH_SUDO_PERMISSION PATH_OF_PUBLIC_KEY

If your server is in AWS ("ubuntu" is the user who has sudo permission), the initialize command will be like this:

$ ./deploy init ubuntu ~/.ssh/YOUR_APP_NAME.pem.pub

for Digital Ocean ("root" is the user who has sudo permission)

$ ./deploy init root ~/.ssh/YOUR_APP_NAME.pem.pub

Deploy to Ubuntu Server -- Deploy Project

Login to remote server

$ ssh YOUR_APP_NAME@YOUR_SERVER_IP_OR_DOAMIN

and edit .git/config from

url = https://git_user@github.com/example/repository

to

url = git@github.com:example/repository.git

and add ssh key to github or bitbucket. After this, you can deploy your server without enter git account password.

Deploy your code to your ubuntu server.

$ ./deploy

After deploy, for ubuntu 13.10, you may need to edit /etc/apache2/apache.conf, comment out these lines

# <Directory /> 
#       Options FollowSymLinks 
# 		AllowOverride None 
# 		Require all denied 
# </Directory> 
# <Directory /usr/share> 
# 		AllowOverride None 
# 		Require all granted 
# </Directory> 
# <Directory /var/www/> 
# 		Options Indexes FollowSymLinks 
# 		AllowOverride None 
# 		Require all granted 
# </Directory> 

Then do this at remote

$ sudo service apache2 restart

Go to your IP/domain : http://example.com to check if it works. (Don't forget to open 80 port in your security group if you are using AWS)

Create Remote Superuser

$ ./deploy createsuperuser

Contributors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages