Install Drupal Commerce 2 on a shared host

Commerce Guys and their trusty friends recently released Commerce 2, a rewrite of an ecommerce system for Drupal 8. It is amazing.

This article walks you through installing Commerce 2 on a shared hosting account. I teach an ecommerce class at Oakland University, in Michigan. Hello, Shannon, Kayla, Isaac, Victoria, Jessica, Ashley, Chris, Brooke (suspected assassin), Will (Killer of Worlds), and everyone else!

This article is for students in that class. Maybe you’ll find it useful, too.

We use Reclaim Hosting. However, the process will be almost identical on other hosting platforms.

There are three main steps:

  1. Make a Drupal site
  2. Add Commerce files
  3. Enable Commerce modules

Make a Drupal site

Your first Commerce site should be for learning and testing. I recommend you make a subdomain for your site, in a directory outside your regular Web root. This will let you keep your test site separate from everything else. It won’t interfere with your main site, and you can erase it anytime you like.

Make a subdomain

Use cPanel to make a subdomain.

From your cPanel home page
Making the new subdomain

Type in the name of the subdomain, and select the domain it will belong to. My subdomain is transporte.kieranmathieson.com. You should type something else besides transporte. Whatever makes sense for your project.

Type in the document root, that is, the directory Drupal’s files will be in. The default that Reclaim offers is OK. However, I prefer to put all my subdomains under the subdomains directory. A little more organized for my old, failing brain. I type the name of the subdomain after the /, so that the inner directory has the same name as the subdomain. You’ll see what that means in a mo’.

Hit the Create button. cPanel will make the subdomain for you. Check the subdomain list, to make sure it’s there.

Pro tip: Remember, your computer hates you. It will take any opportunity to cause you pain. Don’t make it easy for your computer. Check after each step.

Where the wild files are

Let’s make sure you understand that directory stuff. It will be important later.

In cPanel, open the File Manager.

Starting the File Manager

The File Manager shows you the files on your server. Don’t delete any files, if you don’t know what you are doing. You could break your site.

File Manager shows directories on the left, and files on the right.

Remember this?

Making the new subdomain

subdomains is a directory. Scroll down File Manager’s directory list, and you’ll see it.

subdomains directory

Click the + to open the directory, and you’ll see transporte (or whatever you named your subdirectory) inside it.

Where the subdomain’s files are

When a browser goes to https://transporte.yoursite.com, the server will get files from that inner directory. That’s where Drupal will go.

Make an SSL certificate

You should encrypt traffic from every Web site, if you can. Reclaim Hosting makes it easy with Let’s Encrypt. Use it to add an SSL certificate to your subdomain. The certificate is what your browser and server will use to encrypt site traffic.

Go to your cPanel home. Then:

Make an SSL certificate

Choose the subdomain you want to make a certificate for, and click the Issue link.

Issue a certificate

It’s that easy! W00t!

Install Drupal 8 in the subdomain

Reclaim Hosting has Installatron, a magical software installer. Let’s use that to put Drupal in the subdomain.

Installatron, I choose you!
Drupal me this…
Insert your own funny caption here
Choose subdomain, empty the directly, choose Drupal 8

Choose the subdomain to drop Drupal in. https, remember. Clear the directory field, so you don’t add another directory level. Choose the latest Drupal 8.

Some more fields:

More fields

Type in your own user name and password. Write them down. You’ll need them later.

Click the Install button. Installatron the Magnificent will start a background task. Eventually, you’ll have a Drupal 8 in your subdomain. Yowza!

Add Commerce files

Now on to step 2 of 3: adding the Commerce 2 files. You’ll need some command-line-fu for that. Don’t worry, it’s only three commands. What could possibly go wrong?

Get an SSH program

You’ll need a way to connect to your server’s command-line shell. With Windows, you can use PuTTY. It’s free. Download an installation program from www.chiark.greenend.org.uk/~sgtatham/putty/download.html. Run it, and PuTTY will be yours! Well, not yours, but you can use it.

If you’re on a Mac, you already have an SSH program. Lucky you!

Log in to your server

On Windows, run PuTTY, and you’ll see a connection dialog:

PuTTY connection

Type your domain, like billybob.com, in the Host name field. Don’t put an http in the front. Just the plain domain. Leave SSH selected. Click Open.

If you have a Mac, errrr… do something else. Maybe check this link.

Type in your user name and password. These will be the same ones you used to login to your Web hosting account, to get to cPanel. Probably.

You’ll have a command-line prompt. It will be something like:

billyjoe@unwound [~]#

In this example, the user is billyjoe, on the unwound server. The tilde (~) shows the current directory. ~ means your home directory. More in a moment.

Change the current directory

You need to put the Commerce files in the right directory. Remember this?

Where the subdomain’s files are

That’s the directory where your subdomain’s files hang out.

At the command line, only one directory can be the “current directory,” the place where most commands put files by default. Use the cd command to change the current directory. E.g.:

cd subdomains/transporte

Or maybe:

cd subdomains/bananas

Whatever you called the directory. BTW, the /s matter, so don’t add extras, like directly after cd.

How to check that you’re in the right place? Look at the command prompt. It should show you the current directory. If your system doesn’t show the current directory in the prompt (some don’t), use the pwd command. Just type it and press Enter. It stands for print working directory. You’ll see something like:

/home/bobbybob/subdomains/transporte

If you don’t see the directories you expect, the cd ~ command will take you back to your home directory, and you can try the first cd again.

OK, now you have the right directory. Time to put Commerce’s files in it.

Install Drupal commerce with Composer

Composer is a program that will download code files and put them in the right places. Composer only works with some software. It works with Drupal. Hooray!

Type:

composer require "drupal/commerce"

Include the quotes.

Composer will show you a lot of messages, as it does its work. Eventually, you’ll see something like:

Final message from Composer

The last line is the command-line prompt again. The shell ran your Composer command, and is waiting for your next command. Yeehah!

Log out of your server

You’re done here. You can logout. The command is:

logout

Or, to be really geeky, ^D.

Close PuTTY, or whatever Mac thing you used.

Enable Commerce modules

Now the Commerce files are in your subdomain. Time to activate them.

First, log in to Drupal as user 1. Type the user name and password you gave Installatron earlier:

You recorded them, right?

Turn on Update Manager

When Reclaim Hosting’s Installatron installs Drupal, it doesn’t turn on the Update Manager module. I don’t know why. You need Update Manager. So, Admin | Extend. Scroll down, and you’ll see:

Update Manager is off

Click the Update Manager checkbox, and click Install at the bottom of the page. Here’s what I saw when I did that:

After the module is enabled

There should be an Install button on that screen, that lets you install new modules. It’s not there. Curses!

The first thing to do when Drupal doesn’t work the way you expect is to clear its caches. Go to Configuration | Performance, and click the button:

Clear the caches

It could take a while, but you’ll get a message that the caches have been cleared. Go back to Extend. You should see a button for installing modules:

Install button appears

Yes! We are rockin’ geeks!

Enable modules

Almost done. Scroll down on the Extend page, and you’ll see Commerce’s modules listed. There are some others you’ll need to enable, as well. Turn these ones on:

Click that ol’ time Install button. It could take a little while.

Check it

The Extend page will come back to you, and tell you it installed the new modules. How do know it worked? Look at the admin menu. There’s a new entry.

New Commerce menu item

Celebrate!

You did it! Celebrate! Play with your dog, have some chocolate, whatever hammers your strings. That’s a new saying. A dulcimer reference. You’re welcome.

Commerce 2 is full of serious goodness. It’s moderately complex, but that comes with the power to customize product info, make any reports you want… well, you name it, pretty much. Now that you’re installed it, start testing it out.