Shopware is one of the best free and open-source platforms that helps you to start your own e-commerce website. It provides you useful tools to help you build and customize a fully responsive and functional online store in a matter of a few minutes. We have all heard about other ecommerce platforms such as Magento, BigCommerce and WooCommerce but like other platforms, Shopware is powerful, easy-to-use, and a flexible application with an ever growing open source community. It has an intuitive interface which makes it easier to create and manage content and products and on top of that, it is super quick.

While Shopware support is not officially available on Nginx but in this tutorial, we will show you how to install Shopware with Nginx and have it up and running in a matter of few mins.

Prerequisites:

  • A development server running PHP7.3 (or higher), MySQL and Nginx.
  • A valid domain name or a local host file override
  • Full root level access to your server.

Installation

Download Shopware

Let’s suppose you are using a local domain i.e. local.shopware.com and updated your OS hosts file with the domain name to point to your local server i.e. 127.0.0.1.

For us to install shopware, first we will create an installation directory on your local server:

mkdir /var/www/htdocs/local.shopware.com

Next, download the Shopware with the following command:

wget https://www.shopware.com/en/Download/redirect/version/sw6/file/install_v6.3.5.0_ba08dbfc07784b5cefe7837f2abbda69dbf5b8b7.zip -O shopware.zip

Once the download is complete, unzip shopware.zip to the shopware directory:

unzip shopware.zip -d /var/www/htdocs/local.shopware.com

Next, set proper permission and ownership with the following command:

chown -R root:root /var/www/htdocs/local.shopware.com
chmod -R 775 /var/www/htdocs/local.shopware.com

NOTE: We have set ROOT as the directory owner purely because it is a local installation. Please do not set ROOT as the file owner on your live production or development environment.

Create a Database for Shopware

You can either create a new database using the shopware installation wizard or do it beforehand using the following commands:

First, connect to the MySQL server using the following command:

mysql -uroot -p -hlocalhost

Once connected, create a database and user with the following command:

MySQL [(none)]> CREATE DATABASE shopware;
MySQL [(none)]> GRANT ALL ON shopware.* TO 'shopware' IDENTIFIED BY 'password';
MySQL [(none)]> FLUSH PRIVILEGES;
MySQL [(none)]> EXIT;

Once you are finished, you can proceed to the next step to configure Nginx.

Configure Nginx for Shopware

Shopware entry point is in its public directory so you will need to create an Nginx virtual host file for Shopware with the following command:

nano /etc/nginx/conf.d/shopware.conf

And add the following block:

server {
    listen 80;

    # Handle / to index.php
    index index.php;

    # Our server name
    server_name local.shopware.com;

    # Where the code is located
    root /var/www/htdocs/local.shopware.com/public;

    # Needed for Shopware install / update
    location /recovery/install {
        index index.php;
        try_files $uri /recovery/install/index.php$is_args$args;
    }

    location /recovery/update/ {
        if (!-e $request_filename){
            rewrite . /recovery/update/index.php last;
        }
    }

    # Forward any not found file to index.php. Also allows to have beautiful urls like /homemade-products/
    location / {
        try_files $uri /index.php$is_args$args;
    }

    # Let php-fpm handle .php files
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        fastcgi_read_timeout 300s;
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php-fpm/www.sock;
        http2_push_preload on;
    }
}

Finally, save the file and restart Nginx.

Access Your Local Shopware Website

We will now complete final step of the installation using the web installation wizard.

So, open your web browser and type the URL http://local.shopware.com.

Select your language and click on the Next button. Make sure all the requirements have been met then click on the Next button. You should see the following page:

Agree to the GTC and click on the Next button to head to the Database configuration section:

Provide your database, username, password and click on the Start installation button and follow the steps to complete the configuration.

Once you have completed the installation wizard and shopware installed, you will be redirected to the dashboard. That’s all!