Base de Conhecimento

Shopware Print

  • 0

How to Install Shopware 6 on Ubuntu 24.04 Using Nginx, PHP 8.3 and MySQL

This guide explains how to manually install and configure Shopware 6 on an Ubuntu 24.04 server. The steps below follow the same configuration used in the supplied Shopware Ansible playbook.

What will be installed:
  • PHP 8.3
  • PHP 8.3-FPM
  • Nginx
  • MySQL Server
  • Composer
  • Git
  • Shopware 6
  • Shopware MySQL database
  • Shopware MySQL database user
  • Nginx configuration for Shopware
Requirements:
  • Ubuntu 24.04 LTS
  • Root or sudo access
  • Internet connection
  • SSH access to the server

Step 1: Connect to the Ubuntu Server

Open PowerShell, Windows Terminal, or another SSH client and connect to your Ubuntu server.

ssh username@SERVER-IP

Replace username with your Ubuntu username and SERVER-IP with your server's IP address.

Example:

ssh ubuntu@203.0.113.10

Step 2: Check the Ubuntu Version

Confirm that your server is running Ubuntu 24.04:

lsb_release -a

The server should report Ubuntu 24.04 LTS.


Step 3: Update Ubuntu

Update the package list:

sudo apt update

Upgrade installed packages:

sudo apt upgrade -y

Step 4: Install the Required Packages

Install the packages used by the Shopware Ansible playbook:

sudo apt install -y software-properties-common nginx mysql-server composer git unzip curl python3-pymysql

This installs Nginx, MySQL, Composer, Git, PHP repository management tools, and the other required utilities.


Step 5: Add the PHP Repository

The playbook uses the Ondřej Surý PHP repository to obtain PHP 8.3. Add the repository:

sudo add-apt-repository ppa:ondrej/php

If Ubuntu asks you to confirm, press Enter.

Update the package list:

sudo apt update

Step 6: Install PHP 8.3

Install PHP 8.3 and the extensions specified by the playbook:

sudo apt install -y php8.3 php8.3-cli php8.3-fpm php8.3-mysql php8.3-xml php8.3-curl php8.3-mbstring php8.3-zip php8.3-intl php8.3-gd

Check the installed PHP version:

php -v

You should see PHP 8.3 in the output.


Step 7: Check PHP-FPM

Shopware uses PHP-FPM through Nginx. Check the PHP 8.3-FPM service:

sudo systemctl status php8.3-fpm --no-pager

If it is not running, start it:

sudo systemctl start php8.3-fpm

Enable it at boot:

sudo systemctl enable php8.3-fpm

Step 8: Start Nginx

Start Nginx:

sudo systemctl start nginx

Enable Nginx at boot:

sudo systemctl enable nginx

Check its status:

sudo systemctl status nginx --no-pager

Step 9: Start MySQL

Start MySQL:

sudo systemctl start mysql

Enable MySQL at boot:

sudo systemctl enable mysql

Check MySQL:

sudo systemctl status mysql --no-pager

Step 10: Create the Shopware Directory

The supplied Ansible playbook installs Shopware in:

/var/www/upcloud_store

Create the directory:

sudo mkdir -p /var/www/upcloud_store

Set the owner to the Nginx web-server user:

sudo chown www-data:www-data /var/www/upcloud_store

Set the permissions:

sudo chmod 755 /var/www/upcloud_store

Step 11: Install Shopware Using Composer

Change into the Shopware directory:

cd /var/www/upcloud_store

Run the Composer command used by the Ansible playbook:

sudo COMPOSER_ALLOW_SUPERUSER=1 composer create-project shopware/production:^6.5 .

Composer will download Shopware and its dependencies. This can take several minutes.

Important: Do not close the SSH session while Composer is installing Shopware. Wait until the command has completely finished.

Step 12: Set Shopware Ownership

After Composer finishes, make sure the Shopware files belong to www-data:

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

Step 13: Create the Shopware Database

The Ansible playbook creates the following database:

  • Database: upcloud_store_db
  • User: upcloud_store
  • Password: upcloud_store_password

Open MySQL:

sudo mysql

Inside MySQL, create the database:

CREATE DATABASE upcloud_store_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Create the Shopware database user:

CREATE USER 'upcloud_store'@'localhost' IDENTIFIED BY 'upcloud_store_password';

Give the user access to the database:

GRANT ALL PRIVILEGES ON upcloud_store_db.* TO 'upcloud_store'@'localhost';

Apply the privileges:

FLUSH PRIVILEGES;

Exit MySQL:

EXIT;

Step 14: Verify the Shopware Database

Log into MySQL using the Shopware database user:

mysql -u upcloud_store -p

Enter:

upcloud_store_password

If the login succeeds, the database user has been created correctly. Exit MySQL:

EXIT;

Step 15: Create the Nginx Configuration

Create the Shopware Nginx configuration file:

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

Paste the following configuration:

