How to Install Shopware CE on Ubuntu 18.04 LTS

Updated on October 5, 2018
How to Install Shopware CE on Ubuntu 18.04 LTS header image

Shopware is an open source eCommerce platform for online businesses. Shopware source code is hosted on Github. This guide will show you how to install Shopware Community Edition (CE) on a fresh Ubuntu 18.04 LTS Vultr server instance.

Requirements

Minimum requirements of Shopware are:

  • PHP version 5.6.4 or above with the following extensions:
  • ctype
  • curl
  • dom
  • hash
  • iconv
  • gd (with freetype and libjpeg)
  • json
  • mbstring
  • OpenSSL
  • session
  • SimpleXML
  • xml
  • zip
  • zlib
  • PDO/MySQL
  • Nginx or Apache with mod_rewrite enabled. This guide will use Nginx
  • MySQL version 5.5.0 or above
  • IonCube Loader version 5.0 optional, but recommended

Before you begin

Check the Ubuntu version.

lsb_release -ds
# Ubuntu 18.04 LTS

Create a new non-root user account with sudo access and switch to it.

adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

sudo dpkg-reconfigure tzdata

Ensure that your system is up to date.

sudo apt update && sudo apt upgrade -y

Install unzip.

sudo apt install -y unzip

Install PHP

Install PHP 7.2 and required PHP extensions.

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mysql php7.2-curl php7.2-json php7.2-zip php7.2-gd php7.2-xml php7.2-mbstring php7.2-opcache

Check the version.

php --version

# PHP 7.2.5-0ubuntu0.18.04.1 (cli) (built: May  9 2018 17:21:02) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
#     with Zend OPcache v7.2.5-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

Install IonCube Loader

Download IonCube Loader.

cd /tmp && wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

Extract the loader.

tar xfz ioncube_loaders_lin_*.gz

Find the PHP extensions directory on the system by running the commands below.

php -i | grep extension_dir
# extension_dir => /usr/lib/php/20170718 => /usr/lib/php/20170718

Copy the ionCube Loader into the PHP extensions directory.

sudo cp /tmp/ioncube/ioncube_loader_lin_7.2.so /usr/lib/php/20170718/

Include the loader via PHP configuration.

sudo vim /etc/php/7.2/fpm/php.ini

Then, add a line in the file to include ionCube loader. It can be anywhere in the file below the [PHP] line.

zend_extension = /usr/lib/php/20170718/ioncube_loader_lin_7.2.so

Save the file and restart PHP-FPM.

sudo systemctl restart php7.2-fpm.service

Install MySQL and setup the database

Install MySQL.

sudo apt install -y mysql-server

Check the version.

mysql --version && sudo mysqld --version

# mysql  Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using  EditLine wrapper
# mysqld  Ver 5.7.22-0ubuntu18.04.1 for Linux on x86_64 ((Ubuntu))

Run mysql_secure installation to improve MySQL security and set the password for the MySQL root user.

sudo mysql_secure_installation

Would you like to setup VALIDATE PASSWORD plugin? N
Please set the password for root here.
New password: **********************
Re-enter new password: **********************
Remove anonymous users? Y
Disallow root login remotely? Y
Remove test database and access to it? Y
Reload privilege tables now? Y

Success.

All done!

Connect to the MySQL shell as the root user.

sudo mysql -u root -p
# Enter password

Create an empty MySQL database and user for Shopware, and remember the credentials.

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Install and configure Nginx

Install Nginx.

sudo apt install -y nginx

Check the version.

sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)

Run sudo vim /etc/nginx/sites-available/shopware.conf and configure Nginx for Shopware.

server {
    listen 80;
    listen [::]:80;
    
    server_name example.com; # Check this
    root /var/www/shopware; # Check this

    index shopware.php index.php;

    location / {
        try_files $uri $uri/ /shopware.php$is_args$args;
    }

    location /recovery/install {
      index index.php;
      try_files $uri /recovery/install/index.php$is_args$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # Check this
    }
}

Activate the new shopware.conf configuration by linking the file to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/shopware.conf /etc/nginx/sites-enabled/

Test the configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install Shopware

Create a document root directory.

sudo mkdir -p /var/www/shopware

Change ownership of the /var/www/shopware directory to johndoe.

sudo chown -R johndoe:johndoe /var/www/shopware

Download the latest release of Shopware.

cd /var/www/shopware
wget http://releases.s3.shopware.com.s3.amazonaws.com/install_5.4.5_6847c0845f0f97230aa05c7294fa726a96dda3ff.zip?_ga=2.133696968.774684214.1529926951-1771999509.1528830594 -O shopware.zip
unzip shopware.zip
rm shopware.zip

NOTE: Update the download link in the command above if there is a newer release.

Change ownership of the /var/www/shopware directory to www-data.

sudo chown -R www-data:www-data /var/www/shopware

Increase memory_limit = 256M and upload_max_filesize = 6M, and set allow_url_fopen = On if it is not already set in the /etc/php/7.2/fpm/php.ini file.

sudo vim /etc/php/7.2/fpm/php.ini

After making changes in the /etc/php/7.2/fpm/php.ini file, reload php7.2-fpm.service

sudo systemctl reload php7.2-fpm.service

Open your domain/IP in the web browser and follow the installation wizard. The backend of Shopware is located at /backend example: http://example.com/backend.

You have successfully installed Shopware.