Nextcloud is an open-source file sync and sharing software that can be used as a replacement for Google Drive, Yandex Disk, and similar cloud-based storage. It is written in PHP and JavaScript and has support for MySQL, PostgreSQL, SQLite, and Oracle Database.
Install LAMP Stack
Install Apache2, MySql, and PHP.
apt install apache2 mysql-server php zip unzip libapache2-mod-php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-mysql php-bcmath php-gmp
Secure MySql
Run the command to secure MySql.
mysql_secure_installation
Create MySql User and Database
Login as a root user to MySQL console and create a new database for Nextcloud.
mysql -u root -p
Create a new database.
CREATE DATABASE nextcloud;
Create a new user.
CREATE USER 'nextcloud'@'localhost' IDENTIFIED BY 'PASSWORD';
Give the new user the necessary permissions.
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost';
Flush the privileges and exit the console.
FLUSH PRIVILEGES;
quit
Download Nextcloud
Download the latest Nextcloud from its official website.
cd /tmp
https://download.nextcloud.com/server/releases/nextcloud-20.0.7.zip
cd /var/www
unzip /tmp/nextcloud-20.0.7.zip
chown -R www-data: /var/www/nextcloud/
Configure Apache
Create a configuration file with an Alias to Nextcloud directory.
nano /etc/apache2/sites-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
<IfModule mod_dav.c>
Dav off
</IfModule>
</Directory>
Enable the site.
a2ensite nextcloud.conf
Enable the necessary Apache modules.
a2enmod rewrite headers env dir mime
Reload Apache.
systemctl reload apache2
Create a configuration file with a domain to Nextcloud directory.
nano /etc/apache2/sites-available/unihost.link.conf
<VirtualHost *:80>
ServerName unihost.com
ServerAdmin [email protected]
DocumentRoot /var/www/nextcloud
<directory /var/www/nextcloud>
Require all granted
AllowOverride All
Options FollowSymLinks MultiViews
SetEnv HOME /var/www/nextcloud
SetEnv HTTP_HOME /var/www/nextcloud
</directory>
</VirtualHost>
Enable the site.
a2ensite unihost.com
Reload Apache.
systemctl reload apache2
Run Nexctloud Web Installer
Now open your website or Nextcloud directory according to your configuration.
Enter new admin credentials to create an admin account and input the database credentials and click on Finish Setup.
After completing the setup you will get the admin dashboard.
Now install Nextcloud Agent on your end device to start syncing files.