HOW TO INSTALL NEXTCLOUD ON UBUNTU?

Nextcloud is an open-source and secure PHP-based content collaboration platform. It is used for file sharing and synchronization. User can share the number of files and folders from their local computers and synchronize with the Nextcloud server.

Before we proceed to install Nextcloud, your ubuntu system should have LAMP stack (Linux, Apache, MySQL /MariaDB, PHP) installed. Following are the steps to install Nextcloud on Ubuntu.

Install Apache :

  1. Run the below command to install Apache server on Ubuntu.

    # sudo apt update
    # sudo apt install apache2
    
  2. After installing Apache, start and enable the Apache service on boot.

    # sudo systemctl start apache2.service
    # sudo systemctl enable apache2.service
    

          You should be able to access the default apache page with server ip address now.

Install MariaDB :

  1. MariaDB is an open-source database server. Please hit the below command to install MariaDB.

    # sudo apt-get install mariadb-server mariadb-client
  2. After installing MariaDB, start and enable the MariaDB service on boot.

    # sudo systemctl start mariadb.service
    # sudo systemctl enable mariadb.service
  3. we will configure MariaDB once it is installed. Run below command to secure MariaDB.

    # sudo mysql_secure_installation
    
    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
    
  4. Restart MariaDB server.

    # sudo systemctl restart mariadb.service
    

Install PHP :

  1. To install php 7.2 run the below command

    # sudo apt install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-gmp php7.2-curl php7.2-intl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-cli php7.2-zip
    
  2. After installing PHP 7.2, hit the below command to open default config file of php for Apache.

    # sudo nano /etc/php/7.2/apache2/php.ini
    
  3. Please make the following changes in your php.ini file.

    file_uploads = On
    allow_url_fopen = On
    short_open_tag = On
    memory_limit = 256M
    upload_max_filesize = 100M
    max_execution_time = 360
    date.timezone = America/Chicago
    
  4. Restart the Apache service again.

    # sudo systemctl restart apache2.service
  5. We will verify all the installed features by adding a php info page on your code.

    # sudo nano /var/www/html/phpinfo.php
  6. Enter the below code in phpinfo.php page.

    php phpinfo( ); ?
  7. Save you file and open the phpinfo page with ipaddress/phpinfo.php in your browser.

Create NextCloud Database

  1. First, create a Blank Database. Login to the MariaDB Database.

    # sudo mysql -u root -p
    
  2. Create a Database named nextcloud_db;

    # CREATE DATABASE nextcloud_db;
    
  3. Create a User for the Database nextcloud_db.

    CREATE USER 'nextcloud_user'@'localhost' IDENTIFIED BY 'your_password';
    ;
  4. Grant All privileges for the nextcloud_user to nextcloud_db database.

    #GRANT ALL ON nextcloud_db.* TO 'nextcloud_user'@'localhost' IDENTIFIED BY 'user_password' WITH GRANT OPTION;
  5. Save the changes with the below command.

    # FLUSH PRIVILEGES;
    # EXIT;
    

Download Nextcloud Latest Release :

  1. Before installing Nextcloud, we will need to install curl and composer on the server. You can do it with the below command.

    # sudo apt install curl git
    # curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
    
  2. Download the Nextcloud from Github using below command. We will download it on the apache root directory.
    # cd /var/www/html
    # sudo git clone --branch stable13 https://github.com/nextcloud/server.git nextcloud
    # cd /var/www/html/nextcloud
    # sudo composer install
    # sudo git submodule update --init
    
  •                Set permission for the folder as below.

    # sudo chown -R www-data:www-data /var/www/html/nextcloud/
    # sudo chmod -R 755 /var/www/html/nextcloud/

Configure Apache service

  1. Now, we will need to configure the Apache for Nextcloud. Create a file called nextcloud.conf and add the below content into it.

    # sudo nano /etc/apache2/sites-available/nextcloud.conf 
      ServerAdmin [email protected]
         DocumentRoot /var/www/html/nextcloud/
         ServerName yourdomain.com
         ServerAlias yourdomain.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
    
  2. Save and exit from file.

  3. Enable NextCloud and Rewrite Module.

  4. As we have configured the virtualhost, we will need to enable it with below command.

    sudo a2ensite nextcloud.conf
    sudo a2enmod rewrite
    sudo a2enmod headers
    sudo a2enmod env
    sudo a2enmod dir
    sudo a2enmod mime
  5. Finally, Restart the Apache.

    # sudo systemctl restart apache2.service
  6. Our setup is completed now. Let us check with accessing your domain name in a browser which you have added in nextcloud.conf

  7. Set Nextcloud username, password, data folder and DB username, DB Name. Finally, click on Finish Button.



  8. Here it is. We have Nextcloud Dashboard as per the below image.

        This is it. We are done with Nextcloud installation.

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to install OPcache in cPanel/WHM?

OPcache is a PHP extension and it helps to improve the performance of your php Website. OPcache...

How to Stop and Disable ClamAV Service from CentOS?

We all know that ClamAV scanner is a pretty heavy on CPU-Memory resources, and it should be...

Difference Between su and sudo and How to Configure sudo in Linux VPS.

As we know Linux provides much better security. You can set user management policy and user...

How to upgrade MySQL/Maria DB in WHM/cPanel?

Note: These steps will work only with the cPanel version 88 and later. Please refer to the below...

Can I open APN port 2195 on my VPS?

You will get full administrative control of your VPS, therefore you can surely open/close any...