How to Install ownCloud on VPS for Private Cloud Storage

ownCloud is a flexible, secure, and self-hosted cloud storage solution that allows you to store, manage, and access your files from anywhere. By setting up ownCloud on your VPS, you can create a private cloud server to handle your data storage needs. This guide will walk you through the installation process on a Ubuntu 20.04 LTS VPS, along with basic configuration and security measures to ensure your server runs smoothly.


Step 1: Set Up Your VPS

  1. Create a VPS

    • Choose a VPS with at least 1GB of RAM for smooth operation. For better performance, a VPS with 2GB or more is recommended.
    • Ensure the VPS is running Ubuntu 20.04 LTS or a later version of Ubuntu.
  2. SSH Into Your VPS

    • After creating your VPS, connect to it via SSH:
       
      ssh username@your-vps-ip
  3. Update Your System

    • Before installing any software, update your system:
       
      sudo apt update && sudo apt upgrade -y

Step 2: Install Apache, MySQL, and PHP (LAMP Stack)

ownCloud requires a web server (Apache), a database server (MySQL), and PHP to run. We'll install the LAMP stack.

  1. Install Apache

    • Apache will serve as the web server for ownCloud:
       
      sudo apt install apache2 -y
  2. Install MySQL

    • MySQL is the database system used by ownCloud:
       
      sudo apt install mysql-server -y
  3. Install PHP

    • ownCloud requires PHP and several PHP extensions to work. Install them by running:
       
      sudo apt install php php-cli php-gd php-mysql php-xml php-curl php-zip php-mbstring php-bz2 php-intl php-common php-json -y
  4. Start and Enable Services

    • Enable and start Apache and MySQL services:
       
      sudo systemctl enable apache2 sudo systemctl start apache2 sudo systemctl enable mysql sudo systemctl start mysql

Step 3: Create a MySQL Database for ownCloud

  1. Log into MySQL

    • Access the MySQL command line:
       
      sudo mysql -u root -p
  2. Create a Database and User

    • Create a database for ownCloud:
      sql
       
      CREATE DATABASE owncloud;
    • Create a user and grant privileges to the ownCloud database:
      sql
       
      CREATE USER 'ownclouduser'@'localhost' IDENTIFIED BY 'yourpassword'; GRANT ALL PRIVILEGES ON owncloud.* TO 'ownclouduser'@'localhost'; FLUSH PRIVILEGES; EXIT;

Step 4: Install ownCloud

  1. Download ownCloud

    • Download the latest version of ownCloud from the official website:
       
      wget https://download.owncloud.org/community/owncloud-complete-latest.tar.bz2
  2. Extract the Archive

    • Extract the downloaded archive:
       
      tar -xvjf owncloud-complete-latest.tar.bz2
  3. Move ownCloud Files to Apache’s Root Directory

    • Move the extracted files to Apache’s root directory:
       
      sudo mv owncloud /var/www/html/
  4. Set Permissions

    • Change the ownership of the ownCloud directory to Apache's user:
       
      sudo chown -R www-data:www-data /var/www/html/owncloud/ sudo chmod -R 755 /var/www/html/owncloud/

Step 5: Configure Apache for ownCloud

  1. Create a Virtual Host for ownCloud

    • Create a new Apache configuration file for ownCloud:

       
      sudo nano /etc/apache2/sites-available/owncloud.conf
    • Add the following configuration:

      apache
       
      <VirtualHost *:80> DocumentRoot /var/www/html/owncloud ServerName yourdomain.com <Directory /var/www/html/owncloud> Options +FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
  2. Enable the Site and Rewrite Module

    • Enable the new site and Apache's rewrite module:
       
      sudo a2ensite owncloud.conf sudo a2enmod rewrite
  3. Restart Apache

    • Restart Apache to apply the changes:
       
      sudo systemctl restart apache2

Step 6: Complete the Installation via the Web Interface

  1. Access the ownCloud Web Installer

    • Open your web browser and visit http://your-vps-ip or http://yourdomain.com if you’ve set up a domain. This will take you to the ownCloud web installer.
  2. Database Configuration

    • On the installation page, fill in the database settings:
      • Database user: ownclouduser
      • Database password: yourpassword
      • Database name: owncloud
  3. Create Admin Account

    • Create an admin account to manage your cloud:
      • Admin username: admin
      • Admin password: (Choose a strong password)
  4. Complete the Setup

    • Once you’ve entered the necessary information, click Finish Setup. The installation process will complete, and ownCloud will be ready for use.

Step 7: Configure SSL for Secure Access (Optional but Recommended)

For secure HTTPS access, it’s highly recommended to use SSL certificates. You can obtain free SSL certificates using Let’s Encrypt.

  1. Install Certbot

    • Install Certbot to enable SSL on Apache:
       
      sudo apt install certbot python3-certbot-apache -y
  2. Obtain SSL Certificate

    • Run the following command to obtain and install the SSL certificate:

       
      sudo certbot --apache
    • Follow the prompts to enter your email address and accept the terms of service. Certbot will automatically configure SSL for your domain.

  3. Auto-Renew SSL Certificate

    • Certbot will automatically renew the SSL certificate when it expires. To test the renewal process, you can run:
       
      sudo certbot renew --dry-run

Step 8: Finalizing Configuration and Accessing ownCloud

  1. Access ownCloud

    • Now, you can access ownCloud at https://your-vps-ip or https://yourdomain.com. Log in using the admin credentials you created earlier.
  2. Add External Storage (Optional)

    • You can configure external storage to connect to other services such as Dropbox, Google Drive, or network shares through the External Storage app in the settings.
  3. Enable Apps (Optional)

    • ownCloud offers various apps for added functionality, such as calendars, contacts, and file sharing. You can install these apps from the ownCloud App Store under the settings section.

Step 9: Secure Your ownCloud Instance

  1. Change Default Admin Password

    • Ensure the admin password is strong and change it if necessary from the settings page.
  2. Enable Two-Factor Authentication

    • Add an extra layer of security by enabling two-factor authentication (2FA). You can do this through the ownCloud settings.
  3. Regular Backups

    • Regularly back up your ownCloud data to ensure that you don’t lose important files.

Conclusion

You have successfully installed and configured ownCloud on your VPS to create a private cloud storage solution. With ownCloud, you can securely store, manage, and share files from any device while maintaining full control over your data. You can further customize your installation by enabling additional apps and external storage, and ensure its security by enabling HTTPS and two-factor authentication.

By following these steps, you now have a reliable private cloud storage system that can be accessed remotely from anywhere, providing flexibility, privacy, and security for your data.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution