Skip to content

Installing Nextcloud on Ubuntu 24.04 (Non-Docker)

(written April 2024)

This guide walks through installing Nextcloud on a fresh Ubuntu 24.04 virtual machine using Apache, MariaDB, and PHP, without Docker. This setup is ideal for users running a homelab, particularly on Proxmox.


Prerequisites


VM Configuration (Proxmox)

  • Base OS: Ubuntu 24.04 Server
  • CPU: 2 Cores (minimum)
  • RAM: 2GB (4GB recommended)
  • Disk: 32GB+ (more for large file storage)
  • Network: Bridged mode with static IP (recommended)

System Preparation

1. Update system packages:

sudo apt update && sudo apt upgrade -y

2. Install required dependencies:

sudo apt install -y apache2 mariadb-server libapache2-mod-php \
php php-gd php-mysql php-curl php-mbstring php-intl php-gmp \
php-bcmath php-imagick php-xml php-zip unzip curl gnupg2

Configure MariaDB

1. Secure the installation:

sudo mysql_secure_installation

Use a strong root password and answer prompts to secure the DB.

2. Create database and user for Nextcloud:

sudo mariadb

Then within the MariaDB prompt:

CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'your_secure_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Download and Configure Nextcloud

1. Download Nextcloud:

cd /var/www/
sudo curl -LO https://download.nextcloud.com/server/releases/latest.zip
sudo unzip latest.zip
sudo chown -R www-data:www-data nextcloud
sudo chmod -R 755 nextcloud

Configure Apache

1. Create a new virtual host file:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Paste the following config (replace your.domain.com if needed):

<VirtualHost *:80>
    ServerName your.domain.com
    DocumentRoot /var/www/nextcloud/

    <Directory /var/www/nextcloud/>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
    CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>

2. Enable site and required modules:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime setenvif ssl
sudo systemctl reload apache2

Finalize Installation

  1. Navigate to http://your-server-ip or http://your.domain.com in a browser.
  2. Set your admin user and password.
  3. Enter the database info:

  4. User: nextclouduser

  5. Password: your_secure_password
  6. Database: nextcloud
  7. Host: localhost

Optional: Enable HTTPS with Let's Encrypt

If you have a domain and want HTTPS:

sudo apt install certbot python3-certbot-apache
sudo certbot --apache -d your.domain.com

Post-Install Tips

  • Set up cron for background jobs:
sudo -u www-data crontab -e

Add:

*/5 * * * * php -f /var/www/nextcloud/cron.php
  • Set PHP memory limit (optional):
sudo nano /etc/php/8.3/apache2/php.ini

Increase:

memory_limit = 512M
upload_max_filesize = 2G
post_max_size = 2G
  • Restart Apache:
sudo systemctl restart apache2