This tutorial shows you how to install NextCloud on Ubuntu 20.04 LTS with the Apache web server.

What is the NextCloud?

NextCloud is a free, open source, self-hosting cloud storage solution. It is functionally similar to the Dropbox. Own cloud storage solutions (Dropbox, Google Drive, etc.) are convenient but affordable: They may be used to collect personal information because your files are stored on their computers. If you are concerned about privacy, you can switch to the NextCloud, which can be installed on your own private server or on a virtual private server (VPS). You can upload files to your server via NextCloud and then synchronize them with your desktop, laptop or smartphone. This way you have full control over your data.

NextCloudFeatures

  • Free and open source
  • End-to-end encryption, which means that files on client devices can be encrypted before they are uploaded to the server so that even if someone steals your server, he or she cannot read your files.
  • It integrates with Collobora Online (OnlyOffice), allowing you to create and edit Doc, ppt and xls files directly from NextCloud.
  • The App Store contains hundreds of applications designed to enhance functionality (for example, a calendar application, a contact application, a recording application, a videoconferencing application, etc.).
  • The synchronization client is available for Linux, MacOS, Windows, iOS and iroid.

Requirements

NextCloud is written in the programming language PHP. To follow this manual, you must first install the LAMP battery on Ubuntu 20.04. If you have not already done so, please read the following manual.

You can install NextCloud on your home server or on a VPS (Virtual Private Server). You will also need a domain name so that you can later activate HTTPS to encrypt HTTP traffic. I registered my domain name with NameCheap because the price is low and they offer free Whois privacy for life.

Now we install NextCloud.

Step 1: DownloadNextCloud on Ubuntu 20.04

Connect to the Ubuntu 20.04 server. Then download the NextCloud Zip archive to your server. At the time of writing, the latest stable release is 18.0.4. You may need to change your version number. Go to https://nextcloud.com/install and click on Download for Server to see the latest version.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

You can run the following command to download it to your server.

Mailbox https://download.nextcloud.com/server/releases/nextcloud-18.0.4.zip

You can still use the URL format above to download the NextCloud. When a new version is released, simply replace 18.0.4 with a new version number.

Unpack the archive after downloading.

sudo apt zip adjustment

sudo decompresses the following file cloud-18.0.4.zip -d /var/www/

The -d option specifies the target folder. NextCloud web files are decompressed in /var/www/nextcloud/. Then we need to change the owner of this directory to www-data, so that a web server (Apache) can write data to it.

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

Step 2: Create a database and a user for Nextcloud on the MariaDBdatabase server .

Connect to the MariaDB database server with the following command. Since MariaDB now uses the unix_socket plugin to authenticate the user, it is no longer necessary to enter the MariaDB root password. Just give the mysql sudo command prefix.

Ship’s vehicle

Then create a database for Nextcloud. This tutorial will take the database to the next cloud. You can use any name you want.

to create a database in the next cloud;

Create a database user. You can also use your preferred name for this user. Replace your password with the one you want.

Create a user [email protected] identified by your password;

Give this user full rights in the next cloud database.

make all privileges of nextcloud.* available to [email protected], identified by your password;

Privilege and flash output.

to relinquish those privileges;

A way out;

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Step 3: Creating an Apache Virtual Host for the Nextcloud

Create the nextcloud.conf file in /etc/apache2/sites-available/, using a command line text editor like Nano.

sudo nano /etc/apache2/sites-available/nextcloud.conf

Copy the following text and paste it into the file Replace nextcloud.example.com with your favorite subdomain Don’t forget to create a DNS A record for this subdomain in the DNS zone editor. If you don’t have a real domain name, I advise you to go to NameCheap and buy it. The price is low and they allow you to protect your privacy for free for the rest of your life.

DocumentRoot /var/www/nextcloud
ServerName nextcloud.example.com

Error Log ${APACHE_LOG_DIR}/nextcloud.error
Custom log ${APACHE_LOG_DIR}/nextcloud.access combined.

Requires all options if
+ MultiView
Icons All options are required

Dev part

SetEnv HOME /var/wwwww/next cloud
SetEnv HTTP_HOME /var/wwww/next cloud
Possible Satisfaction

 

 

