
Existe un manual anterior de @Kike pero está desactualizado aunque he usado algunos datos, la mayor parte de este manual pertenece al texto sobre el tema de la página web ElAngelCaido (Cerrada por el momento) y también a algunas revisiones mias.
RASPBIANJESSIE:
He usado una RPi3 y la imagen 2017-06-21-raspbian-jessie-lite.img con configuración de locales en es_ES.UTF8-UTF8 e IP estática 192.168.1.20.
RASPBIAN STRETCH:
He usado una RPi3 y la imagen 2017-09-07-raspbian-stretch-lite.img con configuración de locales en es_ES.UTF8-UTF8 e IP estática 192.168.1.20.


ACTUALIZAMOS EL SISTEMA
Código: Seleccionar todo
sudo apt-get update && sudo apt-get upgrade
INSTALAMOS REPOSITORIOS
Código: Seleccionar todo
sudo su
Código: Seleccionar todo
echo "deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi" >> /etc/apt/sources.list
Código: Seleccionar todo
echo "Package: *" >> /etc/apt/preferences
Código: Seleccionar todo
echo "Pin: release n=jessie" >> /etc/apt/preferences
Código: Seleccionar todo
echo "Pin-Priority: 600" >> /etc/apt/preferences
Código: Seleccionar todo
exit
Código: Seleccionar todo
sudo apt-get update
Código: Seleccionar todo
sudo apt-get install -t stretch php7.0 php7.0-bz2 php7.0-cli php7.0-curl php7.0-gd php7.0-fpm php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php-pear php7.0-imap php-memcache php7.0-pspell php7.0-recode php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mysql php7.0-opcache php7.0-xml php7.0-zip php-imagick php-redis libapache2-mod-php7.0 mariadb-server apache2
- Cuando te aparezca (:) dos puntos en la parte inferior izquierda deberás pulsar ENTER hasta que aparezca (q to quit) entonces pulsas "q"
- Después te aparecerán varias pantallas azules
"Restart services during package upgrades without asking?" ----> NO
"Services to restart for GNU library upgrade: ssh cron" -----------> OK
Código: Seleccionar todo
sudo apt-get autoremove
INSTALAMOS PHP7-MARIADB-APACHE2
Código: Seleccionar todo
sudo apt-get install php7.0 php7.0-bz2 php7.0-cli php7.0-curl php7.0-gd php7.0-fpm php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php-pear php7.0-imap php-memcache php7.0-pspell php7.0-recode php7.0-tidy php7.0-xmlrpc php7.0-xsl php7.0-mysql php7.0-opcache php7.0-xml php7.0-zip php-imagick php-redis libapache2-mod-php7.0 mariadb-server apache2
INSTALAMOS PHP7.2-MARIADB-APACHE2
Código: Seleccionar todo
sudo apt-get install php7.2 php7.2-bz2 php7.2-cli php7.2-curl php7.2-gd php7.2-fpm php7.2-intl php7.2-json php7.2-mbstring php-pear php7.2-imap php-memcache php7.2-pspell php7.2-recode php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mysql php7.2-opcache php7.2-xml php7.2-zip php7.2-dev php-imagick redis-server php-redis libapache2-mod-php7.2 mariadb-server apache2
Código: Seleccionar todo
sudo systemctl enable redis-server
- Instalamos los paquetes de configuración necesarios
Código: Seleccionar todo
sudo apt-get -y install gcc make autoconf libc-dev pkg-config
Código: Seleccionar todo
sudo apt-get -y install libmcrypt-dev
Código: Seleccionar todo
sudo pecl install mcrypt-1.0.1
Código: Seleccionar todo
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/cli/conf.d/mcrypt.ini"
Código: Seleccionar todo
sudo bash -c "echo extension=/usr/lib/php/20170718/mcrypt.so > /etc/php/7.2/apache2/conf.d/mcrypt.ini"
Código: Seleccionar todo
php -i | grep mcrypt
CONTINUAMOS, UNA VEZ INSTALADOS LOS PROGRAMAS EN EL SISTEMA OPERATIVO CORRESPONDIENTE
COMPROBAMOS LAS VERSIONES INSTALADAS
Código: Seleccionar todo
php --version
Código: Seleccionar todo
mysql --version
Código: Seleccionar todo
sudo nano /etc/php/7.0/fpm/php.ini
Y lo modificamosupload_max_filesize = 2M
Guardamos CRTL+O y cerramos CRTL+Xupload_max_filesize = 2000M
Buscamos "post_max_size"
Y lo modificamospost_max_size = 8M
Guardamos y cerramospost_max_size = 2000M
CONFIGURACION DE MariaDB
Securizamos la instalación:
Código: Seleccionar todo
sudo mysql_secure_installation
Preguntará
e introducimos el password que queramos para root en MariaDB"Set root password? [Y/n]" --- Y
Tras introducir la contraseña de root respondemos a las preguntas como sigue:
(ATENCIÓN: Puede que no salga debido a que hemos cambiado el password en el paso anterior)Change the root password? [Y/n] n <---
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] y
Remove test database and access to it? [Y/n] y
CREAMOS LA BASE DE DATOS Y EL USUARIOReload privilege tables now? [Y/n] y
Código: Seleccionar todo
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'caylus'@'localhost' IDENTIFIED BY 'caylus123';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'caylus'@'localhost';
FLUSH PRIVILEGES;
exit;HABILITAMOS LOS MODULOS SSL Y REWRITE EN APACHE
Código: Seleccionar todo
sudo a2enmod ssl
Código: Seleccionar todo
sudo a2enmod rewrite
Código: Seleccionar todo
sudo reboot
Código: Seleccionar todo
sudo openssl req -new -x509 -days 365 -nodes -out /etc/ssl/certs/nextcloud.pem -keyout /etc/ssl/private/nextcloud.key
Country Name (2 letter code) [AU]: SP
State or Province Name (full name) [Some-State]: Mi_Casa
Locality Name (eg, city) []: Mi_Casa
Organization Name (eg, company) [Internet Widgits Pty Ltd]: Caylus
Organizational Unit Name (eg, section) []:Caylus
Coomon Name (e.g. server FQDN or YOUR name) []: Caylus NUBE
Al ser un certificado autofirmado aparecerá, cuando conectemos por https, el mensaje "No se confía en el certificado porque está autofirmado." simplemente hay que añadir la página a las excepciones de seguridad.Email Addres []: caylus@caylus.es
CONFIGURAMOS LOS CERTIFICADOS
Copiar el archivo de configuracion default-ssl en la carpeta de sitios activos
Código: Seleccionar todo
sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf
Código: Seleccionar todo
sudo nano /etc/apache2/sites-enabled/default-ssl.conf
Buscamos "ssl-cert-snakeoil.pem" y lo sustituimos por "nextcloud.pem"
Buscamos "ssl-cert-snakeoil.key" y lo sustituimos por "nextcloud.key"
Y añadir, justo debajo, lo siguiente:
Guardamos y, antes de reiniciar, activamos el módulo headers<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
</IfModule>
Código: Seleccionar todo
sudo a2enmod headers
Código: Seleccionar todo
sudo reboot
INSTALACION NEXTCLOUD
Descargamos
Código: Seleccionar todo
sudo wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.zip
Código: Seleccionar todo
sudo unzip nextcloud-12.0.0.zip
Código: Seleccionar todo
sudo cp -R /var/www/html /var/www/htmlviejo
Código: Seleccionar todo
sudo rm -R /var/www/html
Código: Seleccionar todo
sudo mv nextcloud /var/www/html
Código: Seleccionar todo
sudo rm nextcloud-12.0.0.zip
Para configurar más facilmente damos permisos totales temporalmente
Código: Seleccionar todo
sudo chmod 777 -R /var/www/html
Ahora entraremos al servidor desde nuestro navegador Web poniendo la dirección IP de nuestra PI
http://IP_DE_NUESTRA_PI en mi caso http://192.168.1.20

