Come installare Shopware con Nginx e Free Lets Encrypt SSL su Ubuntu 22.04
Questo tutorial esiste per queste versioni del sistema operativo
- Ubuntu 22.04 (Jammy Jellyfish)
- Ubuntu 18.04 (Bionic Beaver)
Su questa pagina
- Prerequisiti
- Installa Nginx e MariaDB
- Installa PHP e altri componenti
- Configura database MariaDB
- Scarica Shopware
- Configura Nginx per Shopware
- Accedi all'installazione guidata di Shopware
- Shopware sicuro con Lets Encrypt
- Conclusione
Shopware community edition è una piattaforma di carrello della spesa gratuita e open source utilizzata che ti consente di avviare il tuo negozio online sul web. È scritto in Symfony e Vue.js e si basa su un moderno stack tecnologico. È una soluzione alternativa ad altre applicazioni di eCommerce, come Magento. Offre un'interfaccia utente Web bella e intuitiva utilizzata per la gestione di clienti e ordini. Ti consente di gestire i prezzi dei prodotti, modificare o aggiornare temi, progettare modelli di email per commercializzare i tuoi prodotti e generare risultati statistici.
In questo tutorial, ti mostreremo come installare Shopware CE con Nginx e Lets Encrypt su Ubuntu 22.04.
Prerequisiti
- Un server che esegue Ubuntu 22.04 con un minimo di 4 GB di RAM.
- Un nome di dominio valido è indirizzato al tuo server.
- Una password di root è configurata sul tuo server.
Installa Nginx e MariaDB
Innanzitutto, installa il server Web Nginx e il server del database MariaDB utilizzando il seguente comando:
apt-get install nginx mariadb-server -y
Una volta installati entrambi i pacchetti, avviare il servizio Nginx e MariaDB e abilitarli all'avvio all'avvio del sistema:
systemctl start nginx
systemctl start mariadb
systemctl enable nginx
systemctl enable mariadb
Installa PHP e altri componenti
Shopware 6 supporta le versioni PHP tra 7.2 e 7.3. Quindi dovrai installare PHP insieme ad altre librerie nel tuo sistema.
Innanzitutto, aggiungi il repository PHP al tuo sistema con il seguente comando:
apt-get install software-properties-common -y
add-apt-repository ppa:ondrej/php
Una volta aggiunto il repository, installa PHP con altre librerie utilizzando il seguente comando:
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
Una volta installati tutti i pacchetti, modifica il file php.ini e modifica alcune impostazioni desiderate:
nano /etc/php/7.2/fpm/php.ini
Modifica le seguenti righe:
memory_limit = 512M upload_max_filesize = 20M max_execution_time = 300
Salva e chiudi il file quando hai finito.
Successivamente, dovrai installare il caricatore IonCube nel tuo sistema.
Innanzitutto, scaricalo con il seguente comando:
wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
Una volta scaricato, estrai il file scaricato con il seguente comando:
tar xfz ioncube_loaders_lin_x86-64.tar.gz
Quindi, individua il percorso della directory dell'estensione PHP:
php -i | grep extension_dir
Dovresti vedere il seguente output:
extension_dir => /usr/lib/php/20170718 => /usr/lib/php/20170718
Successivamente, copia il caricatore IonCube nella directory dell'estensione PHP:
cp ioncube/ioncube_loader_lin_7.2.so /usr/lib/php/20170718/
Successivamente, modifica il file php.ini e definisci il caricatore IonCube:
nano /etc/php/7.2/fpm/php.ini
Aggiungi la seguente riga all'interno della sezione [PHP]:
zend_extension = /usr/lib/php/20170718/ioncube_loader_lin_7.2.so
Salva e chiudi il file, quindi riavvia il servizio PHP-FPM per applicare le modifiche.
systemctl restart php7.2-fpm
Configura database MariaDB
Innanzitutto, proteggi l'installazione di MariaDB e imposta la password di root utilizzando il seguente script:
mysql_secure_installation
Rispondi a tutte le domande come mostrato di seguito:
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
Al termine, accedi alla shell MariaDB con il seguente comando:
mysql -u root -p
Fornisci la tua password root MariaDB, quindi crea un database e un utente per Shopware:
MariaDB [(none)]> CREATE DATABASE shopwaredb;
MariaDB [(none)]> GRANT ALL ON shopwaredb.* TO 'shopware'@'localhost' IDENTIFIED BY 'password';
Successivamente, svuota i privilegi ed esci da MariaDB usando il seguente comando:
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
Una volta terminato, puoi procedere al passaggio successivo.
Scarica Shopware
Innanzitutto, crea una directory per Shopware all'interno della directory root web di Nginx:
mkdir /var/www/html/shopware
Successivamente, modifica la directory in shopware e scarica l'ultima versione di Shopware utilizzando il seguente comando:
cd /var/www/html/shopware
wget http://releases.s3.shopware.com.s3.amazonaws.com/install_5.4.5_6847c0845f0f97230aa05c7294fa726a96dda3ff.zip?_ga=2.133696968.774684214.1529926951-1771999509.1528830594 -O shopware.zip
Una volta scaricato, decomprimere il file scaricato con il seguente comando:
unzip shopware.zip
Successivamente, modifica la proprietà della directory shopware e concedi le autorizzazioni appropriate utilizzando il seguente comando:
chown -R www-data:www-data /var/www/html/shopware
chmod -R 755 /var/www/html/shopware
Al termine, puoi procedere al passaggio successivo.
Configura Nginx per Shopware
Innanzitutto, crea un nuovo file di configurazione dell'host virtuale Nginx per Shopware:
nano /etc/nginx/sites-available/shopware.conf
Aggiungi le seguenti righe:
server { listen 80; server_name shopware.example.com; # Check this root /var/www/html/shopware; # Check this index shopware.php index.php; location / { try_files $uri $uri/ /shopware.php$is_args$args; } location /recovery/install { index index.php; try_files $uri /recovery/install/index.php$is_args$args; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # Check this } }
Salva e chiudi il file, quindi abilita il file dell'host virtuale di Shopware con il seguente comando:
ln -s /etc/nginx/sites-available/shopware.conf /etc/nginx/sites-enabled/
Successivamente, controlla Nginx per eventuali errori di sintassi utilizzando il seguente comando:
nginx -t
Dovresti ottenere il seguente output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Successivamente, riavvia il servizio Nginx per applicare le modifiche:
systemctl reload nginx
Per verificare lo stato di Nginx, eseguire il seguente comando:
systemctl status nginx
Dovresti ottenere il seguente output:
? nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-09-12 05:03:41 UTC; 5min ago Docs: man:nginx(8) Process: 29668 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s reload (code=exited, status=0/SUCCESS) Main PID: 17628 (nginx) Tasks: 3 (limit: 4579) Memory: 5.7M CPU: 63ms CGroup: /system.slice/nginx.service ??17628 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;" ??29669 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ??29670 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" Sep 12 05:03:41 ubuntu2204 systemd[1]: Starting A high performance web server and a reverse proxy server... Sep 12 05:03:41 ubuntu2204 systemd[1]: Started A high performance web server and a reverse proxy server. Sep 12 05:09:28 ubuntu2204 systemd[1]: Reloading A high performance web server and a reverse proxy server... Sep 12 05:09:28 ubuntu2204 systemd[1]: Reloaded A high performance web server and a reverse proxy server.
Accedi all'installazione guidata di Shopware
A questo punto, Shopware è installato nel tuo sistema. Ora apri il tuo browser web e digita l'URL http://shopware.example.com. Dovresti vedere la procedura guidata di installazione web di Shopware:
Seleziona la lingua e fai clic sul pulsante Avanti. Dovresti vedere la seguente schermata:
Assicurati che tutte le dipendenze richieste siano installate, quindi fai clic sul pulsante Avanti. Dovresti vedere la seguente schermata:
Accetta i termini e le condizioni e fai clic sul pulsante Avanti. Dovresti vedere la seguente schermata:
Fornisci i dettagli del tuo database e fai clic sul pulsante Avvia installazione. Una volta che l'installazione è stata completata con successo, dovresti vedere la seguente schermata:
Ora, fai clic sul pulsante Avvia installazione . Dovresti vedere la seguente schermata:
Fare clic sul pulsante Avanti. Dovresti vedere la seguente pagina:
Seleziona l'opzione desiderata e fai clic sul pulsante Avanti. Dovresti vedere la seguente schermata:
Fornisci il nome del negozio, l'e-mail, il paese, l'e-mail dell'amministratore, il nome utente dell'amministratore, la password e fai clic sul pulsante Avanti. Verrai reindirizzato alla schermata del dashboard di Shopware:
Fai clic sul pulsante Vai al back-end del negozio. Dovresti vedere la seguente schermata:
Fornisci il nome utente e la password di accesso e fai clic sul pulsante Accedi. Dovresti vedere la seguente pagina:
Ora completa la configurazione del tuo negozio e inizia a vendere online utilizzando la piattaforma Shopware.
Shopware sicuro con Lets Encrypt
Prima di iniziare, dovrai installare il client Certbot nel tuo sistema per installare e gestire Lets Encrypt SSL. Puoi installarlo usando il seguente comando:
apt-get install certbot python3-certbot-nginx -y
Una volta installato il client Certbot, esegui il seguente comando per scaricare e installare Lets Encrypt SSL per il tuo sito web:
certbot --nginx -d shopware.example.com
Fornisci il tuo indirizzo email e accetta i termini di servizio come mostrato di seguito:
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): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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.example.com Waiting for verification... Cleaning up challenges Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/shopware.conf
Seleziona se reindirizzare o meno il traffico HTTP su 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
Digita 2 e premi invio per avviare il processo. Una volta completata l'installazione, dovresti vedere il seguente output:
Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/shopware.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://shopware.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=shopware.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/shopware.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/shopware.example.com/privkey.pem Your cert will expire on 2022-09-12. 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
A questo punto, il tuo sito Web Shopware è protetto con Lets Encrypt SSL. Ora puoi accedere al tuo sito Web in modo sicuro utilizzando l'URL https://shopware.example.com.
Conclusione
Congratulazioni! hai installato con successo Shopware con Nginx e Lets Encrypt SSL su Ubuntu 22.04. Ora puoi iniziare a creare la tua attività online utilizzando Shopware. Non esitate a chiedermi se avete domande.