By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
Cloudbooklet Logo
  • Artificial Intelligence
  • Applications
  • Linux
Notification

Free AI Image Generator

Submit Tool
AI Tools
Cloudbooklet AICloudbooklet AI
Search
AI Tools
Submit Tool
  • Artificial Intelligence
  • Applications
  • Google Cloud
  • Compute Engine
  • Linux

Top Articles

Explore the latest updated articles about AI and technology!
Ai Christmas Songs

How to Create AI Christmas Songs Free – 2023

1
Instagram Profile Views

Instagram Profile Views -What to Expect in 2024

Bing Gpt-4 Deep Search

Bing GPT-4 Deep Search: A New Era of AI-Powered Queries

Follow US
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
Cloudbooklet © 2023 All rights reserved.

Home » Google Cloud » Install Spree Commerce on Google Cloud with Ubuntu 18.04, Passenger and Nginx

Google CloudCompute Engine

Install Spree Commerce on Google Cloud with Ubuntu 18.04, Passenger and Nginx

Last updated: 2019/12/21 at 6:02 AM
By Cloudbooklet
Install Spree Commerce On Google Cloud With Ubuntu 18.04, Passenger And Nginx
SHARE
Readers like you help support Cloudbooklet. When you make a purchase using links on our site, we may earn an affiliate commission.

Install Spree Commerce on Google Cloud with Ubuntu 18.04, Passenger and Nginx

In this guide, you are going to learn how to install and set up a leading Open Source Platform Spree Commerce built with Ruby on Rails in a production environment.

Table of Contents
PrerequisitesInstall Ruby on Rails with RVMInstall RubyInstall RailsInstall Spree CommerceInstall Passenger and NginxNginx Configurations for Spree Commerce

Prerequisites

  1. For setting up Compute Engine, see the Setting up Compute Engine Instance.
  2. Domain name is pointed to your virtual machine.
  3. For setting up Cloud DNS, see the Setting up Google Cloud DNS for your domain.
  4. Google Cloud SQL Setup, see Setup Cloud SQL and connect with Compute Engine.

Install Ruby on Rails with RVM

SSH to your Compute Engine Instance and execute the following commands to install RVM. Replace username with your username

\curl -sSL https://get.rvm.io | bash
source /home/username/.rvm/scripts/rvm

Install Dependencies

rvm requirements

Wait for the dependencies installation to complete

Install Ruby

Once RVM and dependencies are installed successfully you can install Ruby with RVM.

rvm install ruby
rvm --default use ruby
ruby -v

Bundler is a tool that manages gem dependencies for all projects. Install the Bundler gem next as Rails depends on it.

gem install bundler

Install Nodejs, ImageMagick, MySQL Client, and some required packages

sudo apt-get install -y nodejs imagemagick libcurl4-openssl-dev mysql-client libmysqlclient-dev

Install Rails

gem install rails
rails -v

Now install MySQL adapter for Rails

gem install mysql2

Create a new Rails project

rails new myproject -d mysql
cd myproject

Edit the database configuration to connect to Cloud SQL

sudo nano config/database.yml

Replace the username with your username, password with your password, host with your Cloud SQL IP address

Make sure your database.yml looks like this

default: &default
  adapter: mysql2
  encoding: utf8
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: username
  password: password
  host: Cloud_SQL_IP_Address
  database: database_name

development: 
  <<: *default 

test: 
  <<: *default

production:
  <<: *default

Install Spree Commerce

Add Spree to your Gemfile

sudo nano Gemfile

Add the following to the last

gem 'therubyracer', platforms: :ruby
gem 'spree', '~> 3.6.4'
gem 'spree_auth_devise', '~> 3.3'
gem 'spree_gateway', '~> 3.3'
bundle install
rails g spree:install --user_class=Spree::User

Enter your admin credentials when prompted and complete the installation.

Install Passenger and Nginx

