📘 Nextcloud
These instructions assume you have already set up a raspberry pi with Raspberry OS. I used a Raspberry Pi 3 B+.
They also assume that you are using a subdomain and that you've pointed the subdomain at your Raspberry Pi's public IP and open up the port for it to get through your network.
Set up Apache
sudo apt install apache2
sudo usermod -a -G www-data [yourusername]
sudo chown -R -f www-data:www-data /var/www
sudo chmod -R 770 /var/www/html
Set up MySQL
sudo apt install mariadb-server
sudo mysql_secure_installation
Set up database
mysql -u root -p
Within mysql, run the following:
CREATE DATABASE nextclouddb;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON nextclouddb.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
quit
Install PHP 8.1
Nextcloud requires PHP 8.1, however Raspberry OS still runs PHP 7.4, so a little more work goes into installing it.
wget -q https://packages.sury.org/php/apt.gpg -O- | sudo tee /etc/apt/trusted.gpg.d/php.gpg
echo "deb https://packages.sury.org/php/ bullseye main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update
sudo apt install php8.1 php8.1-gd php8.1-sqlite3 php8.1-curl php8.1-zip php8.1-xml php8.1-mbstring php8.1-mysql php8.1-bz2 php8.1-intl php8.1-smbclient php8.1-imap php8.1-gmp php8.1-bcmath libapache2-mod-php8.1
Get Nextcloud
sudo wget https://download.nextcloud.com/server/releases/latest.tar.bz2
cd /var/www
sudo tar -xvf latest.tar.bz2
sudo mkdir nextcloud/data
sudo chown -R www-data:www-data nextcloud
sudo chmod 750 nextcloud/data
Set up Apache
Create /etc/apache2/sites-available/nextcloud.conf with the following contents:
<VirtualHost *:80>
ServerName nextcloud.domain.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/nextcloud
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME}=nextcloud.domain.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
Enable it:
sudo a2ensite nextcloud
Set up a certificate
sudo apt install python3-certbot-apache -y
sudo certbot --apache -d nextcloud.domain.com
Answer the questions and it will auto set up the cert and restart apache for you
Finish Nextcloud setup
- Go to your domain, which should provide you with a Nextcloud setup screen.
- Fill in the username/password and click Storage & Database then click MySQL/MariaDB.
- Fill in the database details you set up earlier
- Click Finish Setup
After it finishes, you should have a working Nextcloud instance!
Post 008/100 of #100DaysToOffload
👋 Hey! Thanks for reading! If you have any comments or questions about this post, or anything else, I'd love to chat! You can find the best way to contact me on my hello page or send me an email.