Shopware 6 installeren met Nginx en Let’s Encrypt SSL op Ubuntu 20.04
Shopware CE is een gratis en open-source eCommerce platform geschreven in Symfony en Vue.js. Het is gebaseerd op een vrij moderne technologie stack en een heel goed alternatief voor een andere eCommerce toepassing, zoals Magento. Het is een zeer krachtige en flexibele toepassing en geeft je de vrijheid om snel en gemakkelijk je groeipotentieel te benutten en je te concentreren op de perfecte klantervaring. Het biedt een eenvoudige en gebruiksvriendelijke admin interface voor het beheer van klanten en bestellingen. Je kunt er de prijzen van producten mee beheren, thema’s veranderen of bijwerken, e-mail sjablonen ontwerpen voor de marketing van je producten, en statistische resultaten genereren.
In deze handleiding laten we je zien hoe je Shopware CE met Nginx en Let’s Encrypt installeert op Ubuntu 20.04.
Vereisten
- Een server met Ubuntu 20.04 met minimaal 4 GB RAM.
- Een geldige domeinnaam die met je server is verbonden.
- Een root wachtwoord is op je server ingesteld.
Installeer Nginx en MariaDB
Installeer eerst de Nginx webserver en de MariaDB databaseserver met het volgende commando:
apt-get install nginx mariadb-server -y
Zodra beide pakketten geïnstalleerd zijn, start je de Nginx en MariaDB service, en zet je ze aan om te starten bij het opstarten van het systeem:
systemctl start nginx systemctl start mariadb systemctl enable nginx systemctl enable mariadb
Installeer PHP en andere componenten
Shopware 6 ondersteunt PHP versies tussen 7.2 en 7.3. Je zult dus PHP samen met andere bibliotheken in je systeem moeten installeren.
Voeg eerst de PHP repository aan je systeem toe met het volgende commando:
apt-get install software-properties-common -y add-apt-repository ppa:ondrej/php
Zodra de repository is toegevoegd, installeer je PHP samen met andere bibliotheken met het volgende commando:
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
Als alle pakketten geïnstalleerd zijn, bewerk je het php.ini bestand en pas je enkele gewenste instellingen aan:
nano /etc/php/7.2/fpm/php.ini
Verander de volgende regels:
memory_limit = 512M upload_max_filesize = 20M max_execution_time = 300
Sla het bestand op en sluit het als je klaar bent.
Vervolgens moet je IonCube loader in je systeem installeren.
Download hem eerst met het volgende commando:
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
Pak het gedownloade bestand, eenmaal gedownload, uit met het volgende commando:
tar xfz ioncube_loaders_lin_x86-64.tar.gz
Zoek vervolgens het pad van de PHP uitbreidingsdirectory:
php -i | grep extension_dir
Je zou de volgende uitvoer moeten zien:
extension_dir => /usr/lib/php/20190902 => /usr/lib/php/20190902
Kopieer vervolgens IonCube loader naar de PHP extensie directory:
cp ioncube/ioncube_loader_lin_7.2.so /usr/lib/php/20180731/
Bewerk vervolgens het php.ini bestand en definieer de IonCube loader:
nano /etc/php/7.2/fpm/php.ini
Voeg de volgende regel toe binnen de sectie [PHP]:
zend_extension = /usr/lib/php/20180731/ioncube_loader_lin_7.2.so
Bewaar en sluit het bestand en herstart dan de PHP-FPM dienst om de veranderingen toe te passen.
systemctl restart php7.2-fpm
Configureer de MariaDB Database
Beveilig eerst de MariaDB installatie en stel het root wachtwoord in met het volgende script:
mysql_secure_installation
Beantwoord alle vragen zoals hieronder aangegeven:
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
Als je klaar bent, log je in in de MariaDB shell met het volgende commando:
mysql -u root -p
Geef je MariaDB root wachtwoord en maak dan een database en gebruiker voor Shopware:
MariaDB [(none)]> CREATE DATABASE shopwaredb; MariaDB [(none)]> GRANT ALL ON shopwaredb.* TO 'shopware'@'localhost' IDENTIFIED BY 'password';
Spoel vervolgens de privileges door en verlaat de MariaDB met het volgende commando:
MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit;
Als je klaar bent, kun je verder gaan met de volgende stap.
Installeer Composer
Composer is een afhankelijkhedenbeheerder voor PHP. Het wordt gebruikt om alle PHP afhankelijkheden te installeren die nodig zijn om Shopware te installeren.
Je kunt het installeren met het curl commando zoals hieronder getoond:
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
Eenmaal geïnstalleerd, controleer je de Composer versie met het volgende commando:
composer --version
Je zou de volgende uitvoer moeten krijgen:
Composer version 1.10.7 2020-06-03 10:03:56
Shopware downloaden
Maak eerst een map voor Shopware binnen de Nginx web root map:
mkdir /var/www/html/shopware
Verander de directory vervolgens in shopware en download de nieuwste versie van Shopware met het volgende commando:
cd /var/www/html/shopware wget https://www.shopware.com/en/Download/redirect/version/sw6/file/install_6.2.2_1592398977.zip
Eenmaal gedownload pak je het gedownloade bestand uit met het volgende commando:
unzip install_6.2.2_1592398977.zip
Installeer vervolgens alle PHP afhankelijkheden met het volgende commando:
composer install
Verander vervolgens het eigendom van de map shopware en geef de juiste rechten met het volgende commando:
chown -R www-data:www-data /var/www/html/shopware chmod -R 755 /var/www/html/shopware
Als je klaar bent, kun je verder gaan met de volgende stap.
Configureer Nginx voor Shopware
Maak eerst een nieuw Nginx virtual host configuratiebestand voor Shopware:
nano /etc/nginx/sites-available/shopware.conf
Voeg de volgende regels toe:
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; } }
Sla het bestand op en sluit het af, schakel dan het Shopware virtuele host bestand in met het volgende commando:
ln -s /etc/nginx/sites-available/shopware.conf /etc/nginx/sites-enabled/
Controleer vervolgens de Nginx op een eventuele syntaxfout met het volgende commando:
nginx -t
Je zou de volgende uitvoer moeten krijgen:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Herstart vervolgens de Nginx dienst om de veranderingen toe te passen:
systemctl reload nginx
Ga naar de Shopware installatiewizard
Op dit punt is Shopware in je systeem geïnstalleerd. Open nu je web browser en typ de URL http://shopware.linuxbuz.com. Je zou de Shopware web installatie wizard moeten zien:
Kies je taal en klik op de Next knop. Je zou het volgende scherm moeten zien:
Controleer of alle vereiste dependencies geïnstalleerd zijn en klik dan op de Next knop. Je zou het volgende scherm moeten zien:
Accepteer de voorwaarden en condities, en klik op de Next knop. Je zou het volgende scherm moeten zien:
Geef je database gegevens op en klik op de Start Installation knop. Als de installatie met succes voltooid is, zou je het volgende scherm moeten zien:
Klik nu op de Next knop. Je zou nu het Shopware configuratiescherm moeten zien:
Geef je winkelnaam, e-mail, land, admin e-mail, admin gebruikersnaam, wachtwoord op en klik op de Volgende knop. Je wordt doorgestuurd naar het Shopware dashboard scherm:
Klik op de knop Volgende. Je zou het volgende scherm moeten zien:
Installeer de gewenste gegevens en klik op de knop Volgende. Je zou het volgende scherm moeten zien:
Kies je gewenste e-mail agent en klik op de Volgende knop. Je zou het volgende scherm moeten zien:
Kies je gewenste optie en klik op de knop Volgende. Je zou het volgende scherm moeten zien:
Configureer je PayPal of klik op de Skip knop. Je zou het volgende scherm moeten zien:
Configureer je PayPal inloggegevens of klik op de knop Overslaan. Je zou het volgende scherm moeten zien:
Kies je regio en klik op de knop Volgende. Je zou het volgende scherm moeten zien:
Klik op de knop Overslaan. Als de Shopware geconfigureerd is, zou je het volgende scherm moeten zien:
Klik op de knop Finish. Je zou het Shopware dashboard moeten zien in het volgende scherm:
Beveilig Shopware met Let’s Encrypt
Voor je begint, moet je de Certbot client op je systeem installeren om de Let’s Encrypt SSL te installeren en beheren. Je kunt het installeren met het volgende commando:
apt-get install certbot python3-certbot-nginx -y
Als de Certbot client geïnstalleerd is, voer je het volgende commando uit om Let’s Encrypt SSL voor je website te downloaden en te installeren:
certbot --nginx -d shopware.linuxbuz.com
Geef je email adres op en accepteer de servicevoorwaarden zoals hieronder getoond:
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
Kies, of je HTTP verkeer al dan niet wilt omleiden naar 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
Typ 2 en druk op enter om het proces te starten. Als de installatie voltooid is, zou je de volgende uitvoer moeten zien:
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
Op dit moment is je Shopware website beveiligd met Let’s Encrypt SSL. Je kunt nu je website veilig bezoeken met de URL https://shopware.linuxbuz.com.
Conclusie
Gefeliciteerd! Je hebt met succes Shopware met Nginx en Let’s Encrypt SSL geïnstalleerd op Ubuntu 20.04. Je kunt nu beginnen je eigen online zaak op te zetten met Shopware. Voel je vrij me te vragen als je vragen hebt.