server {
    listen 80;
    listen [::]:80;

    server_name _;

    root /var/www/upcloud_store/public;
    index index.php index.html;

    access_log /var/log/nginx/shopware_access.log;
    error_log /var/log/nginx/shopware_error.log;

    client_max_body_size 100M;

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

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;

        internal;
    }

    location ~ \.php$ {
        return 404;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

Save the file:

  • Press Ctrl + O
  • Press Enter
  • Press Ctrl + X

Step 16: Enable the Shopware Nginx Site

Create the symbolic link:

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

Step 17: Remove the Default Nginx Site

Remove the default Nginx site:

sudo rm -f /etc/nginx/sites-enabled/default

Step 18: Test the Nginx Configuration

Always test Nginx before restarting it:

sudo nginx -t

A successful configuration should show something similar to:

syntax is ok
test is successful
Important: If nginx -t reports an error, do not restart Nginx. Read the error message and correct the configuration first.

Step 19: Restart Nginx

Restart Nginx:

sudo systemctl restart nginx

Check Nginx:

sudo systemctl status nginx --no-pager

Step 20: Verify PHP-FPM

Check PHP-FPM:

sudo systemctl status php8.3-fpm --no-pager

The service should show:

Active: active (running)

Check that the PHP-FPM socket exists:

ls -l /run/php/php8.3-fpm.sock

Step 21: Verify the Shopware Files

Check the Shopware installation directory:

ls -lah /var/www/upcloud_store

Check the public directory:

ls -lah /var/www/upcloud_store/public

The Nginx configuration uses:

/var/www/upcloud_store/public

Step 22: Check the Server IP Address

Find the IP address of the Ubuntu server:

hostname -I

Copy the server's IP address.


Step 23: Open Shopware in Your Browser

Open a web browser on your computer and enter:

http://YOUR_SERVER_IP

For example:

http://203.0.113.10

Replace the example IP address with your actual server IP.


Step 24: Complete the Shopware Installation Wizard

The Shopware installation wizard should now appear in your browser. Follow the instructions shown on screen.

When Shopware asks for the database information, use:

SettingValue
Database Hostlocalhost
Database Nameupcloud_store_db
Database Usernameupcloud_store
Database Passwordupcloud_store_password

Complete the remaining Shopware installation wizard steps and create the administrator account when requested.


Step 25: Check Nginx Logs

If Shopware does not open, check the Shopware Nginx error log:

sudo tail -f /var/log/nginx/shopware_error.log

Press Ctrl + C to stop viewing the log.

Check the access log:

sudo tail -f /var/log/nginx/shopware_access.log

Step 26: Troubleshooting Nginx

If Nginx is not working, first test its configuration:

sudo nginx -t

Check its status:

sudo systemctl status nginx --no-pager -l

Check its logs:

sudo journalctl -u nginx -n 100 --no-pager

Step 27: Troubleshooting PHP-FPM

Check PHP-FPM:

sudo systemctl status php8.3-fpm --no-pager -l

Check the PHP-FPM logs:

sudo journalctl -u php8.3-fpm -n 100 --no-pager

Restart PHP-FPM if necessary:

sudo systemctl restart php8.3-fpm

Step 28: Troubleshooting MySQL

Check MySQL:

sudo systemctl status mysql --no-pager -l

Test the Shopware database:

mysql -u upcloud_store -p -e "SHOW DATABASES;"

Enter the database password when prompted.


Step 29: Troubleshooting Shopware

If Shopware returns an error, first check that the files are owned by www-data:

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

Check the Shopware directory:

ls -lah /var/www/upcloud_store

Check the public directory:

ls -lah /var/www/upcloud_store/public

Step 30: Useful Service Commands

Nginx

Start:

sudo systemctl start nginx

Stop:

sudo systemctl stop nginx

Restart:

sudo systemctl restart nginx

PHP-FPM

Restart:

sudo systemctl restart php8.3-fpm

MySQL

Restart:

sudo systemctl restart mysql

Step 31: Final Verification

Run the following commands to verify the main components:

php -v

sudo systemctl status nginx --no-pager

sudo systemctl status mysql --no-pager

sudo systemctl status php8.3-fpm --no-pager

sudo nginx -t

ls -lah /var/www/upcloud_store

ls -lah /var/www/upcloud_store/public

If the services are running and nginx -t reports a successful configuration test, open:

http://YOUR_SERVER_IP

Installation Complete

Congratulations!

Shopware has been installed on Ubuntu 24.04 with:

  • PHP 8.3
  • PHP-FPM 8.3
  • Nginx
  • MySQL
  • Composer
  • Shopware 6
  • Shopware database
  • Shopware database user
  • Nginx reverse/front-end configuration

Shopware URL:
http://YOUR_SERVER_IP


Configuration Summary

ComponentConfiguration
Operating SystemUbuntu 24.04 LTS
PHP8.3
Web ServerNginx
DatabaseMySQL
Shopware Directory/var/www/upcloud_store
Shopware Public Directory/var/www/upcloud_store/public
Database Nameupcloud_store_db
Database Userupcloud_store
PHP-FPM Socket/run/php/php8.3-fpm.sock
HTTP Port80

Quick Access

Shopware:
http://YOUR_SERVER_IP

Shopware installation directory:
/var/www/upcloud_store

Shopware public directory:
/var/www/upcloud_store/public

Nginx configuration:
/etc/nginx/sites-available/shopware.conf

Security recommendation:

The database credentials shown in this guide are the credentials defined in the provided Ansible project. For a production deployment, replace the example database password with a strong, unique password and configure HTTPS/TLS before using the Shopware installation publicly.

This knowledgebase article follows the supplied Shopware Ansible configuration, including PHP 8.3, Nginx, MySQL, Composer, the /var/www/upcloud_store installation path, the Shopware database configuration, and the supplied Nginx configuration.


Esta resposta foi útil?
Back