原文见:简明配置指南. 作者:edustack开源教育信息化社区

一、edX默认用户名/密码

Staff staff@example.com:edx
Honor honor@example.com:edx
verified verified@example.com:edx
audit audit@example.com:edx

二、配置LMS/Studio SMTP

涉及文件:

/edx/app/edxapp/lms.env.json  #|文件里包含一些功能开关
/edx/app/edxapp/cms.env.json  #|
/edx/app/edxapp/lms.auth.json #|auth 文件包含一些密码 权限相关
/edx/app/edxapp/cms.auth.json #|

修改 lms.env.json文件:

cd /edx/app/edxapp
sudo vi lms.env.json

修改以下对应值:

“DEFAULT_FROM_EMAIL”: “your email”, #设置成你的smtp邮箱
“EMAIL_BACKEND”: “django.core.mail.backends.smtp.EmailBackend”,
“EMAIL_HOST”: “smtp.qq.com”, #内容修改成你的smtp主机,比如你的邮箱设置的QQ邮箱则是smtp.qq.com
“EMAIL_PORT”: 25, #端口一般是25,QQ企业邮箱是465
“EMAIL_USE_TLS”: false,
“LMS_BASE”: “example.com”, #你的平台域名,可填ip
“PREVIEW_LMS_BASE”: “example.com”,
“CMS_BASE”: “studio.example.com”,
“PLATFORM_NAME”: “OPENEDX”, #内容修改成你的edX平台名字
“SITE_NAME”: “localhost”, #域名或ip,激活邮箱时调用

修改 cms.env.json文件:

cd /edx/app/edxapp
sudo vi cms.env.json

修改以下对应值:

“BULK_EMAIL_DEFAULT_FROM_EMAIL”: “your email”, #设置成你的smtp邮箱
“DEFAULT_FROM_EMAIL”: “your email”, #设置成你的smtp邮箱
“EMAIL_BACKEND”: “django.core.mail.backends.smtp.EmailBackend”,
“EMAIL_HOST”: “smtp.qq.com”, #内容修改成你的smtp主机,比如QQ邮箱则是smtp.qq.com
“EMAIL_PORT”: 25, #一般是25,腾讯企业邮箱貌似465
“EMAIL_USE_TLS”: false,
“LMS_BASE”: “example.com”, #你的平台域名,可填ip
“PREVIEW_LMS_BASE”: “example.com”,
“CMS_BASE”: “studio.example.com”,
“SITE_NAME”: “localhost”, #域名或ip,激活邮箱时调用

修改 lms.auth.json文件:

sudo vi lms.auth.json

 

“EMAIL_HOST_PASSWORD”: “password”, #smtp邮箱密码
“EMAIL_HOST_USER”: “email”, #邮箱

修改 cms.auth.json文件:

sudo vi cms.auth.json
“EMAIL_HOST_PASSWORD”: “password”, #smtp邮箱密码
“EMAIL_HOST_USER”: “email”, #邮箱

重启edxapp生效:

exit
sudo /edx/bin/supervisorctl restart edxapp:

三、使用自定义主题:

1.切换至 edxapp 账户,并加载对应环境变量

sudo -u edxapp bash
source /edx/app/edxapp/edxapp_env
cd /edx/app/edxapp/

2.克隆主题至 /edx/app/edxapp/themes:

cd /edx/app/edxapp/themes
git clone https://github.com/eduStack/eduStack-theme.git

3.修改 lms.env.json文件:

“USE_CUSTOM_THEME”: true
“THEME_NAME”: “eduStack-theme”,

4.编译静态文件:

sudo -H -u edxapp bash
source /edx/app/edxapp/edxapp_env
cd /edx/app/edxapp/edx-platform
paver update_assets lms –settings aws

5.重启 edxapp生效:

exit
sudo /edx/bin/supervisorctl restart edxapp:

四、修改证书下载地址:

1.切换至 certs 账户

sudo -u certs bash
cd /edx/app/certs

2.修改 env.json

“CERT_DOWNLOAD_URL”: “http://www.example.net:18090”,
“CERT_URL”: “http://www.example.net:18090”,
“CERT_VERIFY_URL”: “http://www.example.net:18090”,

 注:不要轻易更换端口。如若更换请记得更换 nginx 配置

3.重启certs生效

sudo /edx/bin/supervisorctl restart certs

五、一些管理命令

1.列出所有manage.py命令参数:

sudo -u www-data /edx/app/edxapp/venvs/edxapp/bin/python
/edx/app/edxapp/edx-platform/manage.py lms –settings aws helpn

2.重启edxapp

sudo /edx/bin/supervisorctl restart edxapp:

3.查看服务器状态:

