GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare MediaWiki con Nginx e Lets Encrypt SSL su Ubuntu 20.04

MediaWiki è un software wiki open source scritto in PHP. Ti consente di creare il tuo sito Web wiki auto-ospitato sul server. È una delle piattaforme wiki più popolari grazie alla sua semplicità e personalizzazione. Attualmente è utilizzato da molte aziende per gestire le proprie pagine wiki. Fornisce uno strumento versatile e gratuito per la pubblicazione di contenuti su Internet.

In questo tutorial, ti mostreremo come installare MediaWiki con il server web Nginx e Let's Encrypt SSL su Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Un nome di dominio valido puntato all'IP del tuo server.
  • Sul server è configurata una password di root.

Per iniziare

Innanzitutto, aggiorna i pacchetti di sistema alla versione aggiornata eseguendo il comando seguente:

apt-get update -y

Una volta aggiornati tutti i pacchetti, puoi procedere al passaggio successivo.

Installa Nginx, MariaDB e PHP

MediaWiki richiede il server web Nginx, il server di database MariaDB, PHP e altre estensioni. Puoi installarli tutti con il seguente comando:

apt-get install nginx mariadb-server php php-fpm php-mbstring php-xml php-json php-mysql php-curl php-intl php-gd php-mbstring texlive imagemagick unzip -y

Una volta installati tutti i pacchetti, installa Composer con il seguente comando:

apt-get install composer -y

Quindi, modifica il file php.ini e cambia le impostazioni predefinite:

nano /etc/php/7.4/fpm/php.ini

Modifica le seguenti righe:

memory_limit = 512M
post_max_size =32M
upload_max_filesize = 32M
date.timezone = Asia/Kolkata

Salva e chiudi il file, quindi riavvia PHP-FPM per applicare le modifiche:

systemctl restart php7.4-fpm

Una volta terminato, puoi procedere al passaggio successivo.

Crea un database MariaDB

MediaWiki utilizza MariaDB come database back-end, quindi dovrai creare un database e un utente per MediaWiki.

Innanzitutto, connettiti a MariaDB con il seguente comando:

mysql

Una volta connesso, crea un database e un utente con il seguente comando:

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

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

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

Una volta terminato, puoi procedere al passaggio successivo.

Scarica MediaWiki

Primo. vai al sito Web MediaWiki e scegli l'ultima versione di MediaWiki. Quindi, esegui il seguente comando per scaricarlo sul tuo server:

wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.2.zip

Una volta completato il download, decomprimere il file scaricato con il seguente comando:

unzip mediawiki-1.35.2.zip

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

mv mediawiki-1.35.2 /var/www/html/mediawiki

Quindi, cambia la directory in MediaWiki e installa tutte le dipendenze PHP con il seguente comando:

cd /var/www/html/mediawiki
composer install --no-dev

Una volta installate tutte le dipendenze, imposta l'autorizzazione e la proprietà appropriate con il comando seguente:

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

Una volta terminato, puoi procedere al passaggio successivo.

Configura Nginx per MediaWiki

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

nano /etc/nginx/conf.d/wiki.conf

Aggiungi le seguenti righe:

server {
        listen 80;
        server_name wiki.example.com;

        root /var/www/html/mediawiki;
        index index.php;
   
        error_log /var/log/nginx/mediawiki.error;
        access_log /var/log/nginx/mediawiki.access;

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


        location ~ /\.ht {
          deny all;
         }

        location ~ \.php$ {
            fastcgi_pass unix:/run/php/php7.4-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            include snippets/fastcgi-php.conf;
        }
}

Salva e chiudi il file, quindi verifica Nginx per eventuali errori di sintassi con il seguente comando:

nginx -t

Dovresti vedere 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, riavvia il servizio Nginx per applicare le modifiche:

systemctl restart nginx

Puoi anche verificare lo stato di Nginx con 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 Wed 2021-06-02 05:06:48 UTC; 3s ago
       Docs: man:nginx(8)
    Process: 24594 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
    Process: 24605 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
   Main PID: 24606 (nginx)
      Tasks: 2 (limit: 2353)
     Memory: 2.8M
     CGroup: /system.slice/nginx.service
             ??24606 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
             ??24607 nginx: worker process