A continuación, debemos añadir las direcciones IP y DOMINIOS a los que se permite el acceso
Código: Seleccionar todo
sudo nano /var/www/html/config/config.php
y añadimos las direcciones IP y DOMINIOS que necesitemosarray (
0 => '192.168.1.20',
),
SECURIZACION DE LA INSTALACIONarray (
0 => '192.168.1.20',
1 => 'caylus.no-ip.com',
),
Añadimos el usuario www-data al grupo www-data
Código: Seleccionar todo
sudo usermod -a -G www-data www-data
Código: Seleccionar todo
sudo nano nextcloud.sh
Código: Seleccionar todo
#!/bin/bash
ocpath='/var/www/html'
htuser='www-data'
htgroup='www-data'
rootuser='root'
printf "Comprobando Directorios y creandolos si faltasen\n"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater
printf "Dando permisos a Archivos y Directorios\n"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750
chmod 755 ${ocpath}
printf "Asignando propietarios de Directorios\n"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/
chmod +x ${ocpath}/occ
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi
Código: Seleccionar todo
sudo bash nextcloud.sh
Código: Seleccionar todo
sudo rm nextcloud.sh
:mareado
Espero que os sea útil, pero si alguien tiene alguna duda, sugerencia o comentario no dudeis en hacermelo saber.
Abrazos