Once Spree Commerce is installed you can install Passenger and configure Nginx

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y nginx-extras libnginx-mod-http-passenger
if [ ! -f /etc/nginx/modules-enabled/50-mod-http-passenger.conf ]; then sudo ln -s /usr/share/nginx/modules-available/mod-http-passenger.load /etc/nginx/modules-enabled/50-mod-http-passenger.conf ; fi
sudo ls /etc/nginx/conf.d/mod-http-passenger.conf
sudo service nginx start

Now Passenger and Nginx are installed successfully. You can visit your domain name in your web browser, you can see the Nginx welcome page.

Nginx Configurations for Spree Commerce

Now you need to update the Nginx configuration to point Passenger to the version of Ruby you are using.

sudo nano /etc/nginx/conf.d/mod-http-passenger.conf

Replace

passenger_ruby /usr/bin/passenger_free_ruby;

with

passenger_ruby /home/username/.rvm/wrappers/ruby-2.5.3/ruby;

Remove default Nginx configurations

sudo rm -rf /etc/nginx/sites-available/default
sudo rm -rf /etc/nginx/sites-enabled/default

Create a new configuration for your Ruby application

sudo nano /etc/nginx/sites-available/yourdomainname.com

Paste this new configuration setting and hit Ctrl+X followed by Y to save the file

server {
    listen 80 default_server;
    server_name yourdomainname.com;

    passenger_enabled on;
    passenger_app_env production;

    root /home/username/myproject/public;
}

Enable your new configuration

sudo ln -s /etc/nginx/sites-available/yourdomainname.com /etc/nginx/sites-enabled/

Validate Nginx configuration and restart your Nginx web server.

sudo nginx -t
sudo service nginx restart

Now Spree Commerce is installed and configured with Passenger and Nginx and connected with Cloud SQL on Google Cloud.

Visit your domain name on your browser, you can view the Spree Commerce homepage

Spree Commerce Homepage

Check your Spree Commerce admin page by entering the admin followed by your domain name (yourdomainname.com/admin)

Spree Commerce Admin Page

Enjoy your installation of Spree Commerce on Google Cloud with Ubuntu 18.04 LTS, Passenger, Nginx and connected to Cloud SQL.

TAGGED: Compute Engine, Google Cloud Platform, Ruby on Rails, Spree Commerce, Ubuntu 18.04
Share This Article
Facebook Twitter Whatsapp Whatsapp LinkedIn Reddit Telegram Copy Link Print
Share
Leave a review Leave a review

Leave a review Cancel reply

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

Please select a rating!

Popular

Amazon Titan
How Amazon Titan Image Generator Can Revolutionize Generative AI
Artificial Intelligence
Omegle Shutdown
Omegle shutdown: The Reasons and Their Solutions
Artificial Intelligence
Ai Christmas Card
How to Create Amazing AI Christmas Cards Online
Artificial Intelligence
Google Reallife Ai Model
Experience the Magic of Google RealLife AI Model
Artificial Intelligence
- Advertisement -

Subscribe Now

loader

Subscribe to our mailing list to receives daily updates!

Email Address*

Name

Related Stories

Uncover the stories that related to the post!
Free Linux Cloud Server
Artificial Intelligence

Top 5 Free Linux Cloud Servers to Host Your Website

How To Install Git On Ubuntu 20.04
Google CloudLinux

How to Install Git on Linux

Vector Image
Data ScienceGoogle Cloud

DataStax Enhances Astra DB on Google Cloud with Vector Search Capability

How To Setup Ssh Keys On Ubuntu
Google CloudAWS

How to Setup SSH Keys on Ubuntu 20.04

Cloudbooklet Logo
  • Categories:
  • Artificial Intelligence
  • Applications
  • Google Cloud

Quick Links

  • About
  • Contact
  • Disclaimer
  • Privacy Policy
Cloudbooklet © 2023 All rights reserved.
Welcome Back!

Sign in to your account

Lost your password?