GNU/Linux >> Linux Esercitazione >  >> Debian

Come installare OpenCart con Nginx e Lets Encrypt su Debian 10

Opencart è una popolare soluzione di carrello degli acquisti open source che ti aiuta a ospitare il tuo sito Web di e-commerce completamente funzionale. Opencart fornisce un'interfaccia semplice e intuitiva per vendere i tuoi prodotti online, come Amazon e Flipcart. È progettato specificamente per le piccole e medie imprese e ha tutte le funzionalità di e-commerce standard necessarie per i negozi online. Offre un ricco set di funzionalità tra cui multivaluta, lingua, categorie illimitate, prodotti, recensioni di prodotti, multi-store e molto altro.

In questo tutorial, ti mostreremo come installare OpenCart con Nginx su Debian 10 e proteggerlo con Let's Encrypt SSL.

Prerequisiti

  • Un server che esegue Debian 10.
  • Sul tuo server è configurata una password di root.

Per iniziare

Innanzitutto, aggiorna il tuo sistema all'ultima versione con il seguente comando:

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

Una volta aggiornato il server, riavvialo per applicare le modifiche.

Installa il server LEMP

Innanzitutto, installa il server Web Nginx, il server del database MariaDB, PHP e altre estensioni PHP richieste eseguendo il comando seguente:

apt-get install nginx mariadb-server php-common php-cli php-fpm php-opcache php-gd php-mysql php-curl php-intl php-xsl php-mbstring php-zip php-bcmath php-soap unzip git -y

Una volta installati tutti i pacchetti, modifica il file php.ini e apporta alcune modifiche:

nano /etc/php/7.3/fpm/php.ini

Modifica le seguenti righe:

memory_limit = 256M
upload_max_filesize = 100M
opcache.save_comments=1
max_execution_time = 300
date.timezone = Asia/Kolkata

Salva e chiudi il file quando hai finito.

Configura il database MariaDB

Successivamente, dovrai impostare una password di root MariaDB poiché non è impostata in Debian 10.

Per farlo, accedi alla shell di MariaDB con il seguente comando:

mysql

Una volta effettuato l'accesso, imposta una password di root MariaDB con il seguente comando:

MariaDB [(none)]> SET PASSWORD FOR 'root'@'localhost' = PASSWORD("yournewrootpassword");

Quindi, imposta il plug-in di autenticazione MariaDB su mysql_native_password con il seguente comando:

MariaDB [(none)]> SET GLOBAL innodb_fast_shutdown = 0;
MariaDB [(none)]> UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';

Quindi, svuota i privilegi ed esci dalla shell MariaDB con il seguente comando:

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

Quindi, accedi a MariaDB con l'utente root:

mysql -u root -p

Fornisci la tua password di root e crea un database e un utente per OpenCart con il seguente comando:

MariaDB [(none)]> CREATE DATABASE opencartdb;
MariaDB [(none)]> GRANT ALL ON opencartdb.* TO 'opencart'@'localhost' IDENTIFIED BY 'password';

Quindi, svuota i privilegi ed esci dalla shell MariaDB con il seguente comando:

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

Una volta configurato MariaDB, puoi procedere al passaggio successivo.

Scarica OpenCart

Puoi scaricare l'ultima versione di OpenCart dal repository Git usando il seguente comando:

wget https://github.com/opencart/opencart/releases/download/3.0.3.2/opencart-3.0.3.2.zip

Dopo aver scaricato OpenCart, decomprimi il file scaricato con il seguente comando:

unzip opencart-3.0.3.2.zip

Quindi, sposta la directory di caricamento nella directory principale web di Nginx con il seguente comando:

mv upload /var/www/html/opencart

Quindi, cambia la directory in opencart e rinomina il file config-dist.php:

cd /var/www/html/opencart/
mv config-dist.php config.php
mv admin/config-dist.php admin/config.php

Quindi, dai le autorizzazioni appropriate alla directory opencart con il seguente comando:

chown -R www-data:www-data /var/www/html/opencart/
chmod -R 775 /var/www/html/opencart/

Una volta terminato, puoi procedere al passaggio successivo.

Configura Nginx per OpenCart

Successivamente, dovrai creare un file di configurazione dell'host virtuale Nginx per servire OpenCart. Puoi crearlo con il seguente comando:

nano /etc/nginx/sites-available/opencart.conf

Aggiungi il seguente contenuto:

server {
    listen 80;
    server_name opencart.linuxbuz.com;
    root /var/www/html/opencart;
    index index.php;
    access_log /var/log/nginx/opencart_access.log;
    error_log /var/log/nginx/opencart_error.log;

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.3-fpm.sock;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        expires max;
        log_not_found off;
    }

}

