Install Shopware 5 on Ubuntu 16.04

Install Shopware 5 on Ubuntu 16.04

We’ll show you. how to install Shopware 5 on Ubuntu 16.04, with MariaDB, PHP-FPM and Nginx. Shopware is a modern open source e-commerce software, written in PHP on top of Symfony and Zend components. This guide should work on other Linux VPS systems as well but was tested and wrote this for an Ubuntu 16.04 VPS

. Install Shopware 5 on Ubuntu 16.04

1. Login to your VPS via SSH with your sudo user

ssh [email protected]_IP

2. Update the system and install necessary packages

[user]$ sudo apt-get update && sudo apt-get -y upgrade
[user]$ sudo apt-get install software-properties-common nano wget ant

3. Install MariaDB 10.1

To add the MariaDB repository to your sources list and install the latest MariaDB 10.1 server, run the following commands:

[user]$ sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
[user]$ sudo add-apt-repository 'deb [arch=amd64,i386] xenial main'
[user]$ sudo apt-get update
[user]$ sudo apt-get install -y mariadb-server

When the installation is complete, run the following command to secure your installation:

[user]$ mysql_secure_installation

Next, we need to create a database for the Shopware installation.

[user]$ mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE shopware;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON shopware.* TO 'shopware'@'localhost' IDENTIFIED BY 'strong_password';
MariaDB [(none)]> \q

4. Install PHP and required PHP modules

To install the latest stable version of PHP version 7.0 and all necessary modules, run:

[user]$ sudo apt-get -y install php-fpm php-cli php-json php-curl php-gd php-mysql php-xml php-mbstring

The following commands will set the PHP memory limit to 512MB, change the values of upload_max_filesize and post_max_size to 100M and set the timezone to UTC.

sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/cli/php.ini
sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/cli/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini
sed -i "s/upload_max_filesize = .*/upload_max_filesize = 100M/" /etc/php/7.0/fpm/php.ini
sed -i "s/post_max_size = .*/post_max_size = 100M/" /etc/php/7.0/fpm/php.ini

Create a new PHP-FPM pool for your user if you already don’t have one:

[user]$ sudo nano /etc/php/7.0/fpm/pool.d/your_user_name.conf
user = your_user_name
group = your_user_name
listen = /var/run/php/php7.0-your_user_name-fpm.sock
listen.owner = your_user_name = your_user_name
listen.mode = 0666
pm = ondemand
pm.max_children = 5
pm.process_idle_timeout = 10s
pm.max_requests = 200
chdir = /

Do not forget to change your_user_name with your username.
Restart PHP-FPM:

[user]$ sudo service php7.0-fpm restart

5. Download and Install Shopware

Download the latest version of Shopware from GitHub: At the time of writing, the latest version is Shopware version 5.1.6.

[user]$ wget
[user]$ unzip
[user]$ mv shopware-5.1.6 ~/
[user]$ rm -f

Set up the configuration and database connection:

[user]$ cd ~/
[user]$ ant configure
[user]$ ant build-unit

Download the test images:

[user]$ cd ~/
[user]$ wget
[user]$ unzip

6. Install and configure Nginx

To install the latest stable version of Nginx available on the Ubuntu repositories, run:

[user]$ sudo apt-get install nginx

Generate a self signed ssl certificate:

[user]$ sudo mkdir -p /etc/nginx/ssl
[user]$ cd /etc/nginx/ssl
[user]$ sudo openssl genrsa -des3 -passout pass:x -out shopware.pass.key 2048
[user]$ sudo openssl rsa -passin pass:x -in shopware.pass.key -out shopware.key
[user]$ sudo rm shopware.pass.key
[user]$ sudo openssl req -new -key shopware.key -out shopware.csr
[user]$ sudo openssl x509 -req -days 365 -in shopware.csr -signkey shopware.key -out shopware.crt

If you don’t want to get warnings associated with self-signed SSL Certificates, you can purchase a trusted SSL certificate here.

Next, create a new Nginx server block:

