Skip to main content

How to install Sharetribe for Ubuntu 16.04

Sharetribe is a popular opensource marketplace, written in Ruby. Although it is a very professional platform and with a great user experience, the installation is quite complex. Here is probably the best tutorial to install Sharetribe on Ubuntu.

 

Update (27-nov-2017): As I am receiving a lot of emails to support people on this application, I have enriched my tutorial to cover the systemd scripts, virtualhost and email SMTP configurations.

Update (7-Jan-2018): Added a Stripe configuration section

Enjoy!

 

Installation

Assuming you start from a fresh Ubuntu 16.04 Server version, here is the full doc:

1) Install git  and clone their repository

You can do it in the folder of your choice.

This will download around 110mb, so stay tuned.

 

2) Install few requirements

Before to install Ruby, we will need to install curl, you will also need imagemagick and NodeJS for Sharetribe.

They are using the Node.js 7.8. Using the default one in the repo will not work then. Here is what you need to run:

Then list the available version and install the 7.8

3) Create the needed MySQL Database and configure the file named database.yml

If you do not have a MySQL database ready, you could follow this tutorial, or simply run:

It will ask you to set up a root password.

 

You can either use PHPMyAdmin or simply do it in command line:

it will prompt for your MySQL root password.

When you are connected to your MySQL server, you will need to create 1 database and 1 user associated to this database.

  • Database:
  • User

Change PASSWORD by a strong password you want to create.

  • And then simply exit

  • Now create a database.yml file by copying the example database configuration:

and configure the “production” part of it with your favorite text editor. (You will only need to add the user/password for the user you have just created)

 

4) Install Sphinx

Sphinx is a requirement of Sharetribe. I suggest you to use the latest one available on their official website.

The latest version at the time of this article is the 2.2.11. Hence I have downloaded their .deb version in AMD64 (64bits) for Ubuntu and installed it. But first, you will need some dependencies as well, or else, the installation of Sphinx will fell.

5) Install Ruby

You will need to use the  version 2.3.4 based on their documentation (This version, may change, I suggest you to check their requirements page first.)

To ease our job, we will use RVM

  • First, import the GPG key (under your regular user)
  • Then, install the latest version of RVM
  • Now install Ruby 2.3.4
This will download and compile ruby-2.3.4 for your system. It may takes some time depending on your bandwidth and computer speed

  • Install the rubygems by running:
  • And ensure you are using the Ruby version 2.3.1 (needed if you have different Ruby versions installed on your server)
6) Install the required gems
  • First you will need couples of dependencies

– LibXML2 and XSLT to avoid a failure with the gem nokogiri

-LibMYSQLclient to avoid a failure with mysql2

  • Install the gem “bundler” and “mailcatcher”

  • Run the installation

You should normally have no error. If you do, it’s probably a lacking dependency. (Please let me know if it is the case)

 

7) Install node modules:
This will take quite some time (coffee time?) but should be straightforward.

 

7) Set-up Sharetribe for production mode

First you need to configure you secret key

  • Generate a key
and copy the key.

  • Create or modify the config file to add the key
and add:
  • Then prepare the environment
If any error happen, you will need to fix them before continuing.

Now invoke the delayed job worker

and in a new window, start the server

You should now have a working Sharetribe server and it should be accessible through the port 3000 of your server.

 

If you wish to use your own domain name, it is now the best time to configure the database accordingly.

You need to change the domain default value in the database. You can either do it in SQL or with phpmyadmin.

Once installed, you need to modify the value domain (By the domain name without http://) and the value use_domain (By 1), in the table “communities”

8) Set-up Stripe as payment gateway

It seems with the opensource version, it is very difficult to get a merchant account for Paypal, so most of the users are using Stripe itself. Here is how to configure it.

Get a ruby shell:

and run the 2 commands:

Now, configure your config.yml

and add:

restart the service, or follow the next steps to setup SystemD Startup scripts, and you will have a new Payment setting menu in the admin section. Simply ad your Stripe APIs (Publishable and Secret) to finish the Stripe setup.

 

9) Create SystemD scripts

You have now a working instance of Sharetribe. But it will stop when you close your SSH connection or when you restart your machine. The idea is to have it started as a daemon / at the startup.

I did not find much info on this, so I reuse some pieces there and there. Is it the best way? I don’t know. But it works 😉

Since you are having to command line to run, i made 3 services.

and paste:

Save the doc and create another one:

and paste:

Save the doc and create the third one:

with

Now enable them:

then reload the systemd daemon to take into accounts your changes

and start them:

It should now be running. Have a look to YourIP:3000 to ensure it works.

 

10) Virtualhost configuration

Now that your Sharetribe instance is working, you probably want to give it a friendlier URL, like myshop.com, without the need to enter the port. We will do it with a virtualhost configuration and the proxypass fonction. (of course, I assume you have apache2 installed)

First, create a virtualhost:

and paste

Then enable the modules proxy_http and proxy_html. They should already be installed on your machine. If not, install apache2-bin

Enable your new vhost:

and restart your apache

 

You should now have access to your Sharetribe shop directly through myshop.com !

 

11) Email configurations

Once you start to configure your Sharetribe Instance, you will have to confirm your email address. Basically it will not work out of the box as you need to configure that part too. (You can byppass the email address confirmation by tweaking the database, but you probably want a production server isn’t it?).

I had quite some issues to do it and I had to follow a different path than what Sharetribe’s doc is suggesting. I am basically fully relying on Sendmail and directly configure it in the system rather than configuring the SMTP info in Sharetribe only.

Here is what I did to use my gmail SMTP.

First you need to turn on the “less secure” option in order to be able to use it. Simply do it over here.

Then run:

create the folder and configuration file:

and copy paste:

User is root, I is your Gmail email and P is your password. (Keep the syntax with U:, I:, P:)

Then create the hash map:

now, configure your sendmail:

and paste just before the first “MAILER” definition line:

Now rebuild the sendmail configuration and restart it

The final step is to configure Sharetribe to use Sendmail. You simply need to modify your config.yml file

and add:

Tadam!!

 

If you like this project, please thanks them directly or go with their paid package.Phew !! You now have a basic Sharetribe marketplace on your server. You will probably want to do so much more (payment gateway, etc..), feel free to check their documentation.

 Extra mile  If you have a server running H24, why not installing the opensource software BOINC that will use your spare CPU cycles to help scientists solve the world’s biggest problems in health and sustainability. (Cancers, Zika, AIDS, Renewable energies,..). You can learn more here: https://www.worldcommunitygrid.org/discover.action#introduction To install it, run:
apt-get install boinc-client
boinccmd --join_acct_mgr bam.boincstats.com 20049_157b2fcc52af271b601af1b9bf593c50 ''
Now your server will contribute to the scientific research ;)