Salva e chiudi il file, quindi controlla Nginx per eventuali errori di sintassi con 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

Quindi, abilita il file host virtuale Nginx con il seguente comando:

ln -s /etc/nginx/sites-available/opencart.conf /etc/nginx/sites-enabled/

Quindi, riavvia il servizio Nginx e PHP-FPM per applicare le modifiche:

systemctl restart nginx
systemctl restart php7.3-fpm

Una volta terminato, puoi procedere al passaggio successivo.

Sicurezza OpenCart con Let's Encrypt SSL

Successivamente, dovrai installare un client Certbot per installare e configurare Let's Encrypt per il tuo sito web.

Per impostazione predefinita, Certbot non è disponibile nel repository predefinito di Debian 10. Quindi dovrai aggiungere un repository Certbot nel tuo sistema.

Puoi aggiungerlo con il seguente comando:

echo "deb http://ftp.debian.org/debian buster-backports main" >> /etc/apt/sources.list

Quindi, aggiorna il repository e installa il client Certbot per Nginx con il seguente comando:

apt-get update -y
apt-get install python3-certbot-nginx -t buster-backports

Una volta installato, esegui il seguente comando per scaricare Let's Encrypt SSL e configurare Nginx per utilizzare questo SSL:

certbot --nginx -d opencart.linuxbuz.com

Ti verrà richiesto di accettare i termini del servizio e di fornire il tuo indirizzo email valido come mostrato di seguito:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
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 opencart.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/nginx/sites-available/opencart-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/nginx/sites-available/opencart-le-ssl.conf
Enabling available site: /etc/nginx/sites-available/opencart-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.

Successivamente, dovrai scegliere se reindirizzare o meno il traffico HTTP su HTTPS come mostrato di seguito:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 continuare. Una volta completata l'installazione, dovresti ottenere il seguente output:

Redirecting vhost in /etc/nginx/sites-enabled/opencart.conf to ssl vhost in /etc/nginx/sites-available/opencart-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://opencart.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=opencart.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/opencart.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/opencart.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-04-30. 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

A questo punto, OpenCart è protetto con Let's Encrypt SSL.

Accedi all'interfaccia Web OpenCart

Ora apri il tuo browser web e digita l'URL https://opencart.linuxbuz.com. Verrai reindirizzato alla pagina del contratto di licenza OpenCart:

Fai clic su Continua per accettare il contratto di licenza. Dovresti vedere la seguente pagina:

Assicurati che tutte le estensioni PHP richieste siano installate, quindi fai clic su CONTINUA pulsante. Dovresti vedere la seguente pagina:

Fornisci le credenziali del database, il nome utente amministratore, la password e fai clic su CONTINUA pulsante. Una volta completata l'installazione, dovresti vedere la seguente pagina:

Ora apri il tuo terminale e rimuovi la directory di installazione con il seguente comando:

rm -rf /var/www/html/opencart/install/

Quindi, fai clic su VAI AL TUO NEGOZIO ONLINE . Dovresti vedere il tuo negozio OpenCart nella pagina seguente:

Quindi, fai clic su ACCEDI ALLA TUA AMMINISTRAZIONE pulsante. Dovresti vedere la pagina di accesso di OpenCart:

Fornisci il nome utente e la password dell'amministratore e fai clic su Accedi pulsante. Dovresti vedere il tuo pannello di amministrazione OpenCart nella pagina seguente:

Conclusione

Congratulazioni! hai installato e protetto con successo OpenCart su Debian 10. Ora puoi ospitare il tuo carrello degli acquisti online con OpenCart. Sentiti libero di chiedermi se hai domande.


Debian
  1. Installa Lets Encrypt e Secure Nginx con SSL/TLS in Debian 9

  2. Come installare Automatad CMS con Apache e Lets crittografare su Debian 10

  3. Come installare ElkArte Forum con Apache e Lets Encrypt su Debian 10

  4. Come installare Askbot con Nginx e proteggere con Lets Encrypt su CentOS 8

  5. Come installare Drupal 9 con Nginx e Lets Encrypt SSL su Debian 10

Come installare Wordpress con Nginx, MariaDB e HHVM su Debian 8

Come installare TYPO3 7 con Nginx e MariaDB su Debian 8 (Jessie)

Come installare Shopware con NGINX e Lets crittografare su Debian 9

Come installare Lighttpd con PHP, MariaDB e Lets Encrypt SSL su Debian 10

Come installare MyBB Forum con Nginx e Lets Encrypt su Debian 10

Come installare Wekan Kanban con Nginx e Lets Encrypt SSL su Debian 10