User Tools

Site Tools


nextcloud

Nextcloud Server

1.0 --- MariaDB Database

To create a database and user, first login to the MariaDB shell by typing the following command:

sudo mysql

Run the following SQL statements to create a database named nextcloud, user named nextclouduser and to grant all necessary permissions to the user:

CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'change-with-strong-password';
FLUSH PRIVILEGES;
EXIT;

1.1 --- Apache & PHP

Nextcloud is a PHP application. PHP 7.2 which is the default PHP version in Ubuntu 18.04 is fully supported and recommended for Nextcloud. Run the following command to install Apache, PHP and all required PHP extensions:

sudo apt install apache2 apache2-utils php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php7.2-imagick php7.2-xml php7.2-zip libapache2-mod-php7.2 zip unzip

Assuming you are using UFW to manage your firewall, you’ll need to open HTTP (80) and HTTPS (443) ports. You can do that by enabling the ‘Apache Full’ profile which includes rules for both ports:

sudo ufw allow 'Apache Full'

After installing PHP 7.2, run the commands below to open PHP default config file for Apache2:

sudo nano /etc/php/7.2/apache2/php.ini

Then make the changes on the following lines below in the file and save. The value below are great settings to apply in your environments:

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 128M
upload_max_filesize = 100M
max_execution_time = 300
date.timezone = Asia/Dhaka

After installing PHP and related modules, all you have to do is restart Apache2 to reload PHP configurations:

sudo systemctl restart apache2

2.0 --- Nextcloud

At the time of writing this wiki, the latest stable version of Nextcloud is version 15.0.2. Before continuing with the next step visit the Nextcloud download page and check if there is a new version of Nextcloud available.

Start by download the latest version of Nextcloud using the following wget command:

wget https://download.nextcloud.com/server/releases/nextcloud-15.0.2.zip -P /tmp

Once the download is complete, extract the archive to the /var/www directory:

sudo unzip /tmp/nextcloud-*.zip  -d /var/www

Set the correct ownership so that the Apache web server can have full access to the Nextcloud’s files and directories:

sudo chown -R www-data: /var/www/nextcloud

2.1 --- Configure

Open your text editor and create the following Apache configuration file:

sudo nano /etc/apache2/conf-available/nextcloud.conf
Alias /nextcloud "/var/www/nextcloud/"

<Directory /var/www/nextcloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud

</Directory>

Enable the newly added configuration and all required Apache modules with:

sudo a2enconf nextcloud
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

Activate the changes by restarting Apache service:

sudo systemctl restart apache2

Now that Nextcloud is downloaded and all necessary services are configured open you browser and start the Nextcloud installation by visiting your server’s domain name or IP address followed by /nextcloud.

x.x --- References

nextcloud.txt · Last modified: 2019/02/04 19:47 by pi