How to set up NextCloud
I’ve recently become interested in hosting more of my own data. Maybe I’ll post more about it sometime. Briefly, I’m using Tailscale to connect my devices, and running an Urbit ship. I wanted to host my own files as well, and ran across Nextcloud and decided to set it up.
Below are a compilation of instructions to make it easy on myself when I inevitably need to set everything up again.
- Follow instructions at NextCloud website to install dependencies.
- I needed to additionally install
sudo apt install libapache2-mod-php7
to get the GUI working. source
- Set up MariaDB.
- Install:
sudo apt install mariadb-server
- Initialize and launch MariaDB/MySQL server:
sudo mysql_secure_installation
- Allow standard login to the DB:
sudo mysql # Opens MySQL shell. > UPDATE mysql.user SET plugin = '' WHERE plugin = 'unix_socket'; > FLUSH PRIVILEGES;
- Follow instructions at NextCloud website to install via the GUI.
A series of commands that may work are as follows (on Ubuntu 20.04):
INSTALL_PATH=/var/www
# Check https://nextcloud.com/install/#instructions-server for newest versions.
CURRENT_VERSION=nextcloud-21.0.2.zip
APT_MODULES='mariadb-server apache2 php7.4 libapache2-mod-php7 ffmpeg'
# Not certain about all these PHP modules.
PHP_MODULES='ctype curl dom gd iconv json mbstring posix session xml zip zlib mysql fileinfo bz2 intl ldap smbclient ftp imap bcmap gmp exif imagick'
wget https://download.nextcloud.com/server/releases/${CURRENT_VERSION}
unzip $CURRENT_VERSION
sudo cp -r nextcloud ${INSTALL_PATH}
sudo apt update && sudo apt upgrade && sudo apt dist-upgrade && sudo apt autoremove && sudo apt install ${APT_MODULES}
for phpmod in ${PHP_MODULES}; do sudo apt install php7.4-${phpmod}; done
sudo mysql_secure_installation
sudo mysql # Opens MySQL shell.
> UPDATE mysql.user SET plugin = '' WHERE plugin = 'unix_socket';
> FLUSH PRIVILEGES;
sudo cat >> /etc/apache2/sites-available/nextcloud.conf << EOF
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
Satisfy Any
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
EOF
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 restart
sudo chown -R www-data:www-data ${INSTALL_PATH}/nextcloud