How to Install Nextcloud on Ubuntu 22.04

How to Install Nextcloud on Ubuntu 22.04

Nextcloud is an open-source tool that allows you to store and share files online. In short, it is an open source cloud solution.

Install and configure Nextcloud on Linux ubuntu 22.04; Through this tutorial, we will learn how to install and configure Nextcloud on Linux ubuntu 22.04.

How to Install Nextcloud on Ubuntu 22.04

Steps to install and configure Nextcloud in Linux ubuntu 22.04 using command line or terminal:

  • Step 1 – Install PHP and Apache Web Server
  • Step 2 – Install MySQL / MariaDB Database Server
  • Step 3 – Download and Install Nextcloud
  • Step 4 – Configure Apache to Serve Nextcloud
  • Step 5 – Enable ReWrite Mode and Restart Server
  • Step 6 – Complete Nextcloud Installation via GUI

Step 1 – Install PHP and Apache Web Server

Execute the following command on command line or terminal to install PHP and apache web server:

sudo apt update
sudo apt install -y php-cli php-fpm php-json php-intl php-imagick php-pdo php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath apache2 libapache2-mod-php

Once the installation of the packages is finished, Set PHP variables using the following command:

sudo vim /etc/php/*/apache2/php.ini

Then set PHP variables; is as follow:

date.timezone = Africa/Nairobi
memory_limit = 512M
upload_max_filesize = 500M
post_max_size = 500M
max_execution_time = 300

And restart apache web server using the following command:

sudo systemctl restart apache2

Step 2 – Install MySQL / MariaDB Database Server

Then execute the following command on command line to install MariaDB or MySQL database server:

sudo apt -y install mariadb-server

Secure MariaDB database server using the following command:

sudo mysql_secure_installation

Change authentication plugin to allow use of root password.

sudo mysql -u root

UPDATE mysql.user SET plugin = 'mysql_native_password' WHERE User = 'root';
FLUSH PRIVILEGES;
QUIT;

Then execute the following command to create database:

mysql -u root -p
CREATE USER 'nextcloud'@'localhost' identified by 'StrongPassword';
CREATE DATABASE nextcloud;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost'; FLUSH PRIVILEGES;
QUIT;

Don’t forget to replace StrongPassword with your database user password.

Step 3 – Download and Install Nextcloud

Execute the following commands on command line to download and install Nextcloud on linux ubuntu:

sudo apt install -y wget unzip
wget https://download.nextcloud.com/server/releases/latest-23.zip

Once the file is downloaded, extract it by using the following command:

unzip latest-23.zip

Move the resulting folder to /srv

sudo mv nextcloud/ /srv

By using the following command to change directory permissions to the www-datauser:

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

Step 4 – Configure Apache to Serve Nextcloud

Then execute the following command on command line to create a VirtualHost file for Nextcloud:

sudo vim /etc/apache2/conf-enabled/nextcloud.conf

After that, add the following content into the file:

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot /srv/nextcloud/
     ServerName example.com
     ServerAlias www.example.com
     ErrorLog /var/log/apache2/nextcloud-error.log
     CustomLog /var/log/apache2/nextcloud-access.log combined
 
    <Directory /srv/nextcloud/>
	Options +FollowSymlinks
	AllowOverride All
        Require all granted
 	SetEnv HOME /srv/nextcloud
 	SetEnv HTTP_HOME /srv/nextcloud
 	<IfModule mod_dav.c>
  	  Dav off
        </IfModule>
    </Directory>
</VirtualHost>

Step 5 – Enable ReWrite Mode and Restart Server

Using the following command to enable required Apache modules and restart the service:

sudo a2enmod rewrite dir mime env headers

sudo systemctl restart apache2

Step 6 – Complete Nextcloud Installation via GUI

Open your browser and point it to the following address:

http://SERVR_IP/nextcloud/
OR
http://SERVER_ADDRESS/nextcloud/

Once the installation wizard loads, create a nextcloud superuser/admin user account. Enter the username and password. Besides, click on the Storage and Database link to access additional installation configuration options for your Nextcloud data directory and database.

Then fill in the database connection details as shown in the following screenshot and click Finish Setup.

Nextcloud Setup Wizard

When the installation is complete, we will see the following window. Click on the forward arrow that will appear at the right side of the blue window to proceed and follow the prompts.

Conclusion

Through this tutorial, we have learned how to install and configure Nextcloud on Linux ubuntu 22.04.

Recommended Linux Ubuntu Tutorials

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *