How to Install Spree Commerce on Debian Latest

Spree Commerce is a free, open-source e-commerce platform that can be used to build online shops, or to integrate an online store with an existing website. In this tutorial, we will cover the steps required to install Spree Commerce on Debian Linux.

Prerequisites

Before we begin, you will need the following:

Step 1: Install Required Dependencies

Spree Commerce requires a few dependencies to run properly. Use the following command to install them:

sudo apt update
sudo apt install git curl build-essential openssl \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev \
libxml2-dev libxslt1-dev libcurl4-openssl-dev \
software-properties-common libffi-dev libpq-dev nodejs yarn

Step 2: Install Ruby

Spree Commerce is built using the Ruby programming language. To install Ruby, you can use the following commands:

sudo apt-add-repository -y ppa:rael-gc/rvm
sudo apt update
sudo apt install rvm
source /etc/profile.d/rvm.sh
rvm install 2.7.0

Step 3: Configure the Environment

Next, we need to configure the environment for Spree Commerce. First, we will create a new user for Spree and switch to that user:

sudo adduser spree
sudo su - spree

Next, we will create a new file called .bashrc in the Spree user's home directory:

nano ~/.bashrc

Add the following line to the bottom of the file:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Save and close the file.

Step 4: Install Spree Commerce

Now that we have configured the environment, we can install Spree Commerce. Use the following command to install it:

gem install spree

This will install the latest version of Spree Commerce.

Step 5: Set up the Database

Next, we need to set up the database for Spree Commerce. If you have not already installed a DBMS such as PostgreSQL or MySQL, do so now.

Once you have installed the DBMS, log in to the database as the superuser and create a new user and database for Spree Commerce:

sudo su - postgres
psql
CREATE USER spree WITH PASSWORD 'password';
CREATE DATABASE spree_production OWNER spree;
GRANT ALL PRIVILEGES ON DATABASE spree_production TO spree;
\q
exit

Replace password with a strong password.

Step 6: Configure Spree

Now we need to configure Spree Commerce to use the database we just created. First, create a new file called database.yml in the Spree user's home directory:

nano ~/database.yml

Add the following content to the file:

production:
  adapter: postgresql
  encoding: unicode
  database: spree_production
  username: spree
  password: password
  host: localhost

Replace password with the password you created in Step 5.

Save and close the file.

Step 7: Start the Server

We are now ready to start the Spree Commerce server. Use the following command to start it:

bundle exec rails server -e production

This will run the server in production mode. By default, it will listen on http://localhost:3000.

Conclusion

In this tutorial, we have covered the steps required to install Spree Commerce on Debian Linux. You can now customize your Spree store and start selling products online!

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!