[user]$ sudo nano /etc/nginx/sites-available/
server {
    listen 443;
    root /home/your_user_name/;

    index shopware.php index.php;

    location / {
      rewrite files/documents/.* /engine last;
      rewrite backend/media/(.*) /media/$1 last;

      try_files $uri $uri/ /shopware.php$args;

    ssl on;
    ssl_certificate     /etc/nginx/ssl/shopware.crt;
    ssl_certificate_key /etc/nginx/ssl/shopware.key;
    ssl_session_timeout 5m;
    ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    access_log  /var/log/nginx/shopware.access.log;
    error_log   /var/log/nginx/shopware.error.log;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.0-your_user_name-fpm.sock;
        fastcgi_index shopware.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;

    location ~ /\.ht {
        deny all;

server {
    listen      80;

    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://$server_name$request_uri? permanent;

Do not forget to change your_user_name with your username.

Activate the server block by creating a symbolic link :

[user]$ sudo ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

7. Test and Restart the Nginx Web Server

Test the Nginx configuration and restart nginx:

[user]$ sudo nginx -t
[user]$ sudo service nginx restart

That’s it. You have successfully installed Shopware on Ubuntu 16.04. The default username and password are both demo. For more information about how to manage your Shopware installation, please refer to the official Shopware documentation.

Of course you don’t have to do any of this if you use one of our Optimized Ubuntu VPS Hosting services, in which case you can simply ask our expert Linux admins to setup this for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Install Shopware 5 on Ubuntu 16.04,  please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Install Lychee on an Ubuntu VPS
Tips and Tricks
How to install and manage software on CentOS 7
How to install mod_security and mod_evasive on an Ubuntu 14.04 VPS
  • Phil


    Author Reply

    Thank you very much !
    There is a little mistake in your nginx config. “rewrite backend/media/(.*) /media/$1 last” should have a “;” at the end of the line.


    • admin


      Author Reply

      Thanks Phil! We updated the post.

  • Andreas


    Author Reply

    when trying this on Ubuntu Server 16.04 and 16.10.02 the Shop wouldnt start. In /var/log/nginx/shopware.error.log the following messages showed:

    2017/03/25 12:16:00 [error] 52185#52185: *2 FastCGI sent in stderr: “PHP message: PHP Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1665 Cannot execute statement: impossible to write to binary log since BINLOG_FORMAT = STATEMENT and at least one table uses a storage engine limited to row-based logging. InnoDB is limited to row-logging when transaction isolation level is READ COMMITTED or READ UNCOMMITTED. in /home/andreas/
    Stack trace:
    #0 /home/andreas/ PDOStatement->execute()
    #1 /home/andreas/ Shopware\Components\Session\PdoSessionHandler->doRead(‘a08f929b57ebf2f…’)
    #2 [internal function]: Shopware\Components\Session\PdoSessionHandler->read(‘a08f929b57ebf2f…’)
    #3 /home/andreas/ session_start()
    #4 /home/andreas/” while reading response header from upstream, client:, server:, request: “GET / HTTP/1.1”, upstream: “fastcgi://unix:/var/run/php/php7.0-andreas-fpm.sock:”, host: “”

    After changing /etc/mysql/my.cnf
    service mysqld restart
    the Shopware page startet to work.

    Best regards,

  • Andreas


    Author Reply

    Sorry, that was service mariadb restart, of course…

  • Boris


    Author Reply

    Hi, after finishin this tutorial, I’m facing problems to load the page in my browser.
    The nginx Server gets into a infinite redirect loop, where at some point the browser ends the request.

    So the servers is constantly redirecting (HTTP 301) with this nginx config, can you help me with this issue?

    Thanks in Advance!
    Best regards!

    • admin


      Author Reply

      Hi Boris,

      Please closely follow the tutorial and make all necessary changes to the nginx configuration file.

  • Micha


    Author Reply

    thanks for the Article. Maybe you should add “php-zip” to the installation, since the “composer install” process will need it – so it also can be used when you´re not building via ANT.