README.md 12.4 KB
Newer Older
1 2 3
This is the main edX platform which consists of LMS and Studio.

See [code.edx.org](http://code.edx.org/) for other parts of the edX code base.
4

5 6 7
Installation - The first time
=============================

8 9
The following instructions will help you to download and setup a virtual machine
with a minimal amount of steps, using Vagrant. It is recommended for a first
10 11 12
installation, as it will save you from many of the common pitfalls of the
installation process.

13 14
1. Make sure you have plenty of available disk space, >5GB
2. Install Git: http://git-scm.com/downloads
Yarko Tymciurak committed
15 16 17
3. Install VirtualBox: https://www.virtualbox.org/wiki/Downloads
   See http://docs.vagrantup.com/v2/providers/index.html for a list of supported
   Providers.  You should use VirtualBox >= 4.2.12.
18
   (Windows: later/earlier VirtualBox versions than 4.2.12 have been reported to not work well with
Yarko Tymciurak committed
19
   Vagrant.  If this is still a problem, you can
20
   install 4.2.12 from http://download.virtualbox.org/virtualbox/4.2.12/).
21 22
4. Install Vagrant: http://www.vagrantup.com/ (Vagrant 1.2.2 or later)
5. Open a terminal
23
6. Download the project: `git clone https://github.com/edx/edx-platform.git`
24
7. Enter the project directory: `cd edx-platform/`
25
8. (Windows only) Run the commands to
26
   [deal with line endings and symlinks under Windows](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#dealing-with-line-endings-and-symlinks-under-windows)
Yarko Tymciurak committed
27
9. Create the development environment and start it: `vagrant up`
28

Yarko Tymciurak committed
29 30 31 32 33
The initial `vagrant up` will download a Linux image, then boot and ask for your
host machine's administrator password to setup file sharing between your computer and the VM.
Once file sharing is established, `edx-platform/scripts/create-dev-env.sh` will
install dependencies and configure the VM.
This will take a while; go grab a coffee.
34

Yarko Tymciurak committed
35
When complete, you should see a _"Success!"_ message.
36
If not, refer to the
Yarko Tymciurak committed
37
[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).
38

Yarko Tymciurak committed
39 40
Your development environment is initialized only on the first bring-up.
Subsequently `vagrant up` commands will boot your virtual machine normally.
41

Yarko Tymciurak committed
42 43
Note: by default, the VM will get the IP `192.168.20.40`.
You can change this in your `Vagrantfile` (the startup message will reflect your VM's actual IP).
44

45 46 47
Accessing the VM
----------------

48
Once the installation is finished, to log into the virtual machine:
49 50 51 52 53

```
$ vagrant ssh
```

Yarko Tymciurak committed
54 55 56 57
Note: This won't work from Windows. Instead, install PuTTY from
http://www.chiark.greenend.org.uk/%7Esgtatham/putty/download.html. Then
connect to 192.168.20.40, port 2222, using vagrant/vagrant as a user/password.

58 59 60 61

Using edX
---------

Yarko Tymciurak committed
62 63 64
When you login to your VM, you are in
`/opt/edx/edx-platform` by default, which is shared from your host workspace.
Your host computer contains the edx-project development code and repository.
65
Your VM runs edx-platform code mounted from your host, so
Yarko Tymciurak committed
66 67 68 69 70 71
you can develop by editing on your host.

After logging into your VM with `vagrant ssh`,
start the _Studio_ and
_Learning management system (LMS)_
servers (run these from `/opt/edx/edx-platform`):
72 73 74 75 76 77 78

Learning management system (LMS):

```
$ rake lms[cms.dev,0.0.0.0:8000]
```

Yarko Tymciurak committed
79
Studio (CMS):
80 81 82 83 84

```
$ rake cms[dev,0.0.0.0:8001]
```

Yarko Tymciurak committed
85
The servers will come up to these URLs:
86

Yarko Tymciurak committed
87 88
- LMS: http://192.168.20.40:8000/
- CMS: http://192.168.20.40:8001/
89

Yarko Tymciurak committed
90 91 92 93
Your VM's port 8000 is forwarded to host port 9000
so you can also access the LMS with [http://localhost:9000/]().
Similarly, VM port 8001 is forwarded to host port 9001.
These are set in your `Vagrantfile`.
94

Yarko Tymciurak committed
95 96 97
Note that when you register a new user through the web interface,
by default the activiation email will be appear on your VM's terminal.
Search for lines similar to:
98 99 100 101 102 103

```
Subject: Your account for edX Studio
From: registration@edx.org
```

Yarko Tymciurak committed
104
and find the activation URL.
105 106 107 108

See the [Frequently Asked Questions](https://github.com/edx/edx-platform/wiki/Frequently-Asked-Questions)
for more usage tips.

Yarko Tymciurak committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
Django admin & debug toolbar
-----------------------------

You can enable admin logins and the debug_toolbar by editing
`lms/envs/common.py`:

- enable ADMIN login page by setting:
  - ```
     'ENABLE_DJANGO_ADMIN_SITE': True
```


- enable debug toolbar by uncommenting:
  - ```
    # 'debug_toolbar.middleware.DebugToolbarMiddleware',
```

These are also defined in `lms/envs/dev.py`,
and usually active on localhost.

To get at your VM's 127.0.0.1, explicitly forward one of VM's available localhost ports to your computer.
Instead of `vagrant ssh`, login with:

```
$ ssh -L 6080:127.0.0.1:8080 vagrant@192.168.20.40
```

The password is _vagrant_.

From your VM, start the LMS as a localhost instance:

```
$ rake lms[cms.dev,127.0.0.1:8080]
```

You should see the debug toolbar now on [http:/localhost:6080/]().
You should now also see a login on [http://localhost:6080/admin/]()
You will need a privileged user for the admin login.
You can create a CMS/LMS super-user with:
```
149
$ ./manage.py lms createsuperuser
Yarko Tymciurak committed
150 151 152
```


153 154 155 156
Stopping & starting
-------------------


Yarko Tymciurak committed
157
To stop the VM (from your `edx-platform/` directory):
158 159 160 161 162 163 164 165 166 167
```
$ vagrant halt
```

To restart:

```
$ vagrant up
```

Yarko Tymciurak committed
168 169 170 171 172 173
To suspend and resume tasks in progress on your VM:
```
$ vagrant suspend
$ # and later...
$ vagrant resume
```
174

Yarko Tymciurak committed
175 176 177 178
Your development environment is normally created once, on first `vagrant up`.
You can continue to fetch changes in edx-platform
as you work with your VM.
To re-create your VM and create a fresh development environment:
179
```
Yarko Tymciurak committed
180 181
$ vagrant destroy
$ vagrant up  # will make a new VM
182 183
```

Yarko Tymciurak committed
184

185 186 187
Troubleshooting
---------------

188
If anything doesn't work as expected, see the
189
[troubleshooting section](https://github.com/edx/edx-platform/wiki/Simplified-install-with-vagrant#troubleshooting).
190 191 192 193 194 195

Installation - Advanced
=======================

Note: The following installation instructions are for advanced users & developers
who are familiar with setting up Python, Ruby & node.js virtual environments.
196
Even if you know what you are doing, edX has a large code base with multiple
197 198
dependencies, so you might still want to use the method described above the
first time, as Vagrant helps avoiding issues due to the different environments.
199

200 201 202 203
There is a `scripts/create-dev-env.sh` that will attempt to set up a development
environment.

If you want to better understand what the script is doing, keep reading.
204 205 206

Directory Hierarchy
-------------------
207

208
This code assumes that it is checked out in a directory that has three sibling
209
directories: `data` (used for XML course data), `db` (used to hold a
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
[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
247
will be able to see and use those libraries. Got incompatible dependencies? Use
248 249
different virtual environments, and your problem is solved.

250
Remember, each language has a different implementation. Python has
251
[`virtualenv`](http://www.virtualenv.org/), Ruby has
252
[`bundler`](http://gembundler.com/), and Node's virtual environment support
David Baumgold committed
253
is built into [`npm`](https://npmjs.org/), its library management tool.
254 255 256 257
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.
258 259 260 261 262 263 264 265 266 267 268 269 270

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:

271
    $ pip install -r requirements/edx/pre.txt
272 273
    $ pip install -r requirements/edx/base.txt
    $ pip install -r requirements/edx/post.txt
274 275 276
    $ bundle install
    $ npm install

Calen Pennington committed
277 278 279 280 281
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

282 283 284 285 286 287 288 289 290 291 292 293
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.

294 295
Configuring Your Project
------------------------
296
Before you run your project, you need to create a sqlite database, create
297 298
tables in that database, and run database migrations. Fortunately, `django`
will do all of this for you
299

300 301
    $ ./manage.py lms syncdb --migrate
    $ ./manage.py cms syncdb --migrate
302 303 304

Run Your Project
----------------
305
edX has two components: Studio, the course authoring system; and the LMS
306
(learning management system) used by students. These two systems communicate
307 308
through the MongoDB database, which stores course information.

309 310 311 312
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.

313
To run Studio, run:
314 315 316

    $ rake cms

317
To run the LMS, run:
318

319
    $ rake lms[cms.dev]
320

321 322 323 324
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`.
325

326 327
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:
328

Calen Pennington committed
329
    $ rake lms
330

331 332 333 334 335 336 337 338
License
-------

The code in this repository is licensed under version 3 of the AGPL unless
otherwise noted.

Please see ``LICENSE.txt`` for details.

339 340 341 342 343 344
Documentation
------------

High-level documentation of the code is located in the `doc` subdirectory. Start
with `overview.md` to get an introduction to the architecture of the system.

345 346 347 348 349 350 351 352 353
How to Contribute
-----------------

Contributions are very welcome. The easiest way is to fork this repo, and then
make a pull request from your fork. The first time you make a pull request, you
may be asked to sign a Contributor Agreement.

Reporting Security Issues
-------------------------
354

355
Please do not report security issues in public. Please email security@edx.org
356

357 358
Mailing List and IRC Channel
----------------------------
359

360 361
You can discuss this code on the [edx-code Google Group](https://groups.google.com/forum/#!forum/edx-code) or in the
`edx-code` IRC channel on Freenode.