Save the file and close it. (To save the file in the NANO editor, press Ctrl+O and then press Enter to confirm. Press Ctrl+X to exit)

Then turn on this virtual host.

sudo a2ensite nextcloud.conf

To enable the required Apache modules, follow the command below.

sudo a2enmod rewrite headings and dir mime setenvif ssl

Then check the Apache configuration.

sudo apache2ctl -t

If the syntax is correct, restart Apache to allow the changes to take effect.

sudo systemctl restart apache2

Step 4: Installation and activation of PHP modules

To install the PHP modules required or recommended by NextCloud, execute the following commands.

install sudo apt php7.4-common php7.4-mysql php7.4-fpm php7.4-json php7.4-curl php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl.

Reboot Apache to use these modules.

sudo systemctl restart apache2

Step 5: HTTPSactivate

You can now start the Nextcloud installation wizard in your web browser by entering the domain name to install the Nextcloud.

nextcloud.example.com

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

If a web page cannot be loaded, you may need to open port 80 in the firewall.

sudo iptables – I INPUT -p tcp –dport 80 -j ADOPTION

And Port 443 too.

sudo iptables -I INPUT -p tcp –dport 443 -j ACCEPT

Before entering sensitive information, we need to activate a secure HTTPS connection to the Nextcloud. We can get a free TLS certificate at Let’s Encrypt. Install the encryption client (certbot) of the Ubuntu 20.04 repository.

install sudo apt certbot python3-certbot-apache

Python3-certbot-apache is an Apache plugin. Then run the following command to get a free TLS certificate with the Apache plugin.

sudo certbot –apache –agree-tos –redirect –staple-ocsp –email [email protected] -d nextcloud.example.com

True:

  • -Parrot2 : Use an Apache authenticator and installer.
  • -agri-tos: Okay, let’s encrypt the terms of use.
  • -directly: Implement HTTPS by adding 301 Redirect.
  • -stack-okr: Activate OCSP stapling.
  • -E-mail: Email used to store and restore contacts.
  • the -d flag is accompanied by a list of domain names separated by commas. You can add up to 100 domain names.

You will be asked if you want to receive e-mails from the EFF (Electronic Frontier Foundation). After selecting Y or N, your TLS certificate will be automatically received and configured for you as indicated in the following message.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

I noticed that Certbot cannot automatically add an HSTS header to an Apache configuration file for the Next Cloud. To enable STEH (HTTP Strict Transport Security), edit the file.

sudo nano /etc/apache2/sites enabled/nextoud-le-ssl.conf

We can then add the following line to the SSL server block to activate the HSTS header.

The title is always fixed Strict transport safety Maximum age=31536000

It’s just like downstairs.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Save the file and close it. Then send text with Apache configurations.

sudo apache2ctl -t

If the test was successful, Apache will restart to implement the changes.

sudo systemctl restart apache2

The above configuration gets an A+ rating when testing SSL.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Step 6: Complete the installation in the web browser

Via an HTTPS connection you now have access to the Nextcloud Configuration Wizard.

https://nextcloud.example.com

To complete the installation, you must create an administrator account, enter the path to the Nextcloud data folder, and enter the data for the database you created in step 2. You can use localhost as the default host address, or enter localhost:3306 if MariaDB is listening on port 3306.

A data folder is a folder in which user files are stored. For security reasons, it is best to place the data folder outside the folder of your Nextcloud web browser. So, instead of saving user files in /var/www/nextcloud/data/, we can change them to /var/www/nextcloud-data/ :

sudo mkdir /var/www/nextcloud-data

Then make sure that the Apache user (www-data) has permission to write to the data folder.

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

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Click on the Finish button, you will see the Nextcloud web interface. Congratulations! You can start using it as private cloud storage.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Implementation of NextCloud e-mail notification

If your NextCloud instance is to be used by more than one person, it is important that your NextCloud server can send transactional emails, such as B. Password reset e-mails. You must first set up an email address for your account. Go to Settings -> Personal information and set up an email address for your account.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Then go to Settings -> Basic Settings. Here you will find the settings of the mail server. There are two ways of sending: sendmail and smtp. You can select the Sendmail mode if your NextCloud host manages an SMTP server.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