Jun 02 05:06:48 ubuntu2004 systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 02 05:06:48 ubuntu2004 systemd[1]: Started A high performance web server and a reverse proxy server.

Accedi all'interfaccia utente Web di MediaWiki

Ora apri il tuo browser web e digita l'URL http://wiki.example.com . Verrai reindirizzato alla seguente pagina:

Ora, fai clic su imposta il wiki pulsante. Dovresti vedere la seguente pagina:

Qui, scegli la tua lingua wiki e fai clic su Continua pulsante. Dovresti vedere la seguente pagina:

Ora, fai clic su Continua pulsante. Dovresti vedere la seguente pagina:

Ora, fornisci i dettagli del tuo database e fai clic su Continua pulsante. Dovresti vedere la seguente pagina:

Seleziona utilizza lo stesso account utilizzato per l'installazione e fai clic su Continua pulsante. Dovresti vedere la seguente pagina:

Ora, fornisci il nome, il nome utente e la password del tuo sito wiki. Quindi, fai clic su Continua pulsante. Dovresti vedere la seguente pagina:

Fai clic su Continua pulsante per avviare l'installazione. Dovresti vedere la seguente pagina:

Fai clic su Continua pulsante. Una volta terminata l'installazione, dovresti vedere la seguente pagina:

Ora, fai clic sul pulsante di download per scaricare LocalSettings.php file nel tuo sistema. Quindi, copia questo file sul tuo server all'interno della directory principale di MediaWiki e imposta i permessi appropriati con il seguente comando:

chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php

Quindi, torna al tuo browser web e fai clic su entra nella tua wiki . Dovresti vedere la dashboard di MediaWiki nella pagina seguente:

Proteggi MediaWiki con Let's Encrypt SSL

Successivamente, dovrai installare il pacchetto client Certbot per installare la gestione di Let's Encrypt SSL.

Innanzitutto, installa Certbot con il seguente comando:

apt-get install python3-certbot-nginx -y

Al termine dell'installazione, esegui il seguente comando per installare Let's Encrypt SSL sul tuo sito Web:

certbot --nginx -d wiki.example.com

Ti verrà chiesto di fornire un indirizzo email valido e di accettare i termini del 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): [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 wiki.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/wiki.conf

Quindi, scegli 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 per completare l'installazione. Dovresti vedere il seguente output:

Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/wiki.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://wiki.example.com

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

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

 - 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.

Ora, il tuo sito web è protetto con Let's Encrypt SSL. Puoi accedervi in ​​modo sicuro utilizzando l'URL https://wiki.example.com.

Conclusione

Congratulazioni! hai installato con successo MediaWiki con Nginx e Let's Encrypt SSL su Ubuntu 20.04. Ora puoi ospitare facilmente il tuo sito wiki con MediaWiki.


Ubuntu
  1. Come installare Nextcloud con Nginx e Lets Encrypt SSL su Ubuntu 20.04 LTS

  2. Come installare Magento 2 con Nginx e Lets Encrypt SSL su Ubuntu 20.04 LTS

  3. Come installare MediaWiki con Nginx su Ubuntu 16.04

  4. Come installare Drupal 8 con Nginx, PHP-FPM e SSL su Ubuntu 15.10

  5. Come installare OpenCart 2 con Nginx e SSL su Ubuntu 15.10

Come installare NodeBB Forum con Nginx e Lets Encrypt SSL su Ubuntu 20.04 LTS

Come installare TYPO3 CMS con Lets Encrypt SSL su Ubuntu 20.04

Come installare Concrete5 CMS con Apache e Lets Encrypt SSL gratuito su Ubuntu 20.04

Come installare ProjectSend con Apache e Lets Encrypt SSL su Ubuntu 20.04

Come installare Moodle con Nginx e Lets Encrypt SSL su Ubuntu 20.04

Come installare Gitea con Nginx e Lets Encrypt SSL gratuito su Ubuntu 20.04