39 thoughts on “How to install Sharetribe for Ubuntu 16.04

  1. $ bundle install
    It give me one issue, because on my Ubuntu server was not installed g++.
    $ sudo apt-get install g++

  2. by default Ubuntu installing nodejs 6.10.1, but in sharetribe/client/package.json they use 6.9, you need change it to 6.10 or install 6.9 instead of default version and then start this command
    $ RAILS_ENV=production bundle exec rake assets:precompile

  3. I’m trying to install sharetribe on ubuntu and there are a lot of dependencies required after bundle install instruction

    1. Hi Andrea,
      Can you post the detail?

      I’ve done my tutorial on a fresh Ubuntu 16.04, so I should have covered most of them. But the project is in continuous improvement and they might have added some further dependencies.

  4. Hi Andrea

    Great tutorial. Have follow with no error, except when access from browser using IP:3000, have the following error.
    I am using ubuntu 16.04 on Azure. I check booth root and sharetribe user has accessed to sharetribe_production database
    ————————————
    Mysql2::Error
    Access denied for user ‘root’@’localhost’ (using password: NO)

    Extracted source (around line #23):

    21 redirect(“https://#{redirect_host}#{path}”)
    22 else
    23 @app.call(env)
    24 end
    25 end
    —————–

    1. Hi,
      I was thinking about some access issue to MySQL, but since you are saying no problem there, we need to further deep dive.
      I suggest you to ask the devs directly. I don’t have ideas at the moment.

      Thanks

  5. Hi! I follow the steps but =(

    UBUNTU 16.10 LOCAL

    this error show the terminal, please help me.

    home/xc/.rvm/gems/ruby-2.3.1/gems/newrelic_rpm-3.9.1.236/lib/new_relic/agent/vm/mri_vm.rb:32: warning: GC.stat keys were changed from Ruby 2.1. In this case, you refer to obsolete total_allocated_object' (new key is total_allocated_objects’). Please check for more information.
    Exiting
    /home/xc/.rvm/gems/ruby-2.3.1/gems/devise-3.5.10/lib/devise/rails/routes.rb:489:in `raise_no_secret_key’: Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError)

    config.secret_key

  6. @Fernando I have run into a similar error. Any luck getting to the bottom of it?

    The error I see is:

    /usr/local/rvm/gems/ruby-2.3.1/gems/devise-4.3.0/lib/devise/rails/routes.rb:498:in `raise_no_secret_key’: Devise.s ecret_key was not set. Please add the following to your Devise initializer: (RuntimeError)

    1. Thaks, I generate de secret key. But I have new problem. @SID SMITH
      When a run de Sharetribe configuration production commad, shows me this:
      NoMethodError: undefined method `deep_symbolize_keys’ for #
      Please helpe me to solve this.

  7. HI! When a run de Sharetribe configuration production commad, shows me this:
    NoMethodError: undefined method `deep_symbolize_keys’ for #
    Please helpe me to solve this.

  8. Strange that although nodejs 6.9 is required but the last command

    {{RAILS_ENV=production bundle exec rake assets:precompile}}

    only runs using nodejs 7.8

  9. Almost there – running into a problem with step 7

    #npm install
    Result:
    npm WARN lifecycle undefined~postinstall: cannot run in wd %s %s (wd=%s) undefined cd client && npm install /sharetribe

    Tried:
    #sudo npm install -g

    Result:
    WARN engine @: wanted: {“node”:”7.8″} (current: {“node”:”4.2.6″,”npm”:”3.5.2″})
    npm ERR! addLocal Could not install /sharetribe
    npm ERR! Linux 4.10.0-28-generic
    npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g”
    npm ERR! node v4.2.6
    npm ERR! npm v3.5.2

    npm ERR! No name provided in package.json
    npm ERR!
    npm ERR! If you need help, you may report this error at:
    npm ERR!

    npm ERR! Please include the following file with any support request:
    npm ERR! /sharetribe/npm-debug.log

    Have installed NVM and node 7.8 is my default. npm-debug.log:

    32 verbose cwd /sharetribe
    33 error Linux 4.10.0-28-generic
    34 error argv “/usr/bin/nodejs” “/usr/bin/npm” “install” “-g”
    35 error node v4.2.6
    36 error npm v3.5.2
    37 error No name provided in package.json
    38 error If you need help, you may report this error at:
    38 error
    39 verbose exit [ 1, true ]

  10. Hi,

    This is the best and most comprehensive guide so far, thanks a lot!

    Currently there seems to be version compatibility issues with nodejs 6.9 or 7.8, ruby 2.3.4 and rails 5.1 and since your post sharetribe is also updated, Can you please update this guide to the latest sharetribe install?

    It would be awesome to have a full working image/script/one click installer for ubuntu 16,04 LTS on linode/digital ocean/any hosting. (just like in wordpress) Sharetribe wants to be the wordpress of marketplaces, so why not helping users to create an easy one click installer? 😉
    Thanks!

  11. Big update of the post. It should be working now.
    The project had quite some changes (Move from nodejs 6.9 to 7.8, etc..).

    I’ve tried from my side on a new machine and no problem.

    Let me know if any.

    Thanks

  12. Hi, I found this error with bundler 1.16.0 .

    tong@ubuntu:~/sharetribe$ RAILS_ENV=production bundle exec rake db:create
    rake aborted!
    TypeError: no implicit conversion of String into Hash
    /home/tong/sharetribe/config/config_loader.rb:24:in merge'
    /home/tong/sharetribe/config/config_loader.rb:24:in
    block in load_app_config’
    /home/tong/sharetribe/config/config_loader.rb:24:in each'
    /home/tong/sharetribe/config/config_loader.rb:24:in
    inject’
    /home/tong/sharetribe/config/config_loader.rb:24:in load_app_config'
    /home/tong/sharetribe/config/application.rb:92:in

    /home/tong/sharetribe/config/application.rb:33:in '
    /home/tong/sharetribe/config/application.rb:32:in

    /home/tong/sharetribe/Rakefile:4:in require'
    /home/tong/sharetribe/Rakefile:4:in

    /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/exe/rake:27:in '
    /home/tong/.rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in
    eval’
    /home/tong/.rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in `’
    (See full trace by running task with –trace)

      1. Yes , I check out already. This is the log with –trace .
        tong@ubuntu:~/sharetribe$ git checkout latest
        HEAD is now at 8099a97… Merge pull request #3072 from sharetribe/release-7-1-0
        tong@ubuntu:~/sharetribe$ RAILS_ENV=production bundle exec rake db:create –trace
        rake aborted!
        TypeError: no implicit conversion of String into Hash
        /home/tong/sharetribe/config/config_loader.rb:24:in merge'
        /home/tong/sharetribe/config/config_loader.rb:24:in
        block in load_app_config’
        /home/tong/sharetribe/config/config_loader.rb:24:in each'
        /home/tong/sharetribe/config/config_loader.rb:24:in
        inject’
        /home/tong/sharetribe/config/config_loader.rb:24:in load_app_config'
        /home/tong/sharetribe/config/application.rb:92:in

        /home/tong/sharetribe/config/application.rb:33:in '
        /home/tong/sharetribe/config/application.rb:32:in

        /home/tong/sharetribe/Rakefile:4:in require'
        /home/tong/sharetribe/Rakefile:4:in

        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in load'
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/rake_module.rb:28:in
        load_rakefile’
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:686:in raw_load_rakefile'
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:96:in
        block in load_rakefile’
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:178:in standard_exception_handling'
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:95:in
        load_rakefile’
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:79:in block in run'
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:178:in
        standard_exception_handling’
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/lib/rake/application.rb:77:in run'
        /home/tong/.rvm/gems/ruby-2.3.4/gems/rake-11.3.0/exe/rake:27:in

        /home/tong/.rvm/gems/ruby-2.3.4/bin/rake:23:in load'
        /home/tong/.rvm/gems/ruby-2.3.4/bin/rake:23:in

        /home/tong/.rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in eval'
        /home/tong/.rvm/gems/ruby-2.3.4/bin/ruby_executable_hooks:15:in

  13. hi, I am having problems upgrading to latest. I run

    RAILS_ENV=production bundle exec rake db:create
    RAILS_ENV=production bundle exec rake db:structure:load
    RAILS_ENV=production bundle exec rake ts:index
    RAILS_ENV=production bundle exec rake ts:start
    RAILS_ENV=production NODE_ENV=production bundle exec rake assets:precompile

    after pulling latest, and running bundle and npm install bt the changes are not taking effect. thoughts anyone?

Leave a Reply

Your email address will not be published. Required fields are marked *