How to Install Shopware on Ubuntu

Shopware Community Edition is a free, open-source, highly flexible, powerful, and customizable software solution that allows you to quickly and easily create an online shop. It is built on PHP with Symfony and Zend components and uses MariaDB to store its data. The Shopware Community Edition is ideal for those who want to use the most advanced and flexible solution on the market without any major investment.

This tutorial will explain how to install Shopware Community Edition on Ubuntu 18.04 server.

Requirements

  • A server running Ubuntu 22.04.
  • A static IP address like 192.168.0.100 is set up to your server.
  • A non-root user with sudo privileges.

Getting Started

Before starting, you must update your system with the latest version. You can do this by running the following command:

sudo apt-get update -y
sudo apt-get upgrade -y

Once your system is updated, restart the system to apply the changes.

Install LAMP Server

First, install Apache web server, MariaDB server, PHP and other PHP modules by running the following command:

sudo apt-get install apache2 mariadb-server php8.1 libapache2-mod-php8.1 php8.1-common php8.1-sqlite3 php8.1-curl php8.1-intl php8.1-mbstring php8.1-xmlrpc php8.1-mysql php8.1-gd php8.1-xml php8.1-cli php8.1-zip wget unzip ant -y

Once all the packages are installed, you will need to make some changes in php.ini file:

sudo nano /etc/php/8.1/apache2/php.ini

Make the following changes:

memory_limit = 512M
upload_max_filesize = 200M
max_execution_time = 360
post_max_size = 200M
date.timezone = UTC

Save and close the file.

Configure MariaDB

Next, you will need to create a database and user for Shopware. First, log in to MariaDB shell with the following command:

mysql -u root -p

Enter your root password. Then, create a database and user for Shopware:

MariaDB [(none)]> CREATE DATABASE shopwaredb;
 MariaDB [(none)]> CREATE USER 'shopware'@'localhost' IDENTIFIED BY 'password';

Next, grant all privileges to the Shopware with the following command:

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

Next, flush the privileges and exit from the MariaDB shell:

MariaDB [(none)]> FLUSH PRIVILEGES;
 MariaDB [(none)]> EXIT;

Install Shopware

First, download the latest version of Shopware from the Git repository with the following command:

wget https://github.com/shopware/shopware/archive/v5.4.6.zip

Next, unzip the downloaded file with the following command:

unzip v5.4.6.zip

Next, copy the extracted directory to the Apache root directory:

sudo cp -r shopware-5.4.6 /var/www/html/shopware

Next, change the directory to build and set up the configuration and database connection with the following command:

cd build/
sudo ant configure

During the configuration process, you will need to provide database details as shown below:

Buildfile: /var/www/html/shopware/build/build.xml
configure:
    [input] Please enter db-host: [localhost]
    [input] Please enter db-port: [3306]

    [input] Please enter db-name: []
shopwaredb
    [input] Please enter db-username: []
shopware
    [input] Please enter db-password:
password
    [input] Please enter app.host (Hostname e.g. example.com): []
example.com
    [input] Please enter app.path (e.g. /shopware. Leave blank if installed in document root): []


write-properties:
[propertyfile] Creating new property file: /var/www/html/shopware/build/build.properties

BUILD SUCCESSFUL
Total time: 2 minutes 0 seconds

Next, build the Shopware with the following command:

sudo ant build-unit

Once the build is completed successfully, you should see the following output:

build-theme-initialize:
     [exec] Themes initialized

build-create-admin-account:
     [exec] 
     [exec]  [OK] Adminuser "demo" was successfully created.                                                                        
     [exec] 

build-install-lock-file:

build-disable-firstrunwizard:
     [exec] First Run Wizard disabled

install-git-hooks:
    [mkdir] Created dir: /var/www/html/shopware/.git/hooks

build-unit:

BUILD SUCCESSFUL
Total time: 12 minutes 52 seconds

Next, give proper permissions to the shopware directory with the following command:

sudo chown -R www-data:www-data /var/www/html/shopware
sudo chmod -R 777 /var/www/html/shopware

Configure Apache

Next, create an Apache virtual host file for Shopware:

sudo nano /etc/apache2/sites-available/shopware.conf

Add the following lines:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /var/www/html/shopware
     ServerName example.com
     ServerAlias www.example.com

    <Directory /var/www/html/shopware/>
        Options FollowSymlinks
        AllowOverride All
        Require all granted
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save and close the file. Then, enable Apache virtual host and rewrite the module with the following command:

sudo a2ensite shopware
sudo a2enmod rewrite

Finally, restart Apache service to apply all the changes:

sudo systemctl restart apache2

Access Shopware

Shopware is now installed and configured. It’s time to access Shopware web interface. Open your web browser and type the URL http://example.com. You will be redirected to the Shopware login page:

Provide default username/password demo/demo and click on the Login button. You should see the Shopware default dashboard in the following page: