Cómo instalar NextCloud en Debian 10

27 feb 2021 6 min di lettura
Cómo instalar NextCloud en Debian 10
Indice dei contenuti

NextCloud es un servidor de alojamiento y uso compartido de archivos de código abierto y gratuito, derivado del proyecto ownCloud. Es muy similar a otros servicios para compartir archivos como Google Drive, Dropbox e iCloud. NextCloud le permite almacenar archivos, documentos, imágenes, películas y videos desde la ubicación central. Con NextCloud puede compartir archivos, contactos y cualquier otro soporte con sus amigos y clientes. NextCloud se integra con correo, calendario, contactos y otras características que ayudarán a sus equipos a hacer su trabajo más rápido y más fácilmente. Puede instalar el cliente de NextCloud en una computadora de escritorio para sincronizar archivos con el servidor de Nextcloud. Los clientes de escritorio están disponibles para la mayoría de los sistemas operativos, incluidos Windows, macOS, FreeBSD y Linux.

En este tutorial, explicaremos cómo instalar NextCloud y protegerlo con Let's Encrypt SSL en Debian 10.

Prerrequisitos

  • Un servidor que ejecuta Debian 10.
  • Un nombre de dominio válido indicado con la IP de su servidor. En este tutorial usaremos el nextcloud.example.com, por ejemplo.
  • Usuario con privilegios de sudo.

Instale Apache, MariaDB y PHP

NextCloud se ejecuta en el servidor web, escrito en PHP, y usa MariaDB para almacenar sus datos. Luego, deberá instalar Apache, MariaDB, PHP y otros paquetes necesarios en su sistema. Puede instalarlos todos ejecutando el siguiente comando:

sudo apt-get install apache2 libapache2-mod-php mariadb-server php-xml php-cli php-cgi php-mysql php-mbstring php-gd php-curl php-zip wget unzip -y

Una vez instalados todos los paquetes, abra el archivo php.ini y cambie algunas configuraciones recomendadas:

sudo nano /etc/php/7.3/apache2/php.ini

Cambie la siguiente configuración:

memory_limit = 512M
 upload_max_filesize = 500M
 post_max_size = 500M
 max_execution_time = 300

Guarde y cierre el archivo cuando termine. Luego, inicie el servicio Apache y MariaDB y habilítelos para que se inicien después de reiniciar el sistema con el siguiente comando:

sudo systemctl start apache2
sudo systemctl start mariadb
sudo systemctl enable apache2
sudo systemctl enable mariadb

Una vez hecho esto, puede continuar con el siguiente paso.

Configurar la base de datos para NextCloud

A continuación, deberá crear una base de datos y un usuario de base de datos para NextCloud. Para hacer esto, inicie sesión en el shell MariaDB con el siguiente comando:

sudo mysql -u root -p

Proporcione la contraseña de root cuando se le solicite, luego cree una base de datos y un usuario con el siguiente comando:

CREATE DATABASE nextclouddb;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'password';

A continuación, conceda todos los privilegios a nextclouddb con el siguiente comando:

GRANT ALL ON nextclouddb.* TO 'nextclouduser'@'localhost';

Luego, borre los privilegios y salga del shell MariaDB con el siguiente comando:

FLUSH PRIVILEGES;
EXIT;

Una vez hecho esto, puede continuar con el siguiente paso.

Descarga NextCloud

Primero, visite la página de descarga de NextCloud y descargue la última versión de NextCloud en su sistema. En el momento de escribir este artículo, la última versión de NextCloud es 17.0.1. Puedes descargarlo con el siguiente comando:

sudo wget https://download.nextcloud.com/server/releases/nextcloud-17.0.1.zip

Una vez que se complete la descarga, descomprima el archivo descargado con el siguiente comando:

sudo unzip nextcloud-17.0.1.zip

Luego, mueva el directorio extraído al directorio raíz web de Apache:

sudo mv nextcloud /var/www/html/

Luego, otorgue los permisos apropiados al directorio nextcloud con el siguiente comando:

sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/

Una vez hecho esto, puede continuar con el siguiente paso.

Configurar Apache para NextCloud

A continuación, deberá crear un archivo de configuración de host virtual Apache para servir a NextCloud. Puedes crearlo con el siguiente comando:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Agrega las siguientes líneas:

<VirtualHost *:80>
 ServerAdmin [email protected]
 DocumentRoot /var/www/html/nextcloud/ServerName nextcloud.example.com

 Alias /nextcloud "/var/www/html/nextcloud/"

 <Directory /var/www/html/nextcloud/>
 Options +FollowSymlinks
 AllowOverride All
 Require all granted
 <IfModule mod_dav.c>
 Dav off
 </IfModule>
 SetEnv HOME /var/www/html/nextcloud
 SetEnv HTTP_HOME /var/www/html/nextcloud
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined

 </VirtualHost>

Guarde y cierre el archivo cuando termine. Luego, habilite el archivo de host virtual Apache y otros módulos requeridos usando los siguientes comandos:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod mime
sudo a2enmod env
sudo a2enmod dir

Finalmente, reinicie el servicio Apache para aplicar la nueva configuración:

sudo systemctl restart apache2

Asegure NextCloud con Let's Encrypt SSL gratuito

NextCloud ahora está instalado y configurado. Después de eso, se recomienda protegerlo con Let's Encrypt SSL gratuito. Para hacer esto, primero instale el cliente Certbot con el siguiente comando:

sudo apt-get install python-certbot-apache -y

Una vez instalado, puede ejecutar el siguiente comando para instalar Let's Encrypt Certificate para su dominio nextcloud.example.com.

sudo certbot --apache -d nextcloud.example.com

Durante la instalación, se le pedirá que proporcione su dirección de correo electrónico y que acepte el plazo de servicio como se muestra a continuación:

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 nextcloud.example.com
 Enabled Apache rewrite module
 Waiting for verification...
 Cleaning up challenges
 Created an SSL vhost at /etc/apache2/sites-available/nextcloud-le-ssl.conf
 Deploying Certificate to VirtualHost /etc/apache2/sites-available/nextcloud-le-ssl.conf
 Enabling available site: /etc/apache2/sites-available/nextcloud-le-ssl.conf

 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

Luego, escriba 2 y presione Entrar para descargar e instalar un certificado SSL gratuito para su dominio. Una vez que la instalación se haya completado con éxito. Debería obtener el siguiente resultado:

Enabled Apache rewrite module
 Redirecting vhost in /etc/apache2/sites-enabled/nextcloud.conf to ssl vhost in /etc/apache2/sites-available/nextcloud-le-ssl.conf

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

 You should test your configuration at:
 https://www.ssllabs.com/ssltest/analyze.html?d=nextcloud.example.com
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
 /etc/letsencrypt/live/example.com/fullchain.pem
 Your key file has been saved at:
 /etc/letsencrypt/live/example.com/privkey.pem
 Your cert will expire on 2019-10-22. 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

Una vez hecho esto, puede continuar con el siguiente paso.

Inicie sesión en la interfaz web de NextCloud

NextCloud ahora está configurado y protegido con Let's Encrypt SSL. Luego, abra su navegador web y escriba la URL https://nextcloud.example.com. Serás redirigido a la siguiente página:

Ahora, ingrese el nombre de usuario y la contraseña del administrador, la carpeta Datos, las credenciales correctas de la base de datos y haga clic en el botón Finalizar configuración. Serás redirigido al panel de NextCloud.

Conclusión

¡Felicidades! ha instalado y protegido correctamente NextCloud con Let's Encrypt SSL gratuito en Debian 10. Ahora puede compartir fácilmente archivos, documentos y medios con otros usuarios utilizando la interfaz web de NextCloud.

Buy me a coffeeBuy me a coffee

Supportaci se ti piacciono i nostri contenuti. Grazie.

Successivamente, completa il checkout per l'accesso completo a Noviello.it.
Bentornato! Accesso eseguito correttamente.
Ti sei abbonato con successo a Noviello.it.
Successo! Il tuo account è completamente attivato, ora hai accesso a tutti i contenuti.
Operazione riuscita. Le tue informazioni di fatturazione sono state aggiornate.
La tua fatturazione non è stata aggiornata.