If you want to use an SMTP server running on a different host, select the smtp mode and enter the SMTP server address and connection details as shown below Select STARTTLS for encryption.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

The following tutorial explains how to configure the mail server:

How to move the data catalog

If you need to move the NextCloud data folder, you need to follow 4 steps. You must first use the cp command to copy a data folder to a new folder. For example, the mounting point of my external hard drive is /media/linuxbabe/b43e4eea-9796-4ac6-9c48-2bcaa46353731. I’m creating a new data folder on my external hard drive.

sudo mkdir /media/linuxbabe/b43e4eea-9796-4ac6-9c48-2bcaa46353731/nextcloud data/

Then I copy the original datamap to the new datamap. The -R indicator means that the copy operation is recursive.

sudo cp /var/www/nextcloud-data/* /media/linuxbabe/b43e4eea-9796-4ac6-9c48-2bcaa46353731/nextcloud-data/ -R

You also need to copy the .ocdata file.

sudo cp /var/wwww/nextcloud-data/.ocdata /media/linuxbabe/b43e4eea-9796-4ac6-9c48-2bcaa46353731/nextcloud-data/

Then you as the owner must install www-data (Apache user).

sudo chown wwww-data: www-data /media/linuxbabe/b43e4eea-9796-4ac6-9c48-2bcaa46353731/nextcloud-data/ -R

Finally, you need to edit the config.php file.

sudo nano /var/wwwww/nextcloud/config/config.php

Find the next line and change the value of the data folder.

Data directory => ‘/var/www/nextcloud-data’,

Save the file and close it. Restart the NextCloud website and you’re done.

Step 7: Increasing the PHP memory limit

The default memory limit for PHP is 128 MB. NextCloud recommends 512MB for best performance. To change PHP’s memory limit, edit the php.ini file.

ship nano /etc/php/7.4/apache2/php.ini

Find the next line. (line 409)

Memory_Limit = 128M

Change the value.

Memory_Limit = 512M

Save the file and close it. You can also use the following command to change the value without opening the file manually.

sudo sed -i ‘s/memory_limit = 128M/memory_limit = 512M/g’ /etc/php/7.4/apache2/php.ini

Then restart Apache to make the changes take effect.

sudo systemctl restart apache2

If you have /etc/php7.4/fpm/php.ini on your server, this means that PHP-FPM is also running on your server. I also recommend changing the memory limit in PHP-FPM.

ship nano /etc/php/7.4/fpm/php.ini

Find the parameter memory_limit and change the value. After saving the file, restart PHP-FPM for the changes to take effect.

sudo systemctl Restart php-fpm

Step 8: Redis Cache Setup for NextCloud

When you go to the NextCloud -> Overview Settings page, you will see the following warning message

The cache isn’t set up. To improve performance, please configure memcache if available.

We will enable storage caching for the next Cloud using Redis. To install the Redis server from the Ubuntu repository, run the following command.

install sudo apt redis server

You can also use the :

Radish server – in

Taking samples:

Redis server v=5.0.7 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=636cde3b5c7a3923

We can now verify that the redis server is working.

Change of system status

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Here’s a hint: If the above command is not executed immediately, you can press the Q key to regain control of the terminal.

In the screenshot above you can see that it works and that the auto-run function is enabled. If this does not work for any reason, execute the following command:

sudo systemctl start redis server

And if Autorun is not turned on at startup, you can use the following command to turn it on:

sudo systemctl sudo systemctl redis server activation

To configure Redis as cache for nextCloud, we need to install the PHP extension to communicate with Redis.

sudo apt installation php-redis

Make sure the extension is activated.

php –ri redis

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

You can see that the redis extension has been activated. If it is not activated, execute the following command:

sudo phpenmod redis

You may also need to restart Apache if the redis extension is still not enabled.

sudo systemctl restart apache2

Then edit the following Cloud configuration file.

sudo nano /var/wwwww/nextcloud/config/config.php

Add the following lines above the end); line.

memcache.local => OCMemcacheRedis,
memcache.locking => OCMemcacheRedis,
redis => array(
host => localhost,
port => 6379,
),

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Save the file and close it. Then restart Apache and PHP-FPM.

sudo systemctl reboot apache2 php7.4-fpm

Now go back to the NextCloud -> Preview page and refresh the website, there should be no warning about memory caching.

Addition of missing indexes

If you see the following message on the NextCloud -> Overview settings page,

Some indexes are missing from the database. Because adding indexes to large tables could take some time, they were not added automatically.

You will then have to add these indexes manually. Go to the Nextcloud web directory.

cd /var/www/nextcloud/

To add indexes to the Nextcloud database, execute the following command.

ship -u www-data php ok db:add-miss indications

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

If you now refresh the NextCloud Settings -> Overview page, the warning about missed indexes should disappear.

Conversion to large Int

If you see the following message on the NextCloud -> Overview settings page,

In some columns of the database there is no conversion to big int. Because changing column types for large tables could take some time, they did not change automatically.

You will then have to change the column type manually. Go to the Nextcloud web directory.

cd /var/www/nextcloud/

Put Nextcloud in maintenance mode to prevent users from logging in and making changes.

sudo -u www-data php occasional service: –on mode

Then execute the following command to change the column type.

ship -u www-data php ok db:convert-filecache-bigint

Once this is done, switch off the maintenance mode.

sudo -u www-data php Occasional maintenance: -off mode

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

If you now update the NextCloud Settings -> Overview page, the large int int alert should disappear.

How to install the NextCloud client on Ubuntu 20.04 Desktop

To install the client from the default repository, run the following commands on the Ubuntu 20.04 desktop

Installing the sudo apt nextcloud client

NextCloud customer on Ubuntu 20.04

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Client software for macros, Windows, Android and iOS can be found on the Nextcloud download page.

How to activate only the Office/Online Collaboration

By default, NextCloud is compatible with OnlyOffice, an online office suite that makes it possible to edit Doc, ppt and XLS files directly from NextCloud. Just install the application to use this function. Go to Nextcloud Applications -> Desktop and Text. Find and activate the Community Document Server application.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Now that you click the Add (+) button in Nextcloud, you can create Word documents, spreadsheets and presentations directly from your Nextcloud server.

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

Install NextCloud to Ubuntu 20.04 with Apache (LAMP Stack)

However, I have established that this request is not very reliable. And community editors only allow a maximum of 20 users. You must purchase a Corporate Edition if you have more than 20 users. There is another open office package based on LibreOffice, called Collabora Online. It has the same characteristics, but without any limitation on the number of users. You can read the following article to integrate it into Nextcloud

Increasing the limit for the size of files to be downloaded

If you use an Apache PHP module to run PHP scripts, there is no limit to the size of the downloaded file. If you use PHP-FPM to execute a PHP script, you must change the file size limit. By default, the maximum size of the downloadable files in PHP-FPM is 2 MB. To increase the size of the downloaded file, edit the PHP configuration file

ship nano /etc/php/7.4/fpm/php.ini

Find the next line (line 846).

upload_max_file size = 2M

Change the value as shown below:

Maximum size of the file to download = 1024M

Save the file and close it. You can also use the following command to change the value without opening the file manually.

sudo sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 1024M/g’ /etc/php/7.4/fpm/php.ini

Then restart PHP-FPM.

reboot sudo systemctl php7.4-fpm

HTTP/2 protocol activation

The HTTP/2 protocol can significantly increase the loading speed of the pages. You can read the following manual to enable the HTTP/2 protocol in Apache.

Troubleshooting Tips

If you encounter errors, you can check one of the following log files to find out what’s wrong

  • Apache error log: /var/log/apache2/error.log
  • Apache error log for Nextcloud virtual host: /var/log/apache2/nextcloud.error
  • Application Log Next Cloud: /var/www/nextcloud/data/nextcloud.logbook

Packaging

I hope this tutorial helped you install NextCloud on the Ubuntu 20.04 server with Apache. As always, if you find this message useful, subscribe to our free newsletter for more tips and tricks. Take care of yourself.

Evaluate this training manual.

On second thought: 0 Average : 0]ubuntu install nextcloud client,nextcloud occ maintenance:install