- Apache Installation and PHP enabled
- MariaDB Installation
- Log in as root or have sudo privledges
ssh root@hostname.com
Step 2: Then log in to your MySQL/MariaDB instance by typing:
mysql
You’ll see the prompt change, and you’ll then be able to use MySQL commands to make a database and grant permissions.
MariaDB [(none)]>
Replace the highlighted password below, with a secure password. You can tell the commands were accepted because it’ll show a “Query OK, 0 rows affected (0.00 sec)” message after each command. Be sure to have the password for the Nextcloud user handy; we’ll be using it later in this tutorial.
CREATE DATABASE nextcloud;
CREATE USER nextcloud IDENTIFIED BY 'password';
GRANT USAGE ON *.* TO nextcloud@localhost IDENTIFIED BY 'password';
GRANT ALL privileges ON nextcloud.* TO nextcloud@localhost;
FLUSH PRIVILEGES;
quit;
Install Nextcloud Modules
You’ll need specific modules installed for NextCloud to work, within your terminal, install the modules using the apt install command. Press Y to continue when prompted.apt install php-gd php-json php-mysql php-curl php-mbstring
apt install php-intl php-imagick php-xml php-zip
Install NextCloud
Finally, we’ll download and extract NextCloud’s files. You can then move it over to the destination of your choice, for our tutorial, we’ll move it to our default document root, /var/www/html. Step 1: Download the Nextcloud package.wget https://download.nextcloud.com/server/releases/nextcloud-15.0.7.tar.bz2
Step 2: Extract the Nextcloud package.
tar -xvf nextcloud-15.0.7.tar.bz2
Step 3: Move Nextcloud core files over to Apache’s root directories.
cd nextcloud
mv ./* /var/www/html
mv ./.htaccess /var/www/html
mv ./.user.ini /var/www/html
cd /var/www/html
Step 4: Make a directory within the /var/www/html folder for Nextcloud storage.
mkdir /nextcloud-data
Step 5: Nextcloud is run by Apache and uses www-data as the user, therefore, you’ll need to change over the permissions and ownership.
chown -R www-data:www-data ./*
chown -R www-data:www-data .htaccess
chown -R www-data:www-data .user.ini
chown www-data:www-data /nextcloud-data
Step 6: Restart Apache for the changes to take effect.
systemctl restart apache2
Step 7: Verify Nextcloud is working by visiting it in your browser at http://your_ip/index.php. Creation of the admin account is necessary, as well as setting the folder/directory (nextcloud-data) that NextCloud will store its uploads.

Note
At this point, it’s a good idea to put encryption on your NextCloud installation. Though it’s not required adding an SSL on your site protects passwords from being viewed by any 3rd party.
- Create an Account with username; we are using admin.
- Data folder should be /nextcloud-data
- Username and password should be the ones for MySQL that were made earlier, leave the setting on localhost.
- Click Finish
