--- tags: Bigbluebutton, proxy title: BBB Proxy Deployment --- ## BBB Proxy Deployment This document shows different steps to deploy the big blue button proxy server ## Requirements - Ubuntu 16.04 64-bit OS - A domain name with a wildcard subdomain ## Install dependencies ### Ruby The first step is to install some dependencies for Ruby and Rails. To make sure we have everything necessary for Webpacker support in Rails, we're first going to start by adding the Node.js and Yarn repositories to our system before installing them. ```bash sudo apt install curl curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update sudo apt-get install -y git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev nodejs yarn ``` Installing with rbenv is a simple two step process. First you install `rbenv`, and then `ruby-build`: ```bash cd sudo git clone https://github.com/rbenv/rbenv.git /opt/.rbenv echo 'export PATH="/opt/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL sudo git clone https://github.com/rbenv/ruby-build.git /opt/.rbenv/plugins/ruby-build echo 'export PATH="/opt/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL rbenv install 2.7.1 rbenv global 2.7.1 ruby -v ``` The last step for ruby is to install Bundler ```bash gem install bundler rbenv rehash ``` ### Nginx ```bash sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7 sudo apt-get install -y apt-transport-https ca-certificates ``` ### Passenger ```bash # Add Passenger APT repository sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list' sudo apt-get update # Install Passenger & Nginx sudo apt-get install -y nginx-extras passenger ``` Next, we need to update the Nginx configuration to point Passenger to the version of Ruby that we're using. You'll want to open up `/etc/nginx/nginx.conf` in your favorite editor. I like to use `nano`, so I'd run this command: ```bash sudo nano /etc/nginx/nginx.conf # You could also use vim if you don't like nano # sudo vim /etc/nginx/nginx.conf ``` Find the following lines, and uncomment them: ```bash= ## # Phusion Passenger ## # Uncomment it if you installed ruby-passenger or ruby-passenger-enterprise ## include /etc/nginx/passenger.conf; ``` Save and close nginx.conf. Then open `/etc/nginx/passenger.conf` in your editor to modify the ruby line: ```bash sudo nano /etc/nginx/passenger.conf ``` And change the passenger_ruby line to point to your ruby executable: ```bash= passenger_ruby /home/deploy/.rbenv/shims/ruby; ``` > replace `/home/deploy` with the path to your home directory The passenger_ruby is the important line here. Make sure you only set this once and use the line from the example that pertains to the version of Ruby you installed. Once you've changed passenger_ruby to use the right version Ruby, you can run the following command to restart Nginx with the new Passenger configuration. ```bash sudo service nginx restart ``` ### Database Setup Setting up your production database is pretty easy. Make sure to keep in mind that you should use a different password for your production databases. #### Installing PostgreSQL Postgres 9.3 is available in the Ubuntu repositories and we can install it like so: ```bash sudo apt-get install postgresql postgresql-contrib libpq-dev ``` Next we need to setup our postgres user (also named "deploy" but different from our linux user named "deploy") and database: ```bash sudo su - postgres createuser --pwprompt deploy createdb -O deploy bbb_proxy_production # change "bbb_proxy" to your app's name which we'll also use later on exit ``` The password you type in here will be the one to put in your `bbb_proxy/config/application.yml` later when you deploy your app for the first time. ## Install the application ### Clone the project Go to the home directory to clone it from there ```bash cd /opt ``` Next, clone the project inside the home directory ```bash git clone https://bitbucket.org/tm_ghenzinger/bbb-tm-proxy.git ``` Next, adjust the folder permission ```bash sudo chown -R "$USER":www-data bbb-tm-proxy sudo chmod -R 0755 bbb-tm-proxy ``` Next, navigate inside the project ```bash cd bbb-tm-proxy ``` ### Install the project's dependencies ```bash bundler install ``` ### Compile assets ```bash bundle exec rake assets:precompile ``` ### Setup environment variables Setting up the environment varibles inside the `application.yml` file ```bash nano config/application.yml ``` Add the environment details ```yaml= SECRET_KEY_BASE: "1234567890" RDS_DB_NAME: "bbb_proxy_production" RDS_USERNAME: "deploy" RDS_PASSWORD: "--user_secret--" RDS_PORT: "5432" ADMIN_USER_EMAIL: "email@example.com" ADMIN_USER_PASSWORD: "sercret_password" ``` Note: replace `--user_secret__` with the password of your postgres user. Feel free to change the above environment variables to reflect the ones available in your machine Replace them with the `email@example.com` and `sercret_password` with the **Admin** user credentials ### Migrate database ```bash rake db:migrate RAILS_ENV=production ``` ### Seed database Create the admin user ```bash rake db:seed RAILS_ENV=production ``` ## Adding The Nginx Host In order to get Nginx to respond with the Rails app, we need to modify it's sites-enabled. Open up `/etc/nginx/sites-enabled/default` in your text editor and we will replace the file's contents with the following: ```bash= server { listen 80; listen [::]:80 ipv6only=on; server_name _; passenger_enabled on; rails_env production; root /opt/bbb-tm-proxy/public; # redirect server error pages to the static page /50x.html error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } ``` This is our Nginx configuration for a server listening on port 80. You need to change the `server_name` values to match the domain you want to use and in `root` replace `/opt/bbb-tm-proxy` with a path to the project **Restart nginx** ```bash sudo service nginx restart ```