This instance of NextCloud will be installed on the server. If you wish to have it using Docker or Snap see the previous post [Link].

If you don’t have Apache + PHP + MySQL running follow these easy steps before starting with the NextCloud it self:

sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo systemctl start mysql && sudo systemctl enable mysql
sudo systemctl start apache2 && sudo systemctl enable apache2
sudo apt install php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl} -y
sudo apt install mysql-server -y
sudo systemctl start mysql && sudo systemctl enable mysql

Configuring Apache VHost

sudo nano /etc/apache2/sites-available/000-default.conf
<Directory /var/www/html/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews
  <IfModule mod_dav.c>
    Dav off
  </IfModule>
</Directory>
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2

Installing NextCloud

wget https://download.nextcloud.com/server/releases/nextcloud-29.0.3.zip
sudo apt install unzip -y
sudo rm -rf /var/www/html
sudo unzip nextcloud-29.0.3.zip -d /var/www/
sudo mv /var/www/nextcloud /var/www/html
sudo chown -R www-data:www-data /var/www/html/
sudo apt install php8.3-mysql php8.3-zip php8.3-dom php8.3-xml php8.3-gd -y

Get the latest at [Link].

MySQL Configuration

Create the database, create the user, give privileges, and flush MySQL privileges:

sudo mysql
CREATE DATABASE nextcloud_db;
CREATE USER nextcloud_user@localhost IDENTIFIED BY 'nextcloud_password';
GRANT ALL PRIVILEGES ON nextcloud_db.* TO nextcloud_user@localhost;
FLUSH PRIVILEGES;
EXIT;

UI Installation

Navigate to http://example.com and complete the installation on the web-ui.

Create the Admin account then, enter the credentials to the DB.

Feel free to install all the plugins to test them in a sandbox but avoid using them in production (publicly reachable) whenever possible.

Done!


BONUS

OwnCloud is another opensource alternative to NextCloud, try it out and see what suits better to your needs:

sudo apt install docker.io -y
sudo docker run --name OwnCloud --restart=unless-stopped -v /opt/OwnCloudData:/mnt/data/ -d -e OWNCLOUD_DOMAIN=owncloud.example.com:8080 -p80:8080 owncloud/server