GNU/Linux >> Tutoriales Linux >  >> Ubuntu

Cómo instalar MediaWiki con Nginx y Lets Encrypt SSL en Ubuntu 20.04

MediaWiki es un software wiki de código abierto escrito en PHP. Le permite crear su propio sitio web wiki alojado en el servidor. Es una de las plataformas wiki más populares debido a su simplicidad y personalización. Actualmente, muchas empresas lo utilizan para administrar sus páginas wiki. Proporciona una herramienta versátil y gratuita para publicar contenido en Internet.

En este tutorial, le mostraremos cómo instalar MediaWiki con el servidor web Nginx y Let's Encrypt SSL en Ubuntu 20.04.

Requisitos

  • Un servidor con Ubuntu 20.04.
  • Un nombre de dominio válido apuntado con la IP de su servidor.
  • Se configura una contraseña raíz en el servidor.

Cómo empezar

Primero, actualice los paquetes del sistema a la versión actualizada ejecutando el siguiente comando:

apt-get update -y

Una vez que todos los paquetes estén actualizados, puede continuar con el siguiente paso.

Instalar Nginx, MariaDB y PHP

MediaWiki requiere un servidor web Nginx, un servidor de base de datos MariaDB, PHP y otras extensiones. Puede instalarlos todos con el siguiente 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 vez que todos los paquetes estén instalados, instale Composer con el siguiente comando:

apt-get install composer -y

A continuación, edite el archivo php.ini y cambie la configuración predeterminada:

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

Cambie las siguientes líneas:

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

Guarde y cierre el archivo y luego reinicie PHP-FPM para aplicar los cambios:

systemctl restart php7.4-fpm

Una vez que haya terminado, puede continuar con el siguiente paso.

Crear una base de datos MariaDB

MediaWiki utiliza MariaDB como base de datos, por lo que deberá crear una base de datos y un usuario para MediaWiki.

Primero, conéctese a MariaDB con el siguiente comando:

mysql

Una vez que esté conectado, cree una base de datos y un usuario con el siguiente comando:

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

A continuación, elimine los privilegios y salga de MariaDB con el siguiente comando:

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

Una vez que haya terminado, puede continuar con el siguiente paso.

Descargar MediaWiki

Primero. vaya al sitio web de MediaWiki y elija la última versión de MediaWiki. Luego, ejecuta el siguiente comando para descargarlo a tu servidor:

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

Una vez completada la descarga, descomprima el archivo descargado con el siguiente comando:

unzip mediawiki-1.35.2.zip

A continuación, mueva el directorio extraído al directorio raíz web de Nginx con el siguiente comando:

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

A continuación, cambie el directorio a MediaWiki e instale todas las dependencias de PHP con el siguiente comando:

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

Una vez que todas las dependencias estén instaladas, establezca el permiso y la propiedad adecuados con el siguiente comando:

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

Una vez que haya terminado, puede continuar con el siguiente paso.

Configurar Nginx para MediaWiki

A continuación, deberá crear un archivo de configuración de host virtual Nginx para MediaWiki. Puedes crearlo con el siguiente comando:

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

Agregue las siguientes líneas:

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;
        }
}

Guarde y cierre el archivo, luego verifique el Nginx para cualquier error de sintaxis con el siguiente comando:

nginx -t

Debería ver el siguiente resultado:

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

A continuación, reinicie el servicio Nginx para aplicar los cambios:

systemctl restart nginx

También puede verificar el estado de Nginx con el siguiente comando:

systemctl status nginx

Debería ver el siguiente resultado:

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

Acceder a la interfaz de usuario web de MediaWiki

Ahora, abra su navegador web y escriba la URL http://wiki.example.com . Será redirigido a la siguiente página:

Ahora, haga clic en configurar la wiki botón. Debería ver la siguiente página:

Aquí, elige el idioma de tu wiki y haz clic en Continuar botón. Debería ver la siguiente página:

Ahora, haga clic en Continuar botón. Debería ver la siguiente página:

Ahora, proporcione los detalles de su base de datos y haga clic en Continuar botón. Debería ver la siguiente página:

Seleccione usar la misma cuenta que para la instalación y haga clic en Continuar botón. Debería ver la siguiente página:

Ahora, proporcione el nombre, el nombre de usuario y la contraseña de su sitio wiki. Luego, haga clic en Continuar botón. Debería ver la siguiente página:

Haga clic en Continuar botón para iniciar la instalación. Debería ver la siguiente página:

Haga clic en Continuar botón. Una vez finalizada la instalación, debería ver la siguiente página:

Ahora, haga clic en el botón de descarga para descargar LocalSettings.php archivo a su sistema. Luego, copie este archivo a su servidor dentro del directorio raíz de MediaWiki y establezca el permiso adecuado con el siguiente comando:

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

Luego, regrese a su navegador web y haga clic en ingrese su wiki . Debería ver el panel de control de MediaWiki en la siguiente página:

Asegure MediaWiki con Let's Encrypt SSL

A continuación, deberá instalar el paquete de cliente de Certbot para instalar y administrar Let's Encrypt SSL.

Primero, instale Certbot con el siguiente comando:

apt-get install python3-certbot-nginx -y

Una vez finalizada la instalación, ejecute el siguiente comando para instalar Let's Encrypt SSL en su sitio web:

certbot --nginx -d wiki.example.com

Se le pedirá que proporcione una dirección de correo electrónico válida y acepte el término de servicio como se muestra a continuación:

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

A continuación, elija si desea o no redirigir el tráfico HTTP a HTTPS como se muestra a continuación:

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

Escriba 2 y presione Entrar para finalizar la instalación. Debería ver el siguiente resultado:

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.

Ahora, su sitio web está protegido con Let's Encrypt SSL. Puede acceder a él de forma segura utilizando la URL https://wiki.example.com.

Conclusión

¡Felicidades! ha instalado con éxito MediaWiki con Nginx y Let's Encrypt SSL en Ubuntu 20.04. Ahora puede alojar fácilmente su propio sitio wiki con MediaWiki.


Ubuntu
  1. Cómo instalar Nextcloud con Nginx y Lets Encrypt SSL en Ubuntu 20.04 LTS

  2. Cómo instalar Magento 2 con Nginx y Lets Encrypt SSL en Ubuntu 20.04 LTS

  3. Cómo instalar MediaWiki con Nginx en Ubuntu 16.04

  4. Cómo instalar Drupal 8 con Nginx, PHP-FPM y SSL en Ubuntu 15.10

  5. Cómo instalar OpenCart 2 con Nginx y SSL en Ubuntu 15.10

Cómo instalar NodeBB Forum con Nginx y Lets Encrypt SSL en Ubuntu 20.04 LTS

Cómo instalar TYPO3 CMS con Lets Encrypt SSL en Ubuntu 20.04

Cómo instalar Concrete5 CMS con Apache y Lets Encrypt SSL gratis en Ubuntu 20.04

Cómo instalar ProjectSend con Apache y Lets Encrypt SSL en Ubuntu 20.04

Cómo instalar Moodle con Nginx y Lets Encrypt SSL en Ubuntu 20.04

Cómo instalar Gitea con Nginx y Lets Encrypt SSL gratis en Ubuntu 20.04