Come installare PrestaShop con Let's Encrypt SSL su Ubuntu 22.04
PrestaShop è una piattaforma di e-commerce open source che ti consente di gestire il tuo negozio online o un negozio su Internet. È molto noto e gestisce oltre 300.000 negozi online in tutto il mondo. È programmato in PHP e utilizza MySQL/MariaDB come database backend. Con Prestashop puoi proporre le tue idee e i tuoi prodotti e venderli su Internet. Offre numerosi temi, moduli ed estensioni con cui puoi estendere le funzionalità del tuo negozio.
In questo articolo ti mostreremo come installare PrestaShop su Ubuntu 22.04.
Requisiti
- Un server che esegue Ubuntu 22.04.
- Sul server è impostata una password di root.
Installa Apache, MariaDB e PHP
Per prima cosa installa il server Apache e MariaDB utilizzando il comando seguente:
apt install apache2 mariadb-server -y
Per impostazione predefinita, Ubuntu 22.04 viene fornito con la versione PHP 8.1, ma PrestaShop non supporta la versione PHP 8.1. Pertanto, è necessario installare la versione PHP 7.4 con altre estensioni sul tuo server.
Innanzitutto, installa tutte le dipendenze richieste utilizzando il seguente comando:
apt install software-properties-common ca-certificates lsb-release apt-transport-https
Successivamente, aggiungi il repository PHP utilizzando il seguente comando:
add-apt-repository ppa:ondrej/php
Una volta aggiunto il repository PHP, esegui il comando seguente per installare PHP 7.4 con tutte le estensioni richieste:
apt install php7.4 libapache2-mod-php7.4 php7.4-zip php7.4-xml php7.4-gd php7.4-curl php7.4-intl php7.4-xmlrpc php7.4-mbstring php7.4-imagick php7.4-mysql unzip -y
Una volta installati PHP e le altre dipendenze richieste, modifica il file di configurazione predefinito di PHP:
nano /etc/php/7.4/apache2/php.ini
Modificare le seguenti righe:
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
date.timezone = UTC
Salva e chiudi il file e riavvia il servizio Apache per applicare le modifiche:
systemctl restart apache2
Crea un database per PrestaShop
Successivamente, devi creare un database e un utente per PrestaShop. Innanzitutto, accedi alla shell MariaDB con il seguente comando:
mysql
Una volta effettuato l'accesso, crea un database e un utente con il seguente comando:
MariaDB [(none)]> CREATE DATABASE prestashop;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop.* TO 'prestashop'@'localhost' IDENTIFIED BY 'password';
Successivamente, cancella i permessi ed esci dalla shell MariaDB con il seguente comando:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Installa PrestaShop
Innanzitutto, vai alla pagina PrestaShop Git Hub e scarica l'ultima versione di PrestaShop utilizzando il seguente comando:
wget https://github.com/PrestaShop/PrestaShop/releases/download/1.7.8.7/prestashop_1.7.8.7.zip
Una volta completato il download, decomprimi il file scaricato nella directory PrestaShop:
unzip prestashop_1.7.8.7.zip -d /var/www/html/prestashop
Successivamente, modifica la proprietà e l'autorizzazione per la directory PrestaShop:
chown -R www-data:www-data /var/www/html/prestashop/
chmod -R 755 /var/www/html/prestashop
Crea un host virtuale Apache per PrestaShop.
Successivamente, devi creare un file di configurazione per un host virtuale Apache per PrestaShop. Puoi crearlo con il seguente comando:
nano /etc/apache2/sites-available/prestashop.conf
Aggiungi le seguenti configurazioni:
<VirtualHost *:80>
ServerAdmin [email
DocumentRoot /var/www/html/prestashop
ServerName prestashop.example.com
<Directory /var/www/html/prestashop>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/prestashop_error.log
CustomLog ${APACHE_LOG_DIR}/prestashop_access.log combined
</VirtualHost>
Salva e chiudi il file quando hai finito. Successivamente attiva PrestaShop e abilita il modulo header Apache con il seguente comando:
a2ensite prestashop
a2enmod rewrite headers
Quindi riavvia il servizio Apache per applicare le modifiche:
systemctl restart apache2
Successivamente, controlla lo stato del servizio Apache con il seguente comando:
systemctl status apache2
Otterrai il seguente output:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2022-08-15 04:14:12 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 35363 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 35367 (apache2)
Tasks: 6 (limit: 2242)
Memory: 21.5M
CPU: 108ms
CGroup: /system.slice/apache2.service
??35367 /usr/sbin/apache2 -k start
??35368 /usr/sbin/apache2 -k start
??35369 /usr/sbin/apache2 -k start
??35370 /usr/sbin/apache2 -k start
??35371 /usr/sbin/apache2 -k start
??35372 /usr/sbin/apache2 -k start
Aug 15 04:14:12 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...
Esegui l'installazione Web di PrestaShop
Ora PrestaShop è installato e configurato con Apache. Ora apri il tuo browser web e accedi all'installazione web di PrestaShop utilizzando l'URL http://prestashop.example.com . Dovresti vedere la schermata di selezione della lingua:
Seleziona la tua lingua e fai clic sul pulsante Avanti. Dovresti vedere la schermata del contratto di licenza:
Accetta il contratto di licenza e fai clic sul pulsante " Avanti". Dovresti vedere la schermata Informazioni sul sito:
Inserisci le informazioni sul tuo sito, nome utente e password e fai clic sul pulsante Avanti. Dovresti vedere la schermata di configurazione del database:
Inserisci le informazioni del tuo database e fai clic sul pulsante Avanti. Una volta completata l’installazione, dovresti vedere la seguente schermata:
Ora rimuovi la cartella di installazione utilizzando il seguente comando:
rm -rf /var/www/html/prestashop/install/
Successivamente, fai clic sul pulsante Gestisci il tuo negozio. Dovresti vedere la schermata di accesso per il backend PrestaShop:
Inserisci il tuo indirizzo email e la password e fai clic sul pulsante ACCEDI. Dovresti vedere la dashboard di PrestaShop:
Proteggi PrestaShop con Let's Encrypt.
Successivamente, è necessario installare il pacchetto client Certbot per installare e gestire Let's Encrypt SSL.
Innanzitutto, installa Certbot utilizzando il seguente comando:
apt-get install certbot python3-certbot-nginx -y
Una volta completata l'installazione, esegui il comando seguente per installare Let's Encrypt SSL sul tuo sito web:
certbot --nginx -d prestashop.example.com
Ti verrà richiesto di fornire un indirizzo email valido e di accettare i termini di servizio (vedi sotto):
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
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 prestashop.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/prestashop.conf
Successivamente, seleziona se reindirizzare o meno il traffico HTTP su HTTPS (vedi sotto):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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
Digitare 2 e premere Invio per completare l'installazione. Dovresti vedere il seguente output:
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/prestashop.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://prestashop.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=prestashop.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/prestashop.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/prestashop.example.com/privkey.pem
Your cert will expire on 2022-11-16. 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"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- 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
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.
Conclusione
Congratulazioni! Hai installato con successo PrestaShop con Apache e Let's Encrypt SSL. Ora puoi ospitare il tuo negozio online su Internet e iniziare a vendere i tuoi prodotti. Se avete domande, non esitate a contattarmi.