Nextcloud Setup Summary – jrowenco.info
Full Nextcloud Setup Summary
Date: April 2025
System: Ubuntu 24.10.2 LTS
Domain: jrowenco.info (ports 80 and 443 open)
Web Server: Nginx with SSL (Let’s Encrypt)
Nextcloud Version: Latest as of April 2025 (likely 29 or higher)
TrueNAS SMB Share: zfs1 with subfolder nextcloud_storage
1. Base System Setup
Ubuntu: Fresh install of Ubuntu 24.10.2 LTS.
Updates:
sudo apt update && sudo apt upgrade -y
Firewall:
sudo ufw allow 80
sudo ufw allow 443
sudo ufw enable
2. Nginx and PHP Setup
Install Nginx:
sudo apt install -y nginx unzip curl
sudo systemctl start nginx
sudo systemctl enable nginx
Install PHP and Modules (PHP 8.3):
sudo apt install -y php-fpm php-common php-mysql php-gd php-json php-curl php-mbstring php-intl php-imagick php-xml php-zip php-bz2 php-bcmath php-gmp
sudo systemctl start php8.3-fpm
sudo systemctl enable php8.3-fpm
Nginx Config (/etc/nginx/sites-available/jrowenco.info):
sudo nano /etc/nginx/sites-available/jrowenco.info
Contents:
upstream php-handler { server unix:/run/php/php8.3-fpm.sock; } server { listen 443 ssl http2; server_name jrowenco.info; ssl_certificate /etc/letsencrypt/live/jrowenco.info/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/jrowenco.info/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; root /var/www/jrowenco.info; index index.php index.html; proxy_read_timeout 120; proxy_connect_timeout 120; proxy_send_timeout 120; fastcgi_read_timeout 120; location / { try_files $uri $uri/ /index.php?$args; } location ~ ^/(?:\.|data|config|db_structure\.xml|README) { deny all; } location ~ \.php(?:$|/) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass php-handler; fastcgi_index index.php; } client_max_body_size 512M; } server { listen 80; server_name jrowenco.info; return 301 https://$server_name$request_uri; }
Enable Config:
sudo ln -s /etc/nginx/sites-available/jrowenco.info /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
3. Database Setup (MariaDB)
Install MariaDB:
sudo apt install -y mariadb-server
sudo mysql_secure_installation
Create Database and User:
sudo mysql -u root -p
SQL Commands:
CREATE DATABASE nextcloud_db CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'your_secure_password'; GRANT ALL PRIVILEGES ON nextcloud_db.* TO 'nextcloud_user'@'localhost'; FLUSH PRIVILEGES; EXIT;
– Database: nextcloud_db
– User: nextcloud_user
– Password: (your secure password)
4. Nextcloud Installation
Download and Install:
cd /var/www
sudo curl -O https://download.nextcloud.com/server/releases/latest.zip
sudo unzip latest.zip
sudo rm latest.zip
sudo mv nextcloud jrowenco.info
Set Permissions:
sudo chown -R www-data:www-data /var/www/jrowenco.info
sudo chmod -R 755 /var/www/jrowenco.info
Web Setup:
– URL: https://jrowenco.info
– Admin User: (your admin username, e.g., admin
)
– Admin Password: (your admin password)
– Data Folder: /var/www/jrowenco.info/data
(default)
– Database: MySQL/MariaDB
- User:
nextcloud_user
- Password: (your secure password)
- Database:
nextcloud_db
- Host:
localhost
5. SSL Setup (Let’s Encrypt)
Install Certbot:
sudo apt install -y certbot python3-certbot-nginx
Generate Certificate:
sudo certbot --nginx -d jrowenco.info
– Redirect HTTP to HTTPS: Yes
6. TrueNAS SMB Share Integration
TrueNAS Share Details:
- IP:
192.168.1.3
- Share Name:
zfs1
- Subfolder:
nextcloud_storage
- SMB User:
zfs
- Password:
i2i
Install SMB Client (for testing):
sudo apt install -y smbclient php-smbclient
sudo systemctl restart php8.3-fpm
Mount Share Locally on Ubuntu:
sudo mkdir /mnt/truenas
sudo mount -t cifs //192.168.1.3/zfs1 /mnt/truenas -o username=zfs,password=i2i,uid=www-data,gid=www-data,dir_mode=0770,file_mode=0770
Verify:
sudo -u www-data ls /mnt/truenas/nextcloud_storage
– Should see test_dir
(created during testing).
Make Mount Permanent:
sudo nano /root/.smbcredentials
Contents:
username=zfs password=i2i
sudo chmod 600 /root/.smbcredentials
sudo nano /etc/fstab
Add:
//192.168.1.3/zfs1 /mnt/truenas cifs credentials=/root/.smbcredentials,uid=www-data,gid=www-data,dir_mode=0770,file_mode=0770 0 0
sudo mount -a
Add to Nextcloud as Local Storage:
– Go to Settings > External Storage.
- Folder Name:
TrueNAS_Share
- External Storage:
Local
- Configuration:
/mnt/truenas/nextcloud_storage
- Available for:
jeffo12
(or “All people”)
– Save and verify in Files section.
Rescan Files (if adding files directly on TrueNAS):
sudo -u www-data php /var/www/jrowenco.info/occ files:scan --all
7. Security and Optimization
Trusted Domains:
sudo nano /var/www/jrowenco.info/config/config.php
Add:
'trusted_domains' => array ( 0 => 'localhost', 1 => 'jrowenco.info', ),
Timeouts (adjusted for normal operation):
– Nginx (/etc/nginx/sites-available/jrowenco.info):
proxy_read_timeout 120; proxy_connect_timeout 120; proxy_send_timeout 120; fastcgi_read_timeout 120;
– PHP-FPM (/etc/php/8.3/fpm/php.ini):
max_execution_time = 120 max_input_time = 120
– PHP-FPM (/etc/php/8.3/fpm/pool.d/www.conf):
request_terminate_timeout = 120
Restart services:
sudo systemctl reload nginx
sudo systemctl restart php8.3-fpm
8. Backup Recommendations
Nextcloud Data:
- Directory:
/var/www/jrowenco.info/data
- TrueNAS Share:
/mnt/pool/zfs1/nextcloud_storage
Database:
sudo mysqldump -u root -p nextcloud_db > nextcloud_db_backup.sql
Config:
- File:
/var/www/jrowenco.info/config/config.php
9. Log Files for Troubleshooting
- Nextcloud:
/var/www/jrowenco.info/data/nextcloud.log
- Nginx:
/var/log/nginx/error.log
- PHP-FPM:
/var/log/php8.3-fpm.log
10. Notes
- The
SMB / CIFS
option in Nextcloud didn’t work reliably (configuration kept disappearing), so we used a local mount instead. - The
nextcloud_storage
subfolder was created on TrueNAS to keep Nextcloud files separate. - The
zfs
user on TrueNAS has read/write access tozfs1/nextcloud_storage
.
Overview: Mounting TrueNAS SMB Share
Date: April 2025
System: Ubuntu 24.10.2 LTS
TrueNAS Share: zfs1 (IP: 192.168.1.3)
Subfolder: nextcloud_storage
Mount Point: /mnt/truenas
Nextcloud Integration: Local storage
1. Install SMB Client (for Testing)
Installed required packages to test SMB connectivity:
sudo apt install -y smbclient php-smbclient
sudo systemctl restart php8.3-fpm
2. Test SMB Connectivity
Tested connection to TrueNAS share using the zfs
user:
smbclient -L //192.168.1.3 -U zfs
– Password: i2i
– Confirmed share zfs1
exists.
Tested subfolder access and created a test directory:
smbclient //192.168.1.3/zfs1 -U zfs -c 'cd nextcloud_storage; mkdir test_dir'
– Confirmed nextcloud_storage
exists and zfs
has write access.
3. Create Mount Point and Mount Share
Created mount point on Ubuntu:
sudo mkdir /mnt/truenas
Mounted the TrueNAS share temporarily:
sudo mount -t cifs //192.168.1.3/zfs1 /mnt/truenas -o username=zfs,password=i2i,uid=www-data,gid=www-data,dir_mode=0770,file_mode=0770
– uid=www-data,gid=www-data
: Ensures Nextcloud (running as www-data
) can access the mount.
– dir_mode=0770,file_mode=0770
: Sets permissions to read/write for owner and group.
Verified mount:
mount | grep /mnt/truenas
– Output: //192.168.1.3/zfs1 on /mnt/truenas type cifs ...
Verified subfolder access:
sudo -u www-data ls /mnt/truenas/nextcloud_storage
– Output: test_dir
4. Make the Mount Permanent
Created a credentials file for security:
sudo nano /root/.smbcredentials
Contents:
username=zfs password=i2i
sudo chmod 600 /root/.smbcredentials
Added mount to /etc/fstab
:
sudo nano /etc/fstab
Added:
//192.168.1.3/zfs1 /mnt/truenas cifs credentials=/root/.smbcredentials,uid=www-data,gid=www-data,dir_mode=0770,file_mode=0770 0 0
Tested:
sudo mount -a
– No errors, mount successful.
5. Integrate with Nextcloud
Added as Local
storage in Nextcloud (since SMB / CIFS
option was unreliable):
– Go to Settings > External Storage.
- Folder Name:
TrueNAS_Share
- External Storage:
Local
- Configuration:
/mnt/truenas/nextcloud_storage
- Available for:
jeffo12
(or “All people”)
– Saved and verified in Files section (saw test_dir
).
Rescan files if adding directly on TrueNAS:
sudo -u www-data php /var/www/jrowenco.info/occ files:scan --all
6. Notes
- The
nextcloud_storage
subfolder was created on TrueNAS to isolate Nextcloud files. - The
zfs
user on TrueNAS has read/write access tozfs1/nextcloud_storage
. - Used
Local
storage in Nextcloud becauseSMB / CIFS
kept failing (configuration disappeared after saving).