Connect to your Server via SSH:
ssh user@your_server_ip
Update Package Lists:
sudo apt update
Install Required Packages:
sudo apt install apache2 mariadb-server libapache2-mod-php7.4 \
php7.4-gd php7.4-json php7.4-mysql php7.4-curl \
php7.4-mbstring php7.4-intl php7.4-xml php7.4-zip unzip
Secure MariaDB Installation:
sudo mysql_secure_installation
Create Database for Nextcloud:
sudo mysql -u root -p
CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Download and Extract Nextcloud:
wget https://download.nextcloud.com/server/releases/latest.zip
sudo unzip latest.zip -d /var/www/
sudo chown -R www-data:www-data /var/www/nextcloud/
Configure Apache for Nextcloud:
sudo nano /etc/apache2/sites-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Options +FollowSymlinks
AllowOverride All
Require all granted
<IfModule mod_dav.c>
Dav off
</IfModule>
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</Directory>
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
Enable HTTPS (Optional but recommended):
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo systemctl restart apache2
Finish Installation via Web Interface:
- Open your browser and go to
https://your_server_ip/nextcloud
- Follow the installation wizard, providing database details created earlier.
Finalize Installation:
- After installation, follow on-screen instructions to create an admin account and configure data storage.
That’s it! Nextcloud should now be installed and ready to use on your minimal Linux server.