Ricerca nel sito web

Come installare OSClass con Nginx su Ubuntu 20.04


Questo tutorial esiste per queste versioni del sistema operativo

  • Ubuntu 20.04 (Focal Fossa)
  • Ubuntu 18.04 (Bionic Beaver)

Su questa pagina

  1. Prerequisiti
  2. Installa lo stack LEMP
  3. Crea un database per Osclass
  4. Scarica Osclass
  5. Configura Nginx per Osclass
  6. Proteggi Osclass con Lets Encrypt
  7. Accedi a Osclass
  8. Conclusione

Osclass è un'applicazione gratuita, open source e di facile utilizzo che può essere utilizzata per creare i propri siti Web classificati sul proprio server. Viene fornito con un editor ricco di funzionalità, un portale di amministrazione intuitivo, un sistema flessibile e di modelli che ti aiuta a creare il tuo sito di annunci senza alcuna conoscenza tecnica. Ha un registro di funzionalità tra cui Multilingua, Captcha, Dashboard, SEO Friendly, Motore di ricerca integrato, Creatore di siti gratuito e molti altri.

In questo tutorial, spiegheremo come installare cms del sito Web classificato Osclass con Nginx e Lets Encrypt SSL sul server Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Un nome di dominio valido indicato con l'IP del tuo server.
  • Il server è configurato con una password di root.

Installa lo stack LEMP

Innanzitutto, dovrai installare il server web Nginx, il server MariaDB, PHP e altri pacchetti richiesti nel tuo server. Puoi installarli tutti con il seguente comando:

apt-get install nginx mariadb-server php7.4 php7.4-cli php7.4-fpm php7.4-common php7.4-mysql php7.4-gd php7.4-xml curl gnupg2 unzip -y

Dopo aver installato tutti i pacchetti, puoi procedere al passaggio successivo.

Crea un database per Osclass

Successivamente, dovrai creare un database e un utente per Osclass. Innanzitutto, accedi a MariaDB con il seguente comando:

mysql

Una volta effettuato il login, crea un database e un utente per Osclass con il seguente comando:

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

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

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

Una volta terminato, puoi procedere al passaggio successivo.

Scarica Osclass

Innanzitutto, dovrai scaricare l'ultima versione di Osclass dal repository Git. Puoi scaricarlo con il seguente comando:

wget https://github.com/Dis555/Osclass/releases/download/4.2.0/Osclass-Evolution4.2.0.zip

Una volta completato il download, decomprimere il file scaricato nella directory principale di Nginx con il seguente comando:

unzip Osclass-Evolution4.2.0.zip -d /var/www/html/osclass

Quindi, cambia la proprietà della directory osclass in www-data e dai l'autorizzazione appropriata con il seguente comando:

chown -R www-data:www-data /var/www/html/osclass
chmod -R 755 /var/www/html/osclass

Una volta terminato, puoi procedere al passaggio successivo.

Configura Nginx per Osclass

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

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

Aggiungi le seguenti righe:

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

    server_name osclass.linuxbuz.com;
    root /var/www/html/osclass;

    index index.php index.html;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # Check this
    }
}

Salva e chiudi il file, quindi abilita l'host virtuale Nginx con il seguente comando:

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

Successivamente, controlla Nginx per eventuali errori di configurazione 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

Infine, riavvia il servizio Nginx per applicare le modifiche:

systemctl restart nginx

Successivamente, verifica lo stato del servizio Nginx utilizzando il seguente comando:

systemctl status nginx

Dovresti vedere 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 Thu 2020-08-13 06:21:23 UTC; 4s ago
       Docs: man:nginx(8)
    Process: 13399 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 13412 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 13415 (nginx)
      Tasks: 3 (limit: 2353)
     Memory: 3.5M
     CGroup: /system.slice/nginx.service
             ??13415 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??13416 nginx: worker process
             ??13417 nginx: worker process

Aug 13 06:21:23 ubunt4 systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 13 06:21:23 ubunt4 systemd[1]: Started A high performance web server and a reverse proxy server.

Una volta terminato, puoi procedere al passaggio successivo.

Proteggi Osclass con Lets Encrypt

È sempre una buona idea proteggere il tuo sito Web Osclass con Lets Encrypt SSL. Innanzitutto, dovrai installare il client Certbot nel tuo server. Certbot è un client Lets Encrypt utilizzato per gestire il certificato SSL per il tuo dominio. Puoi installare il client Certbot con il seguente comando:

apt-get install python3-certbot-nginx -y

Dopo aver installato il client Certbot, esegui il seguente comando per installare Lets Encrypt SSL per il tuo sito web.

certbot --nginx -d osclass.linuxbuz.com

Ti verrà chiesto di fornire il tuo indirizzo email e di accettare 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 osclass.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/osclass.conf

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

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 continuare. Una volta che il certificato è stato installato, dovresti vedere il seguente output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/osclass.conf

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

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

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

A questo punto, il tuo sito Web Osclass è protetto con Lets Encrypt SSL.

Accedi a Osclass

Ora apri il tuo browser web e digita l'URL https://osclass.linuxbuz.com. Verrai reindirizzato alla seguente schermata:

Fare clic sul pulsante INSTALLA per avviare l'installazione. Dovresti vedere la seguente schermata:

Assicurati che tutti i requisiti siano soddisfatti, quindi fai clic sul pulsante ESEGUI L'INSTALLAZIONE. Dovresti vedere la seguente schermata:

Fornire il nome del database, il nome utente del database, la password e fare clic sul pulsante AVANTI. Dovresti vedere la seguente schermata:

Fornisci il nome utente, la password, l'e-mail dell'amministratore e fai clic sul pulsante AVANTI. Una volta terminata l'installazione, dovresti vedere la seguente schermata:

Fare clic sul pulsante FINE E VAI AL PANNELLO DI AMMINISTRAZIONE. Verrai reindirizzato alla schermata di accesso di Osclass come mostrato di seguito:

Fornisci il nome utente e la password dell'amministratore e fai clic sul pulsante ACCEDI. Dovresti vedere la dashboard di Osclass nella seguente schermata:

Conclusione

In questa guida, hai imparato come installare Osclass cms con Nginx sul server Ubuntu 20.04. Hai anche imparato a proteggere Osclass con Lets Encrypt SSL. Spero che ora tu possa creare facilmente il tuo sito web classificato con Osclass.