Toutes les opérations suivantes sont à effectuer en root
. Vous pouvez taper sudo
devant toutes les commandes qui suivent ou taper sudo -s
pour ouvrir une session en tant que root.
La mise à jour se fait de façon classique :
freebox@my1:~$ sudo -s
root@my1:/home/freebox# apt update
root@my1:/home/freebox# apt upgrade
Nous avons besoin d'Apache, de MariaDB, de PHP et des modules pour lier le tout. On ajoute unzip fail2ban certbot dont nous auront besion plus tard.
root@my1:/home/freebox# apt install apache2 libapache2-mod-php php-mbstring php-xml php-zip unzip fail2ban certbot python3-certbot-apache php-gd php-curl php7.4-intl php-bcmath php-imagick php-gmp php-apcu mariadb-server php-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
...
0 upgraded, 163 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.3 MB of archives.
After this operation, 292 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
...
On suit les recommandations pour sécuriser à l'aide de mysql_secure_installation.
Le but est que seul l’utilisateur root de la VM puisse se connecter localement sans mot de passe en utilisant les "socket unix".
root@my1:/home/freebox# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!
Change the root password? [Y/n] n
... skipping.
Remove anonymous users? [Y/n] Y
... Success!
Disallow root login remotely? [Y/n] Y
... Success!
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
Thanks for using MariaDB!
root@my1:/home/freebox#
On créer une base de données nommée "nextcloud" et un utilisateur "admin" qui aura tout les droits sur la base nextcloud.
root@my1:/home/freebox# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 51
Server version: 10.5.8-MariaDB-3 Debian buildd-unstable
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> CREATE DATABASE nextcloud;
Query OK, 1 row affected (0.000 sec)
MariaDB [(none)]> CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'super pwd';
Query OK, 0 rows affected (0.003 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'admin'@'localhost' WITH GRANT OPTION ;
Query OK, 0 rows affected (0.002 sec)
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> exit
Bye
root@my1:/home/freebox#
Le répertoire raçine par défaut d'apache est /var/www/html. Installer Nextcloud dans /var/www.
root@my1:/home/freebox# cd /var/www
root@My1:/var/www# wget https://download.nextcloud.com/server/releases/latest-20.zip
--2020-12-16 10:56:40-- https://download.nextcloud.com/server/releases/latest-20.zip
Resolving download.nextcloud.com (download.nextcloud.com)... 2a01:4f9:2a:3119::181, 95.217.64.181
Connecting to download.nextcloud.com (download.nextcloud.com)|2a01:4f9:2a:3119::181|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 142325595 (136M) [application/zip]
Saving to: ‘latest-20.zip’
latest-20.zip 100%[==================================================================>] 135.73M 55.3MB/s in 2.5s
2021-01-08 15:13:16 (55.3 MB/s) - ‘latest-20.zip’ saved [142325595/142325595]
root@my1:/var/www/html$ sudo unzip latest-20.zip
...
root@my1:/var/www#
Pour la sécurité, on créer un répertoire /var/www/nextcloud-data pour les datas de Nextcloud en dehors de /var/www/nextcloud. On change le propriétaire pour www-data.
root@my1:/var/www# mkdir nextcloud-data
root@my1:/var/www# chown -R www-data:www-data nextcloud nextcloud-data
On crée un fichier "/etc/apache2/sites-available/010.nextcloud.conf", on l'active ainsi que "mod_headers", et on redémarre Apache.
root@my1:/var/www# nano /etc/apache2/sites-available/010.nextcloud.conf
<VirtualHost *:80> ServerAdmin bruno@ducouet.fr ServerName my1.ducouet.fr ServerAlias my1 DocumentRoot /var/www/nextcloud </VirtualHost>
root@my1:/var/www# a2enmod headers Enabling module headers. To activate the new configuration, you need to run: systemctl restart apache2 root@my1:/var/www# a2ensite 010.nextcloud.conf Enabling site 010.nextcloud. To activate the new configuration, you need to run: systemctl reload apache2 root@my1:/var/www# systemctl reload apache2 root@my1:/var/www#
On crée un fichier de conf 99-nextcloud.ini
root@my1:/var/www# nano /etc/php/7.4/apache2/conf.d/99-nextcloud.ini
output_buffering = Off memory_limit = 1024M apc.enable_cli = 1
root@my1:/var/www# systemctl reload apache2
/var/www/html/nextcloud
, un répertoire exérieur comme /var/www/html/datas
peut être un bon choix.