- Raspberry Pi 3B+ or newer
- External SSD (ext4 formatted)
- Raspberry Pi OS (Bullseye+)
- Stable internet connection
- Powered USB hub (recommended)
sudo apt update && sudo apt upgrade -y
sudo apt install smartmontools -y
# Create mount point
sudo mkdir /mnt/ssd
sudo blkid # Note UUID
sudo nano /etc/fstab
Add to fstab:
UUID=<YOUR-UUID> /mnt/ssd ext4 defaults,nofail,noatime,data=ordered 0 2
sudo mount -a
sudo apt install apache2 mariadb-server php-fpm php php-mysql php-cli \
php-curl php-zip php-gd php-xml php-mbstring php-intl php-bcmath \
php-imagick php-redis redis-server unzip ufw -y
sudo mysql_secure_installation
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'strong-password-here';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
sudo nano /etc/php/*/fpm/php.ini
Add:
memory_limit = 512M
upload_max_filesize = 16G
post_max_size = 16G
max_execution_time = 3600
max_input_time = 3600
opcache.enable=1
opcache.memory_consumption=128
sudo nano /etc/apache2/sites-available/nextcloud.conf
<VirtualHost *:80>
DocumentRoot /var/www/nextcloud
ServerName your.domain.com
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=31536000"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
</IfModule>
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=31536000"
</IfModule>
</VirtualHost>
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime ssl
sudo systemctl restart apache2
cd /tmp
wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
sudo mv nextcloud /var/www/
sudo chown -R www-data:www-data /var/www/nextcloud/
sudo chmod -R 750 /var/www/nextcloud/
sudo apt install samba -y
sudo nano /etc/samba/smb.conf
Add:
[SSD]
path = /mnt/ssd
browseable = yes
writable = yes
read only = no
create mask = 0660
directory mask = 0750
public = no
valid users = @smbgroup
sudo groupadd smbgroup
sudo usermod -aG smbgroup $USER
sudo smbpasswd -a $USER
sudo systemctl restart smbd
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 445/tcp
sudo ufw enable
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache
sudo systemctl enable apache2
sudo systemctl enable mariadb
sudo systemctl enable smbd
sudo systemctl enable redis-server
# Setup SMART monitoring
sudo smartctl -a /dev/sdX # Replace X with your drive letter
sudo nano /etc/smartd.conf
Add:
/dev/sdX -a -o on -S on -s (S/../.././02|L/../../6/03) -m [email protected]
sudo systemctl enable smartd
sudo systemctl start smartd
- Nextcloud: http://<Raspberry_Pi_IP>
- Samba: \RASPBERRY-PI-IP\SSD
- Monitor logs:
sudo tail -f /var/log/apache2/error.log
- Check disk health:
sudo smartctl -H /dev/sdX
- Backup Nextcloud: Enable automated backups in Nextcloud admin settings