How to install E-Commerce module in Bitnami' Open edX distribution

Important note: Bitnami distribution of Open edX is designed for testing and demonstration purposes so the e-commerce module integration is for experiment only. Please use this installation guide as your own risk.

Bitnami' Open edX distribution only includes several core services such as LMS, Studio, XQueue, Forum as well as supporting services like MySQL, MongoDB, Memcached, Apache or Elasticsearch (more details here). Additionally, Bitnami' application structure for Open edX is different than the official stack supported by the Open edX community. So, because of those reasons, in order to integrate the e-commerce module in your running instance, currently, there is no way other than doing it manually.

I have had a chance to deploy successfully the e-commerce into a test Open edX instance for a customer. Below is how I did it. You can use it as a reference and leave me a comment if you find any errors or want to add something.

1. Directory structure:

Assuming you have installed Bitnami' Open edX version fiscus.3-2 at /opt/edx-ficus.3-2/, you should create and organize the needed directories as follows:

  • Main folder of the e-commerce module: /opt/edx-ficus.3-2/apps/ecommerce/
  • Source code: /opt/edx-ficus.3-2/apps/ecommerce/ecommerce/
  • Configuration (put all the configuration files of e-commerce here): /opt/edx-ficus.3-2/apps/ecommerce/conf/
  • Python virtual environment: /opt/edx-ficus.3-2/apps/ecommerce/venvs/
  • Node environment (nodejs environment): /opt/edx-ficus.3-2/apps/ecommerce/nodeenvs/
  • Logs: /opt/edx-ficus.3-2/apps/ecommerce/var/logs/
  • Static files: /opt/edx-ficus.3-2/apps/ecommerce/var/staticfiles/

2. Create the user and group for e-commerce:

$ sudo useradd -s /bin/bash -d /opt/edx-ficus.3-2/apps/ecommerce/ -m ecommerce
$ sudo echo "ecommerce ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/ecommerce
$ sudo su - ecommerce
$ sudo chown -R ecommerce:ecommerce /opt/edx-ficus.3-2/apps/ecommerce/ 

3. Clone the e-commerce source code:

$ cd /opt/edx-ficus.3-2/apps/ecommerce/
$ git clone https://github.com/edx/ecommerce.git -b open-release/ginkgo.master

4. Create a virtualenv environment for e-commerce:

$ virtualenv /opt/edx-ficus.3-2/apps/ecommerce/venvs/ecommerce

5. Create a MySQL database for e-commerce:

$ sudo mysql -u root -p

> create database ecommerce;
> grant all privileges on ecommerce.* to ecommerce@localhost identified by 'password';
> flush privileges;
> exit

6. Install e-commerce requirements and Gunicorn

$ cd /opt/edx-ficus.3-2/apps/ecommerce/ecommerce
$ source /opt/edx-ficus.3-2/apps/ecommerce/venvs/ecommerce/bin/activate
$ make requirements

Even though e-commerce itself does not require Gunicorn and Bitnami stack uses Apache and mode WSGI, I found it's much easier to go with Gunicorn and Nginx:

(while you are still sourced in the ecommerce venv)
$ pip install gunicorn

7. Migrate the database:

$ cd /opt/edx-ficus.3-2/apps/ecommerce/ecommerce
$ make migrate

8. Copy all the configuration files I prepared to /opt/edx-ficus.3-2/apps/ecommerce/conf/

$ cd /opt/edx-ficus.3.2/apps/ecommerce/
$ git clone https://github.com/dangtrinhnt/bitnami-edx-ecommerce conf

Note: update your prior information in those configuration files. All of these files are based on the official deployment templates of Open edX.

9. Install Supervisord (to daemonize the Gunicorn process) and config:

- Install and include the supervisor config file for e-commerce
$ sudo apt install supervisor
$ sudo nano /etc/supervisor/supervisord.conf

...
[include]
files = /etc/supervisor/conf.d/*.conf /opt/edx-ficus.3-2/apps/ecommerce/conf/ecommerce_supervisor.conf

- Restart supervisord
$ sudo systemctl restart supervisor

10. Install Nginx (the reverse proxy for the Gunicorn process,) and config:

- Install and symlink the nginx config file from the configuration folder mentioned above
$ sudo apt install nginx
$ sudo ln -s /opt/edx-ficus.3-2/apps/ecommerce/conf/ecommerce_nginx /etc/nginx/sites-enabled/ecommerce

- Check Nginx configuration:
$ sudo nginx -t

- Remove the default Nginx configuration to prevent conflicts with Apache process running on port 80/443.

$ sudo rm /etc/nginx/sites-enabled/default

- Restart Nginx
$ sudo systemctl restart nginx

Notes: nginx will serve at port 18130 while Gunicorn runs at port 8130.

Now you have a running e-commerce application for your Bitnami' Open edX instance. Next thing you need to do is configure e-commerce to make it work with your edx-platform as discribes in this documentation.


Check out my Open edX services at https://www.edlab.xyz/ !!!



Comments