Install Nextcloud Ubuntu.Nextcloud is a client server software that provides storage services such as Google Drive, Dropbox and other Storage services. You can save files or data to be accessed via the internet anytime and anywhere. Not only that, you can also share these files with your friends or relatives.
Actually the Storage Cloud built by Dropbox and Google Drive is convenient, but it is limited by the quota limit in their storage and your personal data is stored on their servers. If you want your data to be more private, only you know, you can install Nextcloud privately or on your virtual server. This way you have full control over your data. Here we will share the step-by-step documentation for Install Nextcloud
Nextcloud Features
- File sync and file share
- NextCloud talk
- Co-working management
- Desktop and mobile clients
- Open source
System Requirements Install Nextcloud
Nextcloud needs a minimum
- OS Ubuntu 20.04
- PHP 7.2 | PHP 7.4
- Hardisk 50 GB
- Ram 512 MB
- WEB Apache 2.4
- Database MySQL atau MariaDB
Nextcloud is built using the PHP programming language. and if you want to follow this tutorial you should first install LAMP. For the LAMP tutorial, see the tutorial link below.
Step 1: Download Nextcloud Latest Version
Before going into How to Install Nextcloud Ubuntu 20.04 Apache2, we will first download the Nextcloud file package that will be installed. Visit NextCloud official site and you can download the version you want, it is best to download the latest stable version. after the download is complete, then we can install nextcloud
Note: For NextCloud Server, Download “Download for Server”.
Login to your server and do the following command
cd /home
wget https://download.nextcloud.com/server/releases/nextcloud-22.2.0.zip
unzip nextcloud-22.2.0.zip
Move the unzipped nextcloud folder to the apache folder in /var/www/html
mv nextcloud /var/www/html/
Change the permissions of the nextcloud directory to www-data so that the webserver (apache2 ) can write/read in that folder. Follow these commands.
chown -R www-data:www-data /var/www/html/nextcloud/
Step 2: Create Nextcloud Database
Here’s the name, user and password that we will use, friends, you can install MySQL 8 at the following link: Installasi MySQL 8
Database : NextcloudDB
Username : NextcloudUser
Password : NextcloudPass
Enter the root database server with the following command
sudo mysql -u root -p
Then create a database for Nextcloud
CREATE DATABASE NextcloudDB;
Create a database user that will be used to login to the database.
CREATE USER 'NextcloudUser'@'localhost' IDENTIFIED BY 'NextcloudPass';
After that, create user access rights create, update, delete user into the database.
GRANT ALL PRIVILEGES ON NextcloudDB.* TO'NextcloudUser'@'localhost';
Reload Database and Exit
flush privileges;
exit
Step 3: Create Apache Virtual Server for NextCloud
By using a Virtual Host you can manage many websites and domains on one server. By using Virtualhost, you can install two or more Nextcloud on the same server, of course with different domains. Perform the following configuration to continue Install Nextcloud
Create a file nextcloud.conf in /etc/apache2/sites-available/
nano /etc/apache2/sites-available/nextcloud.conf
Copy the text below and replace dixmata.com with your domain name. Then Save Ctrl + X select Y then Enter
<VirtualHost *:80> DocumentRoot "/var/www/html/nextcloud" ServerName dixmata.com ErrorLog ${APACHE_LOG_DIR}/nextcloud.error CustomLog ${APACHE_LOG_DIR}/nextcloud.access combined <Directory /var/www/html/nextcloud/> Require all granted Options FollowSymlinks MultiViews AllowOverride All <IfModule mod_dav.c> Dav off </IfModule> SetEnv HOME /var/www/html/nextcloud SetEnv HTTP_HOME /var/www/html/nextcloud Satisfy Any </Directory> </VirtualHost>
Activate the nextcloud.conf configuration that was created earlier.
a2ensite nextcloud.conf
Then reload apache2
systemctl reload apache2
Now you can open a browser and type in the domain name that was created earlier or you can use your server ip-address. Here we use the domain http://dixmata.com
IP-Address
Or
http://yourdomain.com
Step 4: Configure Firewall (Install Nextcloud Ubuntu)
The firewall is a protection for computer network systems and other devices that are useful for protecting threats or harmful content from outside computers.
If the firewall on your server is not installed, you should install a firewall first, but the default for Ubuntu 20.04 already has a firewall. Check Here For Ubuntu Firewall
apt install ufw
Then activate the firewall, on the confirmation notification select Y.
ufw enable
Then see if the firewall is active.
ufw status
Allow all ports to be used such as Port 22(ssh), 80(http), 3306(mysql),433(https)
ufw allow 22 ufw allow 80 ufw allow 3306 ufw allow 443
and if all ports are allowed to be accessed from outside, reload the firewall
ufw reload
To see all the ports that have been opened, you can use the following command.
ufw status
root@dixmata:/home/dixmata# ufw status Status: active To Action From -- ------ ---- 22/tcp ALLOW Anywhere 80 ALLOW Anywhere 3306 ALLOW Anywhere 443 ALLOW Anywhere 22/tcp (v6) ALLOW Anywhere (v6) 80 (v6) ALLOW Anywhere (v6) 3306 (v6) ALLOW Anywhere (v6) 443 (v6) ALLOW Anywhere (v6)
Step 5: Enable NextCloud and Rewrite Module Apache2 (Install Nextcloud Ubuntu)
To install Nextcloud, we have to activate some Apache modules. Follow the following command to activate the modules in this Nextcloud install.
a2enmod rewrite a2enmod headers a2enmod env a2enmod dir a2enmod mime
Reload apache2 again
systemctl restart apache2
Step 6: Enable SSL For Domain
SSL/TLS certificates serve to secure sensitive information, such as personal data, payment or login information, during the transmission process.
For Complete Information and How to Install Let’s Encrypt
For SSL we use a FREE certificate from Let’s Encrypt. to use Let’s Encrypt, first Install Let’s Encrypt. follow the following command
systemctl restart apache2
Run the command below to get a free Let’s Encrypt SSL/TLS certificate.
sudo certbot --apache --agree-tos --redirect --staple-ocsp --email [email protected] -d dixmata.com
Note: Replace [email protected] with your email, and replace dixmata.com with your domain name
If you are asked to receive notifications, select Y. and once you get the certificate it will be auto-configured in your VirtualHost.
The results after generating ssl, look in the /etc/letsencrypt/live/domain_name/ folder. if you have entered the folder, see the contents of the folder.
ls -la
in the folder you will see the Certificate and Private Key of the domain that was generated earlier.
In the Apache2 VirtualHost that was created, include the location of the private-key and certificate above. Check in your virtualhost.
nano /etc/apache2/sites-available/nextcloud-le-ssl.conf
Then reload the apache web server
systemctl restart apache2
Now you can access nextcloud web using HTTPS connection
Step 7: Create Admin Account and Configure MySQL User (Install Nextcloud Ubuntu)
After all the Apache web server configurations have been completed, lastly we need to create an admin user for the NextCloud web, and enter the mysql user that was created in step 2 above.
Create User and Password for Nextcloud Admin. For security reasons, it is recommended not to use a user with admin, because it is prone to brute force by some irresponsible people
Then proceed with database configuration, fill in the database name, user and password that was created in step 2
Click Finish Setup, and you are taken to the Nextcloud Web home page. and now you can use it as your personal cloud storage tool.
Step 8: Add Nextcloud Users and Groups (Install Nextcloud Ubuntu)
If your Nextcloud is used by more than one person, then you must create a user and you can also group these users in one group.
Creating a Group on Nextcloud
Group is used to group several users so that users can be managed properly. Select Menu -> Users
On the left menu select +Add group, and create the desired group name
Creating a User on Nextcloud
In the options on the left screen of the Nextcloud page, select +New user. Fill in (user name, password, email, and group)
Step 9: Increase PHP Memory Limit (Install Nextcloud Ubuntu)
The default at the beginning of installing PHP, the memory limit is 128MB. For Nextcloud we recommend 512MB for better performance. To install nextcloud to change PHP memory limit, edit php.ini
nano /etc/php/7.4/apache2/php.ini
Search memory_limit, by means of CTRL + W and type memory_limit then Enter. Change memory_limit to 512MB
memory_limit = 512M
Save and Close, Alternatively, you can also use the following command
sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php/7.4/apache2/php.ini
Then reload Apache to see the changes
systemctl reload apache2
If your server has the /etc/php7.4/fpm/php.ini
file, that means your server also runs PHP-FPM. I recommend changing the memory_limit
in PHP-FPM as well.
nano /etc/php/7.4/fpm/php.ini
Look for the memory_limit parameter and change its value. after saving the file, reload PHP-FPM for the changes to take effect.
systemctl reload php7.4-fpm
Step 10: Konfigurasikan Redis Cache untuk NextCloud
Redis is a cache server used to improve Nextcloud’s performance. Now we will enable cache memory for this Nextcloud Install, Run the command to install the Redis server.
apt install redis-server
check redis-server version
redis-server -v
Output Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=9435c3c2879311f3
Sekarang kita konfirmasi status Redis
systemctl status redis
If the Redis status is running, it will display like the output below.
Output * redis-server.service - Advanced key-value store Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-10-22 00:55:33 WIB; 6 days ago Docs: http://redis.io/documentation, man:redis-server(1) Process: 221 ExecStart=/usr/bin/redis-server /etc/redis/redis.conf (code=exited, status=0/SUCCESS) Main PID: 239 (redis-server) Tasks: 4 (limit: 153976) CGroup: /system.slice/redis-server.service `-239 /usr/bin/redis-server 127.0.0.1:6379 Oct 22 00:55:33 file systemd[1]: Starting Advanced key-value store... Oct 22 00:55:33 file systemd[1]: Started Advanced key-value store.
From the output above Redis has been running, so we can use it to Install Nextcloud Ubuntu. Run redis automatically when the server reboots or shuts down. Ikuti perintah berikut ini
systemctl enable redis-server
To configure Redis in Install Nextcloud Ubuntu, we need to install the PHP extension Redis.
apt install php-redis
Check extension
php --ri redis
Output redis Redis Support => enabled Redis Version => 5.3.2 Redis Sentinel Version => 0.1 Available serializers => php, json, igbinary
In the output above we can see that Redis is already enabled and if it is not enabled, follow the following command to do so.
phpenmod redis
After that do reload on Apache
systemctl reload apache2
After finishing installing and configuring Redis, now we will implement Redis Server into the Nextcloud Install Configuration. Go to the Install Nextcloud directory /var/www/nextcloud/config/config.php and edit the config.php file
nano /var/www/nextcloud/config/config.php
And follow the following configuration
'memcache.distributed' => '\OC\Memcache\Redis', 'memcache.local' => '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => 'localhost', 'port' => 6379, ),