Spree is a free and open source e-commerce store application. It is written in Ruby on Rails. Spree is fully featured modular application. It is responsive and fully customizable. It provides a personalized shopping experience to your users. It provides extensive product configuration possibilities so that user can customise the product by themselves. It also provides a comprehensive API for every aspect of the system. Spree is used by more than 45,000 shop owners worldwide.
In this tutorial, we will install Spree Ecommerce Store on CentOS 7 server.
Spree Ecommerce Store does not require any special hardware requirements. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i to switch to root user.
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Spree is written in Ruby on Rails. Run the following command to install Ruby on your system. The YUM repository provides an old version of Ruby, you can use RVM or Ruby Version Manager to install the latest or specific version of Ruby on your server. Run the following command to add the GPG key of RVM on your server.
Now you will need to install bundler. Bundler is a dependency manager for Ruby gem applications.
gem install bundler
Once you have installed bundler, you can continue with the installation of Rails. Run the following command to install Rails version 5.0.0 as this is the only version compatible with Spree 3.2.
gem install rails -v 5.0.0
You can now verify the that rails is installed using the following command.
You will see following output.
[root@liptan-pc ~]# rails -v
You will also need to install ImageMagick library for manipulating images. Run the following command to install ImageMagick.
yum -y install ImageMagick
You will also need to install Node.js. Node.js is not available on YUM repository, you will need to install EPEL repository for this. Run the following command for same.
yum -y install epel-release && yum -y update
Now install Node.js using following command.
yum -y install nodejs
Now that we have Ruby, Rails and other dependencies are installed, you can run the following command to create a new Rails project.
cd /varrails new myshop
You can use any name for your project at the place of myshop. Rails will now create a project in /var/myshop. Now switch to your newly created directory using the following command.
Now you will need to add Spree gems to the gemfile of your newly created project. Open the Gemfile through your favourite text editor. In this tutorial, we will use nano editor. If you do not have nano installed, you can run yum -y install nano. Open the Gemfile using following command.
Now copy and paste the following lines at the end of the file.
Save and exit the editor. Now install the application using the following command.
Bundle will now download and install all the required dependencies. Once the application is installed, run the following commands to setup Spree.
rails g spree:install --user_class=Spree::Userrails g spree:auth:installrails g spree_gateway:install
During the execution of the first command, it will ask you for the email address of the admin account. Provide the admin email and password for the creation of new admin user.
Spree is now installed and configured. You can see the web interface of your e-commerce store immediately by running the inbuilt web server using the following command.
rails server --binding=0.0.0.0
The above command will run the inbuilt server and will listen to port 3000. You can now browse the following address through your browser to see the frontend of your website. You can stop the server by pressing ctrl + c keys on keyboard.
You can set up a systemd service so that it can be managed as a service and can be automatically started on failures and boot time. Run the following command to create a systemd service file.
Copy and paste the following code into the editor.
Now you can start Spree server and configure it to automatically start at boot time using following commands.
systemctl start spreesystemctl enable spree
To check if Spree service is started correctly, you can run the following command to check the status of the Spree service.
systemctl status spree
You should get output similar to shown below.
[root@liptan-pc myshop]# systemctl status spree
● spree.service - Spree service
Loaded: loaded (/etc/systemd/system/spree.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2017-05-31 09:42:22 UTC; 9s ago
Main PID: 23834 (ruby)
└─23834 puma 3.8.2 (tcp://0.0.0.0:3000) [myshop]
May 31 09:42:22 liptan-pc systemd: Starting Spree service...
May 31 09:42:26 liptan-pc spree: => Booting Puma
May 31 09:42:26 liptan-pc spree: => Rails 5.0.3 application starting in development on http://localhost:3000
May 31 09:42:26 liptan-pc spree: => Run `rails server -h` for more startup options
May 31 09:42:26 liptan-pc spree: Puma starting in single mode...
May 31 09:42:26 liptan-pc spree: * Version 3.8.2 (ruby 2.4.0-p0), codename: Sassy Salamander
May 31 09:42:26 liptan-pc spree: * Min threads: 5, max threads: 5
May 31 09:42:26 liptan-pc spree: * Environment: development
May 31 09:42:26 liptan-pc spree: * Listening on tcp://0.0.0.0:3000
May 31 09:42:26 liptan-pc spree: Use Ctrl-C to stop
Instead of using the application on Port 3000, you can use Apache to run on port 80. This way the main application will run on port 3000, and Apache will work as a reverse proxy.
yum -y install httpd
Now start the Apache web server and enable it to automatically start at boot time using the following commands.
systemctl start httpdsystemctl enable httpd
Create a new virtual host file using the following command.
Replace shop.yourdomain.com with your actual domain. Now copy and paste the following lines into the file.
Facebook0TwitterReddit0StumbleUpon0 Do you need to increase the memory limit in WordPress? Getting an error about memory Exhausted? The memory limit is one of the most common WordPress errors as the default limit of memory in WordPress is only set to 64mb! But there’s good news! The Memory Exhausted error is...
Facebook0TwitterReddit0StumbleUpon0 A vulnerability has been discovered in the “All In One WordPress Migration” WordPress plugin. All versions earlier than, and including 6.97 contain a vulnerability which allows Cross-Site Scripting (XSS).With over 2 million active installations, this vulnerability has the potential to be high impact, however, this is lessened by the...
Facebook0TwitterReddit0StumbleUpon0HostPresto will be launching a European point of presence in the coming weeks, specifically in Amsterdam. For customers needing their data located within the EU still please contact support to request migration to this location with ticket subject ‘EU Migration’. We will ensure this is actioned well before the Brexit...