We are back with a new Ubuntu tutorial. In this article, we are going to learn you how to install Nextcloud in Ubuntu. To get familiar with a safe, secure, and flexible solution that allows users to share one or more files and directories on their computer, we will show you how to install this open-source, powerful, and secure PHP-based content collaboration platform.
You can use this solution on a Linux system, client applications for Linux, Microsoft Windows, and macOS, as well as mobile clients for Android and Apple iOS.
Nextcloud is suitable for both small and large enterprises and also service providers. please be aware that you need to install a LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) on your server to set up a Nextcloud.
Table of Contents
How to install Nextcloud in Ubuntu
Let’s see how to install the Nextcloud server on the Ubuntu Linux server with Apache and MariaDB as the web server and database software respectively.
Installing LAMP on Ubuntu
Open a terminal window and connect to your Ubuntu server via SSH, to install a LAMP stack. Then use the below command.
sudo apt-get update sudo apt-get install apache2 mariadb-server libapache2-mod-php7.2 php7.2-gd php7.2-json php7.2-mysql php7.2-curl php7.2-mbstring php7.2-intl php-imagick php7.2-xml php7.2-zip
systemctl status apache2 systemctl status mariadb systemctl is-enabled apache2 systemctl is-enabled mariadb
In case you see the services are not working, use the following command.
sudo systemctl start apache2 sudo systemctl start mariadb sudo systemctl enable apache2 sudo systemctl enable mariadb
Then, use the security script that ships with the package, to secure the MariaDB server installation.
sudo mysql_secure_installation
Now, It is time to answer some questions like the below guidance.
Note: Do not forget to set a strong and secure root password.
- Enter current password for root (enter for none): enter
- Set a root password? [Y/n] y
- Remove anonymous users? [Y/n] y
- Disallow root login remotely? [Y/n] y
- Remove test database and access to it? [Y/n] y
- Reload privilege tables now? [Y/n] y
Install Nextcloud in Ubuntu
You should create a database and database user for Nextcloud, after securing the database installation. To do this, log into the MariaDB server to access the MySQL shell.
sudo mysql -u root -p
Next, run the following sql commands.
Note: Do not forget to replace “=@!#@%$lab” with your secure password.
MariaDB [(none)]> CREATE DATABASE nextcloud; MariaDB [(none)]> CREATE USER ncadmin@localhost IDENTIFIED BY '=@!#@%$lab'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO ncadmin@localhost IDENTIFIED BY '=@!#@%$lab'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
Now, Download the Nextcloud from the Nextcloud Download Page, by clicking on Download Nextcloud Server => Download Nextcloud to grab a .zip archive or run the following commands to download it from the command-line using wget command.
sudo wget -c https://download.nextcloud.com/server/releases/nextcloud-18.0.0.zip
Then, extract the archive contents and copy the extracted nextcloud directory/folder into your web server’s document root
sudo unzip nextcloud-18.0.0.zip sudo cp -r nextcloud /var/www/html/ sudo chown -R www-data:www-data /var/www/html/nextcloud
Configure Apache to serve Nextcloud
As you see, you need to create an Apache configuration file for Nextcloud under the /etc/apache2/sites-available directory.
sudo vim /etc/apache2/sites-available/nextcloud.conf
Copy and paste the following lines in the file.
Note: Do not forget to replace /var/www/html/nextcloud/ if your installation directory is different.
Alias /nextcloud "/var/www/html/nextcloud/" <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 </Directory>
You can save and close it now.
To continue, enable the newly created site and other Apache modules in the Apache configuration structure.
sudo a2ensite nextcloud.conf sudo a2enmod rewrite sudo a2enmod headers sudo a2enmod env sudo a2enmod dir sudo a2enmod mime.
Now, you are able to restart the Apache2 service for the recent changes to take effect.
sudo systemctl restart apache2
Complete Nextcloud installation via Graphical wizard
In this step, you need to complete the installation via the graphical installation wizard from a web browser. so open your browser and point it to the following address:
http://SERVR_IP/nextcloud/ OR http://SERVER_ADDRESS/nextcloud/
After loading the wizard installation, you need to create a nextcloud superuser/admin user account. So 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.
Click Finish Setup, when you filled in the database connection details.
If you complete the installation, you will see the following window. So to proceed and follow the prompts, click on the forward arrow that will appear at the right side of the blue window.
Now, to start using your new Nextcloud server, click Finish Setup in the below window.
And finally, you can see the Nextcloud web browser client’s main dashboard.
Dear user, we wish this tutorial on how to install Nextcloud in Ubuntu would be helpful for you, to ask any question or review the conversation of our users about this article, please visit Ask page. Also to improve your knowledge, there are so many useful tutorials ready for Eldernode training.