Thursday, May 3, 2018

Nextcloud On Ubuntu 18.04 Bionic Beaver Linux




Introduction:
NextCloud will be used as storage for the admini types of documents and Eprints for the Academic type of documents. Our best choice is nextcloud as a truly open source software fork of OwnCloud. A 100% open source self-hosted cloud storage services and  storing capacity ca b e extended to a local disk drive or Network Array Storage (NAS).

In our NextCloud deployment, we will use stable Ubuntu 18.04 LTS with Apache2, MariaDB, PHP and Let’s Encrypt SSL support. In addition, we will take the advantage of extending its storage capacity through linking DropBox,google drive,WebDav,NAS, and other cloud storage services. We can also mount local storage such as HDD,SDD arrayed in the network or private cloud services on users’ own servers. It system enable a self-hosted file sync and share app platforms and with them you can access & sync your files, contacts and data across your devices.

In today’s ICT environments, it is one of the most efficient solution frequently being installed with SSL/TLS encryption  to secure data and also all traffic to and from the platform is protected over HTTPS.

Below are the steps and procedures to install  and deploy Nextcloud system .


Requirements:
Software : Ubuntu 18.04,Nextcloud 18.04,Apache2 ,Php 7.2 Mysql-MarianDB
Hardware: Odroid C1, LAN


Methodology:

STEP 1: INSTALL APACHE2

NextCloud requires a webserver to function and the most popular web server in use today is Apache2. So, go and install Apache2 on Ubuntu by running the commands below:

sudo apt install apache2
After installing Apache2, run the commands below to disable directory listing.
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/apache2/apache2.conf
Next, run the commands below to stop, start and enable Apache2 service to always start up with the server boots.
sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

STEP 2: INSTALL MARIADB

NextCloud also requires a database server to function.. and MariaDB database server is a great place to start. To install it run the commands below.
sudo apt-get install mariadb-server mariadb-client
After installing, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
sudo systemctl stop mysql.service
sudo systemctl start mysql.service
sudo systemctl enable mysql.service
Note* if this command gets an error , please type
systemctl enable mariadb
After that, run the commands below to secure MariaDB server.
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • 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

Restart MariaDB server
sudo systemctl restart mysql.service

STEP 3: INSTALL PHP 7.1 AND RELATED MODULES

PHP 7.2 isn’t available on Ubuntu default repositories… in order to install it, you will have to get it from third-party repositories.
Run the commands below to add the below third party repository to upgrade to PHP 7.2
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update

For Ubuntu 18.04
sudo apt-get  install php7.2 libapache2-mod-php7.2 php7.2-common libapache2-mod-php7.2 php7.2-mbstring php7.2-xmlrpc php7.2-soap php-apcu php-smbclient php7.2-ldap php-redis php7.2-gd php7.2-xml php7.2-intl php7.2-json php-imagick php7.2-mysql php7.2-cli  php7.2-ldap php7.2-zip php7.2-curl

After install PHP 7.2, run the commands below to open PHP-FPM default file.
sudo nano /etc/php/7.2/apache2/php.ini

Then make the change the following lines below in the file and save.
file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_file_size = 64M
max_execution_time = 360
date.timezone = America/Chicago

STEP 4: CREATE NEXTCLOUD DATABASE

Now that you’ve install all the packages that are required, continue below to start configuring the servers. First run the commands below to create NextCloud database.Run the commands below to logon to the database server. When prompted for a password, type the root password you created above.
sudo mysql -u root -p
Then create a database called nextcloud
CREATE DATABASE nextcloud;
Create a database user called nextclouduser with new password
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'new_password';
Then grant the user full access to the database.
GRANT ALL ON nextcloud.* TO 'nextclouduser'@'localhost' IDENTIFIED BY 'user_password' WITH GRANT OPTION;
Finally, save your changes and exit.
FLUSH PRIVILEGES;
EXIT;

STEP 5: DOWNLOAD NEXTCLOUD LATEST RELEASE

Next, visit NextCloud site to download your free copy. The community edition is what you’ll want to download.
After downloading, run the commands below to extract the download file into Apache2 root directory.
cd /tmp && wget https://download.nextcloud.com/server/releases/nextcloud-13.0.2.zip
unzip nextcloud-13.0.2.zip
sudo mv nextcloud /var/www/html/nextcloud/

Then run the commands below to set the correct permissions for NextCloud to function.
sudo chown -R www-data:www-data /var/www/html/nextcloud/
sudo chmod -R 755 /var/www/html/nextcloud/

STEP 6: CONFIGURE APACHE2

Finally, configure Apahce2 site configuration file for NextCloud. This file will control how users access NextCloud content. Run the commands below to create a new configuration file called nextcloud.conf
sudo nano /etc/apache2/sites-available/nextcloud.conf
Then copy and paste the content below into the file and save it. Replace the highlighted line with your own domain name and directory root location.
    ServerAdmin admin@gmail.com
    DocumentRoot /var/www/html/nextcloud/
    ServerName example.com
    ServerAlias www.example.com
    Alias /nextcloud "/var/www/html/nextcloud/"
    
       Options +FollowSymlinks
       AllowOverride All
       Require all granted
         
           Dav off
         

       SetEnv HOME /var/www/html/nextcloud
       SetEnv HTTP_HOME /var/www/html/nextcloud
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

Save the file and exit.

STEP 7: ENABLE THE NEXTCLOUD AND REWRITE MODULE

After configuring the VirtualHost above, enable it by running the commands below
sudo a2ensite nextcloud.conf
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod env
sudo a2enmod dir
sudo a2enmod mime

STEP 8 : RESTART APACHE2

To load all the settings above, restart Apache2 by running the commands below.
sudo systemctl restart apache2.service

 

STEP 9 : BACKUP NEXTCLOUD

sudo apt-get rsync
sudo rsync -Aax /var/www/html/nextcloud/ /home/nextcloud/nextcloud-dirbkp_`date +"%Y%m%d"`/

STEP 10 : Mobile ,Desktop Clients  

sudo add-apt-repository ppa:nextcloud-devs/client
sudo apt-get update
sudo apt-get install  nextcloud-client

 
Summary:
Install next cloud
Insert security
Additional storage
Include federated data base
Cloud embedded based  NanoPi NAS setup :)


Conclusions:
Cloud wide database is next cloud