Skip to content

Instantly share code, notes, and snippets.

@icarrr

icarrr/README.md

Last active Mar 23, 2021
Embed
What would you like to do?

Open edX

Install Open edX Using Method Native Installation

Add some variables to your server

echo "export LC_ALL='en_US.UTF-8'" >> ~/.bashrc
echo "export LANG='en_US.UTF-8'" >> ~/.bashrc
echo "export LANGUAGE='en_US.UTF-8'" >> ~/.bashrc
echo "export OPENEDX_RELEASE='the-tag/you-want-to-install'" >> ~/.bashrc

Reload bash

source ~/.bashrc

Create a new file with the name config.yml in the desired directory and add the following script that contains LMS and open the edX Studio address. The following is an example file, please change according to the desired address:

EDXAPP_LMS_BASE: "online.myeducation.org"
EDXAPP_CMS_BASE: "studio.online.myeducation.org"

Install Open edX

wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/ansible-bootstrap.sh -O - | sudo bash
wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/generate-passwords.sh -O - | bash
wget https://raw.githubusercontent.com/edx/configuration/$OPENEDX_RELEASE/util/install/native.sh -O - | bash

References

https://sibunglon.com/2019/07/13/install-open-edx-using-method-native-installation-ubuntu-16.04/

#!/bin/bash
if [[ `lsb_release -rs` != "16.04" ]]; then
echo "This script is only known to work on Ubuntu 16.04, exiting..."
exit
fi
# Config.yml is required, must define LMS and CMS names, and the names
# must not infringe trademarks.
if [[ ! -f config.yml ]]; then
echo 'You must create a config.yml file specifying the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq EDXAPP_LMS_BASE config.yml
GREP_LMS=$?
grep -Fq EDXAPP_CMS_BASE config.yml
GREP_CMS=$?
if [[ $GREP_LMS == 1 ]] || [[ $GREP_CMS == 1 ]]; then
echo 'Your config.yml file must specify the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq edx. config.yml
GREP_BAD_DOMAIN=$?
if [[ $GREP_BAD_DOMAIN == 0 ]]; then
echo '*** NOTE: Open edX and edX are registered trademarks.'
echo 'You may not use "openedx." or "edx." as subdomains when naming your site.'
echo 'For more details, see the edX Trademark Policy: https://edx.org/trademarks'
echo ''
echo 'Here are some examples of unacceptable domain names:'
echo ' openedx.yourdomain.org'
echo ' edx.yourdomain.org'
echo ' openedxyourdomain.org'
echo ' yourdomain-edx.com'
echo ''
echo 'Please choose different domain names.'
exit
fi
echo "Installing release '$OPENEDX_RELEASE'"
##
## Set ppa repository source for gcc/g++ 4.8 in order to install insights properly
##
sudo apt-get install -y python-software-properties
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
##
## Update and Upgrade apt packages
##
sudo apt-get update -y
sudo apt-get upgrade -y
##
## Install system pre-requisites
##
sudo apt-get install -y build-essential software-properties-common curl git-core libxml2-dev libxslt1-dev python-pip libmysqlclient-dev python-apt python-dev libxmlsec1-dev libfreetype6-dev swig gcc g++
sudo pip install --upgrade pip==9.0.3
sudo pip install --upgrade setuptools==39.0.1
sudo -H pip install --upgrade virtualenv==15.2.0
##
## Overridable version variables in the playbooks. Each can be overridden
## individually, or with $OPENEDX_RELEASE.
##
VERSION_VARS=(
edx_platform_version
certs_version
forum_version
XQUEUE_VERSION
configuration_version
demo_version
NOTIFIER_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
##
## Clone the configuration repository and run Ansible
##
cd /var/tmp
git clone https://github.com/edx/configuration
cd configuration
git checkout $CONFIGURATION_VERSION
git pull
##
## Install the ansible requirements
##
cd /var/tmp/configuration
sudo -H pip install -r requirements.txt
##
## Update script openedx_native
##
sudo bash -c "cat << 'EOF' > /var/tmp/configuration/playbooks/openedx_native.yml
---
# Open edX Native installation for single server community installs.
- name: Bootstrap instance(s)
hosts: all
gather_facts: no
become: True
roles:
- python
- name: Configure instance(s)
hosts: all
become: True
gather_facts: True
vars:
migrate_db: 'yes'
EDXAPP_PREVIEW_LMS_BASE: '{{ EDXAPP_LMS_BASE }}'
EDXAPP_LOGIN_REDIRECT_WHITELIST: [
'{{ EDXAPP_CMS_BASE }}',
'account.{{ EDXAPP_LMS_BASE }}',
'gradebook.{{ EDXAPP_LMS_BASE }}',
'profile.{{ EDXAPP_LMS_BASE }}'
]
EDXAPP_LMS_BASE_SCHEME: http
COMMON_LMS_BASE_URL: '{{ EDXAPP_LMS_BASE_SCHEME }}://{{ EDXAPP_LMS_BASE }}'
EDXAPP_LMS_NGINX_PORT: '80'
EDX_PLATFORM_VERSION: 'master'
# Set to false if deployed behind another proxy/load balancer.
NGINX_SET_X_FORWARDED_HEADERS: True
DISCOVERY_URL_ROOT: 'http://localhost:{{ DISCOVERY_NGINX_PORT }}'
AWS_GATHER_FACTS: false
COMMON_ENABLE_AWS_ROLE: false
ecommerce_create_demo_data: true
credentials_create_demo_data: true
CONFIGURE_JWTS: true
SANDBOX_ENABLE_BLOCKSTORE: false
SANDBOX_ENABLE_DISCOVERY: true
SANDBOX_ENABLE_ECOMMERCE: true
SANDBOX_ENABLE_ANALYTICS_API: true
SANDBOX_ENABLE_INSIGHTS: true
SANDBOX_ENABLE_RABBITMQ: true
SANDBOX_ENABLE_NOTES: false
DEMO_ROLE_ENABLED: true
ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING: false
EDXAPP_ENABLE_MEMCACHE: true
EDXAPP_ENABLE_ELASTIC_SEARCH: true
roles:
- role: mongo_3_2
EOF"
##
## Run the openedx_native.yml playbook in the configuration/playbooks directory
##
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@"
#!/bin/bash
next_task=$1
if [[ ! $next_task ]]; then
echo "You must define next_task"
exit
fi
if [[ ! $OPENEDX_RELEASE ]]; then
echo "You must define OPENEDX_RELEASE"
exit
fi
VERSION_VARS=(
edx_platform_version
certs_version
forum_version
XQUEUE_VERSION
configuration_version
demo_version
NOTIFIER_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@" --start-at-task="$next_task"
#!/bin/bash
if [[ ! $OPENEDX_RELEASE ]]; then
echo "You must define OPENEDX_RELEASE"
exit
fi
if [[ `lsb_release -rs` != "20.04" ]]; then
echo "This script is only known to work on Ubuntu 20.04, exiting..."
exit
fi
# Config.yml is required, must define LMS and CMS names, and the names
# must not infringe trademarks.
if [[ ! -f config.yml ]]; then
echo 'You must create a config.yml file specifying the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq EDXAPP_LMS_BASE config.yml
GREP_LMS=$?
grep -Fq EDXAPP_CMS_BASE config.yml
GREP_CMS=$?
if [[ $GREP_LMS == 1 ]] || [[ $GREP_CMS == 1 ]]; then
echo 'Your config.yml file must specify the hostnames (and if'
echo 'needed, ports) of your LMS and Studio hosts.'
echo 'For example:'
echo ' EDXAPP_LMS_BASE: "11.22.33.44"'
echo ' EDXAPP_CMS_BASE: "11.22.33.44:18010"'
exit
fi
grep -Fq edx. config.yml
GREP_BAD_DOMAIN=$?
if [[ $GREP_BAD_DOMAIN == 0 ]]; then
echo '*** NOTE: Open edX and edX are registered trademarks.'
echo 'You may not use "openedx." or "edx." as subdomains when naming your site.'
echo 'For more details, see the edX Trademark Policy: https://edx.org/trademarks'
echo ''
echo 'Here are some examples of unacceptable domain names:'
echo ' openedx.yourdomain.org'
echo ' edx.yourdomain.org'
echo ' openedxyourdomain.org'
echo ' yourdomain-edx.com'
echo ''
echo 'Please choose different domain names.'
exit
fi
echo "Installing release '$OPENEDX_RELEASE'"
##
## Set ppa repository source for gcc/g++ 4.8 in order to install insights properly
##
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
##
## Update and Upgrade apt packages
##
sudo apt-get update -y
sudo apt-get upgrade -y
##
## Install system pre-requisites
##
sudo apt-get install -y build-essential software-properties-common curl git-core libxml2-dev libxslt1-dev python3-pip libmysqlclient-dev python3-apt python3-dev libxmlsec1-dev libfreetype6-dev swig gcc g++
# ansible-bootstrap installs yaml that pip 19 can't uninstall.
sudo apt-get remove -y python-yaml
sudo pip install --upgrade pip==20.0.2
sudo pip install --upgrade setuptools==44.1.0
sudo -H pip install --upgrade virtualenv==16.7.10
##
## Overridable version variables in the playbooks. Each can be overridden
## individually, or with $OPENEDX_RELEASE.
##
VERSION_VARS=(
EDX_PLATFORM_VERSION
CERTS_VERSION
FORUM_VERSION
XQUEUE_VERSION
CONFIGURATION_VERSION
DEMO_VERSION
INSIGHTS_VERSION
ANALYTICS_API_VERSION
ECOMMERCE_VERSION
ECOMMERCE_WORKER_VERSION
DISCOVERY_VERSION
THEMES_VERSION
ACCOUNT_MFE_VERSION
GRADEBOOK_MFE_VERSION
PROFILE_MFE_VERSION
)
for var in ${VERSION_VARS[@]}; do
# Each variable can be overridden by a similarly-named environment variable,
# or OPENEDX_RELEASE, if provided.
ENV_VAR=$(echo $var | tr '[:lower:]' '[:upper:]')
eval override=\${$ENV_VAR-\$OPENEDX_RELEASE}
if [ -n "$override" ]; then
EXTRA_VARS="-e $var=$override $EXTRA_VARS"
fi
done
# my-passwords.yml is the file made by generate-passwords.sh.
if [[ -f my-passwords.yml ]]; then
EXTRA_VARS="-e@$(pwd)/my-passwords.yml $EXTRA_VARS"
fi
EXTRA_VARS="-e@$(pwd)/config.yml $EXTRA_VARS"
CONFIGURATION_VERSION=${CONFIGURATION_VERSION-$OPENEDX_RELEASE}
##
## Clone the configuration repository and run Ansible
##
cd /var/tmp
git clone https://github.com/edx/configuration
cd configuration
git checkout $CONFIGURATION_VERSION
git pull
##
## Install the ansible requirements
##
cd /var/tmp/configuration
sudo -H pip3 install -r requirements.txt
##
## Update script openedx_native
##
sudo bash -c "cat << 'EOF' > /var/tmp/configuration/playbooks/openedx_native.yml
---
# Open edX Native installation for single server community installs.
- name: Configure instance(s)
hosts: all
become: True
gather_facts: True
vars:
migrate_db: 'yes'
EDXAPP_PREVIEW_LMS_BASE: 'preview.{{ EDXAPP_LMS_BASE }}'
EDXAPP_LOGIN_REDIRECT_WHITELIST: [
'{{ EDXAPP_CMS_BASE }}',
]
EDXAPP_ENABLE_CORS_HEADERS: true
EDXAPP_ENABLE_CROSS_DOMAIN_CSRF_COOKIE: true
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_DOMAIN: '{{ EDXAPP_LMS_BASE }}'
EDXAPP_CROSS_DOMAIN_CSRF_COOKIE_NAME: 'native-csrf-cookie'
EDXAPP_LMS_BASE_SCHEME: http
COMMON_LMS_BASE_URL: '{{ EDXAPP_LMS_BASE_SCHEME }}://{{ EDXAPP_LMS_BASE }}'
EDXAPP_LMS_NGINX_PORT: '80'
EDX_PLATFORM_VERSION: 'master'
# Set to false if deployed behind another proxy/load balancer.
NGINX_SET_X_FORWARDED_HEADERS: True
DISCOVERY_URL_ROOT: 'http://localhost:{{ DISCOVERY_NGINX_PORT }}'
AWS_GATHER_FACTS: false
COMMON_ENABLE_AWS_ROLE: false
ecommerce_create_demo_data: true
credentials_create_demo_data: true
CONFIGURE_JWTS: true
SANDBOX_ENABLE_BLOCKSTORE: false
SANDBOX_ENABLE_DISCOVERY: true
SANDBOX_ENABLE_ECOMMERCE: true
SANDBOX_ENABLE_ANALYTICS_API: true
SANDBOX_ENABLE_INSIGHTS: true
SANDBOX_ENABLE_REDIS: true
SANDBOX_ENABLE_NOTES: false
DEMO_ROLE_ENABLED: true
ECOMMERCE_ENABLE_COMPREHENSIVE_THEMING: false
EDXAPP_ENABLE_MEMCACHE: true
EDXAPP_ENABLE_ELASTIC_SEARCH: true
roles:
- role: mongo_3_2
- role: mysql
EOF"
##
## Run the openedx_native.yml playbook in the configuration/playbooks directory
##
cd /var/tmp/configuration/playbooks && sudo -E ansible-playbook -c local ./openedx_native.yml -i "localhost," $EXTRA_VARS "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment