How to Install and Configure Nextcloud on a Hosteons VPS

Nextcloud is a powerful open-source self-hosted cloud storage solution that allows you to store, share, and access your files from anywhere — securely and privately. With a VPS from Hosteons, you can deploy your own Nextcloud instance in minutes.


✅ Prerequisites

Before starting, make sure:

  • You have a Hosteons KVM VPS with at least 1 GB RAM (2 GB recommended).
  • You’re using Ubuntu 22.04 (or a similar Linux distro).
  • You have a domain name pointed to your VPS IP (optional but recommended).
  • SSH access to the VPS (as root or sudo user).

🧰 Step 1: Update Your System

sudo apt update && sudo apt upgrade -y

⚙️ Step 2: Install Required Dependencies

sudo apt install apache2 mariadb-server libapache2-mod-php \
php php-gd php-mysql php-curl php-mbstring php-xml php-zip php-bz2 php-intl php-imagick php-gmp php-bcmath unzip wget -y

🗄️ Step 3: Configure MariaDB

sudo mysql_secure_installation

Then log into MariaDB:

sudo mysql -u root -p

Run the following queries to create a database and user:

CREATE DATABASE nextcloud;
CREATE USER 'nextclouduser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextclouduser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

📦 Step 4: Download and Extract Nextcloud

cd /var/www/
sudo wget https://download.nextcloud.com/server/releases/latest.zip
sudo unzip latest.zip
sudo chown -R www-data:www-data nextcloud
sudo chmod -R 755 nextcloud

🌐 Step 5: Configure Apache for Nextcloud

Create a new config file:

sudo nano /etc/apache2/sites-available/nextcloud.conf

Paste this:

<VirtualHost *:80>
    ServerName yourdomain.com

    DocumentRoot /var/www/nextcloud

    <Directory /var/www/nextcloud/>
        Require all granted
        AllowOverride All
        Options FollowSymlinks MultiViews
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
    CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
</VirtualHost>

Enable the config and necessary modules:

sudo a2ensite nextcloud.conf
sudo a2enmod rewrite headers env dir mime
sudo systemctl restart apache2

🔐 (Optional) Step 6: Secure with HTTPS using Let’s Encrypt

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache

🧪 Step 7: Final Setup via Web UI

Open your browser and go to http://yourdomain.com or http://your_server_ip

You’ll see the Nextcloud installer. Enter:

  • Admin username and password
  • Database name: nextcloud
  • Database user: nextclouduser
  • Password: your DB password
  • DB host: localhost

Click Finish Setup.


🎉 Done!

Nextcloud is now ready on your Hosteons VPS. You can install the mobile or desktop apps and start syncing your files securely.


🚀 Need a VPS?

Hosteons offers powerful, affordable VPS solutions with full root access, 10Gbps ports, and global payment methods including Crypto, Alipay, UPI, and more.

👉 Explore VPS Plans

Logging or Showing Real IP in cPanel/Apache when using CloudFlare

We recently switched to CloudFlare for our own website but even after a lot of research could not find proper documentation moreover mod_cloudflare has been discontinued and all documents are too old, so here is how we fixed it.

  1. First login to WHM
  2. Customise your Apache config and under Apache Modules select mod_remoteip (yes we will use mod_remoteip instead of mod_cloudflare)
  3. Once Apache is recompiled now you need to edit a file with name “370_mod_remoteip.conf” it may be 360 or 350 or something else but last part will be “mod_remoteip.conf” and file is available in /etc/apache2/conf.modules.d.
  4. Just add following to above file:

RemoteIPHeader X-Real-IP
RemoteIPTrustedProxy 173.245.48.0/20
RemoteIPTrustedProxy 103.21.244.0/22
RemoteIPTrustedProxy 103.22.200.0/22
RemoteIPTrustedProxy 103.31.4.0/22
RemoteIPTrustedProxy 141.101.64.0/18
RemoteIPTrustedProxy 108.162.192.0/18
RemoteIPTrustedProxy 190.93.240.0/20
RemoteIPTrustedProxy 188.114.96.0/20
RemoteIPTrustedProxy 197.234.240.0/22
RemoteIPTrustedProxy 198.41.128.0/17
RemoteIPTrustedProxy 162.158.0.0/15
RemoteIPTrustedProxy 104.16.0.0/12
RemoteIPTrustedProxy 172.64.0.0/13
RemoteIPTrustedProxy 131.0.72.0/22
RemoteIPTrustedProxy 2400:cb00::/32
RemoteIPTrustedProxy 2606:4700::/32
RemoteIPTrustedProxy 2803:f800::/32
RemoteIPTrustedProxy 2405:b500::/32
RemoteIPTrustedProxy 2405:8100::/32
RemoteIPTrustedProxy 2a06:98c0::/29
RemoteIPTrustedProxy 2c0f:f248::/32

 

5. Now go to WHM and under “Apache Configuration” click on “Include Editor” then under “Pre Main Include” edit the file and add:

<IfModule remoteip_module>
RemoteIPHeader X-Forwarded-For
</IfModule>
<IfModule log_config_module>
LogFormat “%{Referer}i -> %U” referer
LogFormat “%{User-agent}i” agent
LogFormat “%a %l %u %t \”%r\” %>s %b” common
LogFormat “%a %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined
CustomLog logs/access_log combined
</IfModule>

 

Now just save and restart Apache, it should now start showing your real IP in apache logs etc…