Make a Network Access Storage (NAS) with a Raspberry Pi
To proceed, either use dietpi OS and select nextcloud, apache2, MariaDB , PHP packages (LAMP) to install and any additional package needed.
or follow the procedure described hereafter:
sudo apt-get update && apt-get upgrade
sudo apte-get install apache2 -y
systemctl start apache2
systemctl enable apache2
Install additional packages required by nextCloud server (apache2,MariaDb, php)
sudo apt install -y apache2 mariadb-server libapache2-mod-php7.0 \
php7.0-gd php7.0-json php7.0-mysql php7.0-curl \
php7.0-intl php7.0-mcrypt php-imagick \
php7.0-zip php7.0-xml php7.0-mbstring
Install nextCloud
cd /tmp
wget https://download.nextcloud.org/community/nextcloud-10.18.4.tar.bz2
tar -xvf owncloud-10.18.4.tar.bz2
chown -R www-data:www-data nextcloud
mv nextcloud /var/www/html/
cd
Configure apache2 web server for nextCloud
sudo nano /etc/apache2/sites-available/nextcloud.conf
Paste the following block
Alias /nextcloud "/var/www/html/nextcloud/"
<Directory /var/www/html/nextcloud/>
Options +FollowSymlinks
AllowOverride All
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/html/nextcloud
SetEnv HTTP_HOME /var/www/html/nextcloud
</Directory>
Copy this file into /etc/apache2/sites-enabled folder
cp /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf
Alternatively, create a link as follows
sudo su
ln -s /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-enabled/nextcloud.conf
Additional Apache2 configuration: Execute the following commands:
a2enmod headers
systemctl restart apache2
a2enmod env
a2enmod dir
a2enmod mime
Create database and user
mysql -uroot -ppassword
MariaDB [(none)]> create database nextcloud;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> create user nextcloud@localhost identified by '12345';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> grant all privileges on nextcloud.* to nextcloud@localhost identified by '12345';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit;
Bye
Start nextCloud with Web Server. Open a browser with the IP address of the Raspberry (returned from hostname -I or ifconfig).
http://IP_ADDRESS/nextcloud
Here enter a username and password to create an admin account :
administrator name (nextcloud)
administrator password (nextcloud_password) (See above)
Enter the path of the data directory
/mnt/some_location (where the hard-disk storing the files is mounted)
then immediately underneath enter your MySQL details as follow:
Username: nextcloud
Password: nextcloud_password (See above)
Database: nextcloud
Server: localhost:3306
Click Finish Set-up. Installation of nextCloud is completed.
To update Nextcloud installation follow the following:
Update/upgrade the system
sudo apt update && sudo apt upgrade -y
Go into Nextcloud folder usually /var/www/nextcloud or /var/www/html/nextcloud
Then run the following command:
sudo -u www-data php updater/updater.phar --no-interaction
The system will update automatically and restart. Process can take quite some times however.