sudo /edx/bin/supervisorctl status

4.创建一个名为”user”超级管理员(django-admin):

sudo -u www-data /edx/bin/python.edxapp ./manage.py lms –settings aws create_user -s -p edx -e user@example.com
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms –settings aws changepassword user
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms –settings aws shell
from django.contrib.auth.models import User
me = User.objects.get(username=”user”)
me.is_superuser = True
me.is_staff = True
me.save()

5.以dubug模式启动lms:

cd /edx/app/edxapp/edx-platform
sudo -u www-data /edx/bin/python.edxapp ./manage.py lms runserver 8000 –settings aws

注:ip:8000可访问

6.重建数据库表结构:

sudo su edxapp -s /bin/bash
cd ~
source edxapp_env
python /edx/app/edxapp/edx-platform/manage.py lms/cms syncdb –migrate –settings=aws

 注:(lms/cms二选一)

7.编译lms静态文件:

sudo -H -u edxapp bash
source /edx/app/edxapp/edxapp_env
cd /edx/app/edxapp/edx-platform
paver update_assets lms –settings aws

 注:编译cms只要将lms改成cms既可。

8.课程管理:

a.从github导入一门课程(以/edx-demo为例)

cd /var/tmp
git clone https://github.com/edx/edx-demo-course.git
cd /edx/app/edxapp/edx-platform
sudo -u www-data /edx/bin/python.edxapp ./manage.py cms  –settings=aws import /edx/var/edxapp/data /var/tmp/edx-demo-course

b.删除一门课程:

sudo -u www-data /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py cms –settings aws delete_course 组织名/课程代码/课程学期 commit

例如:

sudo -u www-data /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py cms –settings aws delete_course bistu/M110/2014_T1 commit

c.如果删除失败可从数据库删除:

mongo
use edxapp
db.modulestore.find( { “_id.category” : “course” }, {‘name’:’1′} )

例:删除课程代码为999的课程

db.modulestore.remove({‘_id.course’: ‘999’})

d.从github导入课程:

cd /var/tmp
git clone https://github.com/edx/edx-demo-course.git
cd /edx/app/edxapp/edx-platform
sudo -u www-data /edx/bin/python.edxapp /edx/app/edxapp/edx-platform/manage.py cms –settings=aws import /edx/var/edxapp/data /var/tmp/edx-demo-course

e.删除一个邮箱为”user@example.com”的账户

sudo -u www-data /edx/bin/python.edxapp ./manage.py lms –settings aws shell
from django.contrib.auth.models import User
u=User.objects.get(email=”user@example.com”); [obj.delete()     for obj in u.preferences.all()];
u.delete()

或者

sudo su edxapp -s /bin/bash
cd ~
source edxapp_env
from django.contrib.auth.models import User
u=User.objects.get(email=”user@example.com”); [obj.delete() for obj in u.preferences.all()];
u.delete()

9.修改edx相关参数配置:

edx文件目录: /edx/

edx django管理地址:example.com/admin/ 和 studio.example.com/admin/

10.版本升级:

sudo /edx/bin/update 模块名 版本分支名

例如:

sudo /edx/bin/update edx-platform master

10.数据库初始化、迁移更新:

sudo -u www-data /edx/app/edxapp/venvs/edxapp/bin/python /edx/app/edxapp/edx-platform/manage.py lms syncdb –migrate –settings aws

11.查看服务运行状态:

sudo /edx/bin/supervisorctl -c /edx/etc/supervisord.conf status

12.重启服务:

LMS/CMS –

sudo /edx/bin/supervisorctl -c /edx/etc/supervisord.conf restart edxapp:

Workers –

sudo /edx/bin/supervisorctl -c /edx/etc/supervisord.conf restart edxapp_worker:

13.手动编译assets

sudo -u edxapp bash
source /edx/app/edxapp/edxapp_env
cd /edx/app/edxapp/edx-platform
paver update_assets cms –settings=aws
paver update_assets lms –settings=aws

14.简单查错

如果连不上edx lms/cms,检查nginx状态:

sudo service nginx status
sudo service nginx start

NGINX 日志文件在 /edx/var/log/nginx

NGINX 配置文件在 /edx/app/nginx/sites-enabled

15.检查lms/cms是否运行:

sudo /edx/bin/supervisorctl -c /edx/etc/supervisord.conf status edxapp:

如果仍然无法解决,尝试:

sudo service nginx stop
sudo service supervisor stop
sudo service supervisor.devpi stop
sudo pkill -u www-data
sudo service nginx start
sudo service supervisor start
sudo service supervisor.devpi start

16.查看日志显示:

sudo tail -f /edx/var/log/{lms,cms,nginx}/*log