LMS configure and install in ubuntu with Passenger Rails
1. Install Require Packages
1 2 3 4 5 |
sudo apt-get install mysql-server libmysqlclient-dev sudo apt-get remove apache2-mpm-prefork apache2-utils apache2.2-bin apache2.2-common apache2 libapache2-mod-php5 nginx sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libcurl4-openssl-dev alien libaio-dev libpcre3-dev g++ automake zlib1g-dev libtool tar bzip2 libcurl4-openssl-dev sudo apt-get install openjdk-6-jre nodejs sudo apt-get install libxslt-dev libxml2-dev libxmlsec1 libxmlsec1-dev libyaml-dev libxslt1-dev libncurses5-dev libffi-dev libxslt1-dev libgdbm-dev |
2. Install RVM System Wide
1 2 3 4 |
sudo -s curl -L https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | sudo bash -s stable echo '[[ -s "/usr/local/lib/rvm" ]] && source "/usr/local/lib/rvm"' > /etc/profile.d/rvm.sh chmod a+x /etc/profile.d/rvm.sh |
3.Logout of the server and log back in
1 2 |
sudo rvm install ruby-1.8.7 sudo rvm install ruby-1.8.7-p358 |
5. Set the default Ruby version to 1.8.7
1 |
sudo rvm --default use 1.8.7-p358 |
6. Switch to the default Ruby version 1.8.7
1 |
sudo rvm default |
7.Download Canvas code
1 2 3 4 5 6 |
sudo mkdir -p /var/rails sudo chown -R nbserver:nbserver /var/rails cd /var/rails/ git clone https://github.com/instructure/canvas-lms.git canvas cd canvas git checkout --track -b stable origin/stable |
8.Install nginx with Passenger rails
1 2 3 4 5 6 7 8 9 |
cd /var/rails/canvas vi Gemfile > remove the below lines (we have to remove postgres gems as we are using mysql as database) #group :postgres do #gem 'pg', '0.10.1' #end sudo gem install bundler sudo bundle install sudo gem install passenger |
9. Install nginx with passenger rails integrated
passenger-install-nginx-module –prefix=/etc/nginx –auto
Note:- Choose auto download and configure Nginx option and continue
useradd nginx
chown nginx /etc/nginx/ -R
10. Configure Nginx
The passenger-install-nginx-module
command above creates an nginx.conf
file in /opt/nginx/conf/nginx.conf
with directives to enable Phusion Passenger. We will replace this with our own nginx.conf
file and configuration structure
1 |
sudo mv /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.install |
Create a new /etc/nginx/conf/nginx.conf
file with the following contents:
Replace the passenger version in the below with the installed version. In this case it is passenger-3.0.0.19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
daemon off; user nginx ; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; pid /var/run/nginx/nginx.pid; error_log /var/log/nginx/error.log; events { worker_connections 2048; } http { passenger_root /usr/local/rvm/gems/ruby-1.8.7-p358/gems/passenger-3.0.19; passenger_ruby /usr/local/rvm/wrappers/ruby-1.8.7-p358/ruby; include mime.types; default_type application/octet-stream; # http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerPoolIdleTime passenger_pool_idle_time 600; # This value will need to be tweaked depending on CPU/RAM. See: # http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerMaxPoolSize passenger_max_pool_size 15; # http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerMinInstances passenger_min_instances 10; # http://www.modrails.com/documentation/Users%20guide%20Nginx.html#PassengerSpawnMethod passenger_spawn_method conservative; rails_framework_spawner_idle_time 0; rails_app_spawner_idle_time 0; access_log /var/log/nginx/access.log; include /etc/nginx/sites-enabled/*.site; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; } |
create nginx init file to start and stop the services
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
#! /bin/sh ### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/etc/nginx/sbin/nginx NAME=nginx DESC=nginx mkdir -p /var/run/nginx chown nginx:nginx /var/run/nginx test -x $DAEMON || exit 0 case "$1" in start) echo -n "Starting $DESC: " /etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf & echo "$NAME." ;; stop) echo -n "Stopping $DESC: " killall nginx echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " killall nginx sleep 1 /etc/nginx/sbin/nginx -c /etc/nginx/conf/nginx.conf echo "$NAME." ;; reload) echo -n "Reloading $DESC configuration: " killall -HUP nginx echo "$NAME." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2 exit 1 ;; esac exit 0 |
1 |
sudo chmod +x /etc/init.d/nginx |
11. Create database in mysql
1 2 3 4 5 6 7 |
mysql -u root -p create database canvas_production; create database canvas_queue_production; grant all on canvas_production.* to canvas@localhost identified by 'password'; grant all on canvas_queue_production.* to canvas@localhost identified by 'password'; flush privileges; exit; |
12. Canvas default configurations
1 2 3 |
cd /var/rails/canvas for config in amazon_s3 database delayed_jobs domain file_store \ outgoing_mail security external_migration; do cp config/$config.yml.example config/$config.yml; done |
13. Configure Database details
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
cd /var/rails/canvas vi config/database.yml ( the properties should look like below ) production: adapter: mysql encoding: utf8 database: canvas_production host: nbserver12.nbos.vinisoft.com username: canvas password: password timeout: 5000 queue: adapter: mysql encoding: utf8 database: canvas_queue_production host: nbserver12.nbos.vinisoft.com username: canvas password: password timeout: 5000 |
14. Configure Outgoing email
1 2 3 4 5 6 7 8 9 10 11 12 13 |
cd /var/rails/canvas vi config/outgoing_mail.yml (the properties should look like below ) production: delivery_method: "smtp" address: "smtp.mailserver.com" port: "587" user_name: "user@nbostech.com" password: "password" authentication: "login" # plain, login, or cram_md5 domain: "nbostech.com" outgoing_address: "user@nbostech.com" default_name: "Instructure Canvas" |
15. URL configuration for canvas
1 2 3 4 |
cd /var/rails/canvas vi config/domain.yml (the properties should look like below ) production: domain: "lms.nbostech.com" |
16. Populate the Database
we need to populate the database with tables and initial data
1 2 |
cd /var/rails/canvas RAILS_ENV=production $GEM_HOME/bin/bundle exec rake db:initial_setup |
17. Generate the canvas files
1 2 |
cd /var/rails/canvas bundle exec rake canvas:compile_assets |
18. create directories and change the file permissions
1 2 3 4 5 6 7 |
cd /var/rails/canvas sudo mkdir -p log tmp/pids public/assets public/stylesheets/compiled sudo chown -R nbserver config/environment.rb log tmp public/assets \ public/stylesheets/compiled Gemfile.lock config.ru sudo chown nbserver config/*.yml sudo chmod 400 config/*.yml ( change the config files to readonly so that no one makes any changes to them by mistake) |
19. Automated Jobs
Canvas has some automated jobs that need to run at occasional intervals, such as email reports, statistics gathering, and a few other things. Canvas installation will not function properly without support for automated jobs.
1 2 3 |
cd /var/rails/canvas sudo ln -s /var/canvas/script/canvas_init /etc/init.d/canvas_init sudo update-rc.d canvas_init defaults |
20. Start the server
1 2 |
sudo /etc/init.d/nginx start /etc/init.d/canvas_init start |