README.md 6.57 KB
Newer Older
David Baumgold committed
1
This is edX, a platform for online course delivery. The project is primarily
2
written in [Python](http://python.org/), using the
3
[Django](https://www.djangoproject.com/) framework. We also use some
4 5 6 7 8 9 10
[Ruby](http://www.ruby-lang.org/) and some [NodeJS](http://nodejs.org/).

Installation
============
The installation process is a bit messy at the moment. Here's a high-level
overview of what you should do to get started.

11 12 13
**TLDR:** There is a `scripts/create-dev-env.sh` script, `scripts/create_mac_dev_env.sh` 
for mac computer, that will attempt to set all of this up for you. 
If you're in a hurry, run that script. Otherwise, I suggest
14 15 16 17 18
that you understand what the script is doing, and why, by reading this document.

Directory Hierarchy
-------------------
This code assumes that it is checked out in a directory that has three sibling
19
directories: `data` (used for XML course data), `db` (used to hold a
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
[sqlite](https://sqlite.org/) database), and `log` (used to hold logs). If you
clone the repository into a directory called `edx` inside of a directory
called `dev`, here's an example of how the directory hierarchy should look:

    * dev
     \
      * data
      * db
      * log
      * edx
       \
        README.md

Language Runtimes
-----------------
You'll need to be sure that you have Python 2.7, Ruby 1.9.3, and NodeJS
(latest stable) installed on your system. Some of these you can install
using your system's package manager: [homebrew](http://mxcl.github.io/homebrew/)
for Mac, [apt](http://wiki.debian.org/Apt) for Debian-based systems
(including Ubuntu), [rpm](http://www.rpm.org/) or [yum](http://yum.baseurl.org/)
for Red Hat based systems (including CentOS).

If your system's package manager gives you the wrong version of a language
runtime, then you'll need to use a versioning tool to install the correct version.
Usually, you'll need to do this for Ruby: you can use
[`rbenv`](https://github.com/sstephenson/rbenv) or [`rvm`](https://rvm.io/), but
typically `rbenv` is simpler. For Python, you can use
[`pythonz`](http://saghul.github.io/pythonz/),
and for Node, you can use [`nvm`](https://github.com/creationix/nvm).

Virtual Environments
--------------------
Often, different projects will have conflicting dependencies: for example, two
projects depending on two different, incompatible versions of a library. Clearly,
you can't have both versions installed and used on your machine simultaneously.
Virtual environments were created to solve this problem: by installing libraries
into an isolated environment, only projects that live inside the environment
57
will be able to see and use those libraries. Got incompatible dependencies? Use
58 59
different virtual environments, and your problem is solved.

60
Remember, each language has a different implementation. Python has
61
[`virtualenv`](http://www.virtualenv.org/), Ruby has
62
[`bundler`](http://gembundler.com/), and Node's virtual environment support
David Baumgold committed
63
is built into [`npm`](https://npmjs.org/), its library management tool.
64 65 66 67
For each language, decide if you want to use a virtual environment, or if you
want to install all the language dependencies globally (and risk conflicts).
I suggest you start with installing things globally until and unless things
break; you can always switch over to a virtual environment later on.
68 69 70 71 72 73 74 75 76 77 78 79 80

Language Packages
-----------------
The Python libraries we use are listed in `requirements.txt`. The Ruby libraries
we use are listed in `Gemfile`. The Node libraries we use are listed in
`packages.json`. Python has a library installer called
[`pip`](http://www.pip-installer.org/), Ruby has a library installer called
[`gem`](https://rubygems.org/) (or `bundle` if you're using a virtual
environment), and Node has a library installer called
[`npm`](https://npmjs.org/).
Once you've got your languages and virtual environments set up, install
the libraries like so:

81 82
    $ pip install -r requirements/edx/base.txt
    $ pip install -r requirements/edx/post.txt
83 84 85
    $ bundle install
    $ npm install

Calen Pennington committed
86 87 88 89 90
You can also use [`rake`](http://rake.rubyforge.org/) to get all of the prerequisites (or to update)
them if they've changed

    $ rake install_prereqs

91 92 93 94 95 96 97 98 99 100 101 102
Other Dependencies
------------------
You'll also need to install [MongoDB](http://www.mongodb.org/), since our
application uses it in addition to sqlite. You can install it through your
system package manager, and I suggest that you configure it to start
automatically when you boot up your system, so that you never have to worry
about it again. For Mac, use
[`launchd`](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/launchd.8.html)
(running `brew info mongodb` will give you some commands you can copy-paste.)
For Linux, you can use [`upstart`](http://upstart.ubuntu.com/), `chkconfig`,
or any other process management tool.

103 104 105 106 107 108
Configuring Your Project
------------------------
We use [`rake`](http://rake.rubyforge.org/) to execute common tasks in our
project. The `rake` tasks are defined in the `rakefile`, or you can run `rake -T`
to view a summary.

109 110 111
Before you run your project, you need to create a sqlite database, create
tables in that database, run database migrations, and populate templates for
CMS templates. Fortunately, `rake` will do all of this for you! Just run:
112 113 114

    $ rake django-admin[syncdb]
    $ rake django-admin[migrate]
115
    $ rake django-admin[update_templates]
116 117 118 119 120 121 122 123 124 125

If you are running these commands using the [`zsh`](http://www.zsh.org/) shell,
zsh will assume that you are doing
[shell globbing](https://en.wikipedia.org/wiki/Glob_(programming)), search for
a file in your directory named `django-adminsyncdb` or `django-adminmigrate`,
and fail. To fix this, just surround the argument with quotation marks, so that
you're running `rake "django-admin[syncdb]"`.

Run Your Project
----------------
126
edX has two components: Studio, the course authoring system; and the LMS
127
(learning management system) used by students. These two systems communicate
128 129 130
through the MongoDB database, which stores course information.

To run Studio, run:
131 132 133

    $ rake cms

134
To run the LMS, run:
135

136
    $ rake lms[cms.dev]
137

138 139 140 141
Studio runs on port 8001, while LMS runs on port 8000, so you can run both of
these commands simultaneously, using two different terminal windows. To view
Studio, visit `127.0.0.1:8001` in your web browser; to view the LMS, visit
`127.0.0.1:8000`.
142

143 144
There's also an older version of the LMS that saves its information in XML files
in the `data` directory, instead of in Mongo. To run this older version, run:
145

Calen Pennington committed
146
    $ rake lms
147 148 149 150 151 152 153 154

Further Documentation
=====================
Once you've got your project up and running, you can check out the `docs`
directory to see more documentation about how edX is structured.