This is an old revision of the document!
Download and Extract the Latest Version of NextCloud onto Ubuntu Server 22.04 having Apache2 Webserver
As of the time this article was posted (06-21-2023), the latest NextCloud version was 27.0.0.
Let's first plan and provision the NextCloud web space structure on the Ubuntu / Apache2 server.
Notice that the default website path for Apache2 is /var/www/html/
index.html is the default html test page that is contained in that directory in order to show whether the Apache2 webserver was correctly installed.
Suggestions as follow - Replacing 'dbusername' and 'yourdomain_com' etc., with your own choice of directory names
- Make and put the “/NextCloud/” website directory into a new path adjacent to the above default website path
- Example: /var/www/dbusername/public_html/yourdomain_com/nextcloud/
- Make and move the NextCloud “/data/” directory path outside but adjacent to the new website path
- Example: /var/www/dbusername/storage/yourdomain_com/data/
Use the Make Directory command 'mkdir' to create each of the subdirectories in those two paths shown in the list above. (Google 'examples of linux mkdir command' and learn how to do this). You can create whatever directory naming structure that you want for your NextCloud website path and your NextCloud data path, each starting below the /var/www/ level of the path. Recommend avoiding the default website path /var/www/html/ for each virtual host domain that you configure.
You might want to use mkdir command with the -p option (path create) and/or the -v option (verbose to have linux tell you each directory that was created). You should change the directory names appearing after “var/www/” in the path, to your choices of directory names, in the following Examples:
sudo mkdir -p -v var/www/dbusername/public_html/yourdomain_com/nextcloud sudo mkdir -p -v var/www/dbusername/storage/yourdomain_com/data
Next, download the latest version of NextCloud zip file into the subdirectory that is located one level above the /nextcloud/ subdirectory in the website path, i.e. the /yourdomain_com/ subdirectory.
Switch to the /yourdomain_com/ subdirectory as the current working directory.
sudo cd /var/www/dbusername/public_html/yourdomain_com/
Use the wget / curl command to download the latest NextCloud Release as a zip file to the current working directory. Change the release version number to the latest version number in the command below (or change it to the particular archived version number that you want to install).
sudo curl -o nextcloud.zip https://download.nextcloud.com/server/releases/nextcloud-27.0.0.zip
This should change the name of the downloaded file on your server from 'nextcloud-27.0.0.zip' to 'nextcloud.zip'
After downloading, check the name of the downloaded Zip file in current working directory using the 'ls' command to list files
At this point, make sure that the 'UnZip' package is installed to your linux distro. If not, then install it as follows:
sudo apt install unzip
Next, extract the Nextcloud source code from “nextcloud.zip” or from “nextcloud-27.0.0.zip” (whichever is the case) and you will get a new directory “nextcloud” (unless this “nextcloud” directory was already created as suggested above).
unzip nextcloud.zip
or
unzip nextcloud-27.0.0.zip
From the current domain_com directory (one directory level above the nextcloud directory), use the list command with -l option to check the ownership privileges and permissions of the “nextcloud” directory, and it should show ownership by root:root (user:group).
(code) cd /var/www/dbusername/public_html/yourdomain_com/
ls -l (/code)
Then, change the ownership privileges and permissions of the “nextcloud” directory to the “www-data” user and the “www-data” group (recursively '-R' to all files and subdirectories within and below the nextcloud directory), as follows.
chown -R www-data:www-data nextcloud
Switch to the storage '/yourdomain_com/' directory (one level above the /data/ directory) in order to check and change the permissions of the /data/ directory, as follows (adjust your directory names as necessary):
cd /var/www/dbusername/storage/yourdomain_com/ ls -l chown -R www-data:www-data data