Shopware CE is a free and open-source eCommerce platform written in Symfony and Vue.js. It is based on a quite modern technology stack and a very good alternative to another eCommerce application, like Magento. It is a very powerful and flexible application and gives you the freedom to quickly and easily leverage your growth potential and focus on the perfect customer experience. It provides a simple and easy to use admin interface for managing clients and orders. It allows you to manage the prices of products, change or update themes, design email templates for marketing your products, and generate statistical results.

In this tutorial, we will show you how to install Shopware CE with Nginx and Let’s Encrypt on Ubuntu 20.04.

Prerequisites

  • A server running Ubuntu 20.04 with a minimum of 4 GB of RAM.
  • A valid domain name pointed with your server.
  • A root password is configured on your server.

Install Nginx and MariaDB

First, install the Nginx web server and the MariaDB database server using the following command:

apt-get install nginx mariadb-server -y

Once both package are installed, start Nginx and MariaDB service, and enable them to start at system boot:

systemctl start nginx

systemctl start mariadb

systemctl enable nginx

systemctl enable mariadb

Install PHP and Other Components

Shopware 6 supports PHP versions between 7.2 to 7.3. So you will need to install PHP along with other libraries in your system.

First, add the PHP repository in your system with the following command:

apt-get install software-properties-common -y

add-apt-repository ppa:ondrej/php

Once the repository is added, install PHP with other libraries using the following command:

apt-get install 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-intl php7.2-opcache git unzip socat curl bash-completion -y

Once all the packages are installed, edit the php.ini file and tweak some desired settings:

nano /etc/php/7.2/fpm/php.ini

Change the following lines:

memory_limit = 512M
upload_max_filesize = 20M
max_execution_time = 300

Save and close the file when you are finished.

Next, you will need to install IonCube loader in your system.

First, download it with the following command:

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

Once downloaded, extract the downloaded file with the following command:

tar xfz ioncube_loaders_lin_x86-64.tar.gz

Next, locate the path of the PHP extension directory:

php -i | grep extension_dir

You should see the following output:

extension_dir => /usr/lib/php/20190902 => /usr/lib/php/20190902

Next, copy IonCube loader to the PHP extension directory:

cp ioncube/ioncube_loader_lin_7.2.so /usr/lib/php/20180731/

Next, edit the php.ini file and define the IonCube loader:

nano /etc/php/7.2/fpm/php.ini

Add the following line inside [PHP] section:

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

Save and close the file then restart the PHP-FPM service to apply the changes.

systemctl restart php7.2-fpm

Configure MariaDB Database

First, secure the MariaDB installation and set the root password using the following script:

mysql_secure_installation

Answer all the questions as shown below:

Enter current password for root (enter for none): 
Set root password? [Y/n] Y
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Once you are done, login to MariaDB shell with the following command:

mysql -u root -p

Provide your MariaDB root password then create a database and user for Shopware:

MariaDB [(none)]> CREATE DATABASE shopwaredb;

MariaDB [(none)]> GRANT ALL ON shopwaredb.* TO 'shopware'@'localhost' IDENTIFIED BY 'password';

Next, flush the privileges and exit from the MariaDB using the following command:

MariaDB [(none)]> flush privileges;

MariaDB [(none)]> exit;

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

Install Composer

Composer is a dependency manager for PHP. It is used to install all PHP dependencies required to install Shopware.

You can install it using the curl command as shown below:

curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer

Once installed, verify the Composer version with the following command:

composer --version

You should get the following output:

Composer version 1.10.7 2020-06-03 10:03:56

Download Shopware

First, create a directory for Shopware inside the Nginx web root directory:

mkdir /var/www/html/shopware

Next, change the directory to shopware and download the latest version of Shopware using the following command:

cd /var/www/html/shopware

wget https://www.shopware.com/en/Download/redirect/version/sw6/file/install_6.2.2_1592398977.zip

Once downloaded, unzip the downloaded file with the following command:

unzip install_6.2.2_1592398977.zip

Next, install all the PHP dependencies using the following command:

composer install

Next, change the ownership of the shopware directory and give proper permissions using the following command:

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

chmod -R 755 /var/www/html/shopware

Once you are done, you can proceed to the next step.

Configure Nginx for Shopware

First, create a new Nginx virtual host configuration file for Shopware:

nano /etc/nginx/sites-available/shopware.conf

Add the following lines:

server {
    listen 80;

    index index.php index.html;
    server_name shopware.linuxbuz.com;
    root /var/www/html/shopware/public;

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

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

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

    location ~ .php$ {
        fastcgi_split_path_info ^(. .php)(/. )$;
        include fastcgi.conf;
        fastcgi_param HTTP_PROXY "";
        fastcgi_buffers 8 16k;
        fastcgi_buffer_size 32k;
        client_max_body_size 24M;
        client_body_buffer_size 128k;
        fastcgi_pass unix:/run/php/php7.2-fpm.sock;
        http2_push_preload on;
    }
}

Save and close the file then enable the Shopware virtual host file with the following command:

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

Next, check the Nginx for any syntax error using the following command:

nginx -t

You should get the following output:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Next, restart the Nginx service to apply the changes:

systemctl reload nginx

Access Shopware Installation Wizard

At this point, Shopware is installed in your system. Now, open your web browser and type the URL http://shopware.linuxbuz.com. You should see the Shopware web installation wizard:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Select your language and click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Make sure all required dependencies are installed then click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Accept the terms and conditions, and click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Provide your database details and click on the Start Installation button. Once the installation has been completed successfully, you should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Now, click on the Next button. You should see the Shopware configuration screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Provide your shop name, email, country, admin email, admin username, password and click on the Next button. You will be redirected to the Shopware dashboard screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Install your desired data and click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Select your desired email agent and click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Select your desired option and click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Configure your PayPal or click on the Skip button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Configure your PayPal credentials or click on the Skip button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Select your region and click on the Next button. You should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Click on the Skip button. Once the Shopware is configured, you should see the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Click on the Finish button. You should see the Shopware dashboard in the following screen:

How to Install Shopware 6 with Nginx and Let's Encrypt SSL on Ubuntu 20.04 ubuntu

Secure Shopware with Let’s Encrypt

Before starting, you will need to install the Certbot client in your system to install and manage the Let’s Encrypt SSL. You can install it using the following command:

apt-get install certbot python3-certbot-nginx -y

Once the Certbot client is installed, run the following command to download and install Let’s Encrypt SSL for your website:

certbot --nginx -d shopware.linuxbuz.com

Provide your email address and accept the term of service as shown below:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for shopware.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/shopware.conf

Select, whether or not to redirect HTTP traffic to HTTPS:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Type 2 and hit enter to start the process. Once the installation is completed, you should see the following output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/shopware.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://shopware.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=shopware.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/shopware.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/shopware.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-09-22. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

At this point, your Shopware website is secured with Let’s Encrypt SSL. You can now access your website securely using the URL https://shopware.linuxbuz.com.

Conclusion

Congratulations! you have successfully installed Shopware with Nginx and Let’s Encrypt SSL on Ubuntu 20.04. You can now start setting up your own online business using Shopware. Feel free to ask me if you have any questions.