Nextcloud’s pretty much like your own private Dropbox—open-source, and run by you. If you’re setting it up on robust operating systems like CentOS or AlmaLinux, you score a secure setup for managing your files. Follow these easy steps to get Nextcloud going on your RHEL server.

Why Consider Nextcloud with CentOS / AlmaLinux?

CentOS and AlmaLinux are super reliable, coming off the whole Red Hat family tree. If you prefer stability with long-term support, you’ve got it. By pairing them with Nextcloud, you’ll get:

  • Control over data: Keep your files on your own turf, not out there in the wild internet.
  • Flexibility: Tweak Nextcloud and your server settings to match your needs.
  • Seamless integration: Use it with LDAP/Active Directory for login, plus Linux tools for backups and tracking.
  • Strong security: They come packed with security features, while Nextcloud secures your data with encryptions.

I’ve set up these Nextcloud systems on CentOS 7 and AlmaLinux 8 for clients. Sometimes PHP compatibility and web server tuning are a hassle, but we’ll breeze through that together.

What You’ll Need Before Installing Nextcloud

Ensure your server meets these requirements:

  • Server:
    • CentOS 7/8 or AlmaLinux 8, fully updated.
    • Root or sudo access.
  • Software:
    • Apache HTTP Server (or NGINX if that’s your jam).
    • PHP 7.4+ with all the necessary extensions.
    • MariaDB or MySQL database server.
    • SSL certificate for secure browsing (Let’s Encrypt is fine).
  • Resources:
    • At least 2GB of RAM if it’s for small teams.
    • Enough storage for files.

To check your version, use:

For CentOS:

cat /etc/centos-release

For AlmaLinux:

cat /etc/almalinux-release

Since CentOS 7 comes with outdated PHP by default, use additional repositories like Remi or EPEL for PHP 7.4 or newer versions.

Step 1: Get Your CentOS / AlmaLinux Server Ready

First up, update your system packages:

sudo yum update -y

Add EPEL and Remi Repositories for PHP

Nextcloud needs newer PHP versions not in the base repos.

sudo yum install epel-release -y
sudo yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
sudo yum install yum-utils -y
sudo yum module reset php -y
sudo yum module enable php:remi-7.4 -y
sudo yum install php php-cli php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-common php-bcmath php-json php-intl unzip wget -y

For PHP 8.x, simply replace php:remi-7.4 with the newer version (make sure it works with your Nextcloud version though).

Set Up MariaDB

MariaDB is your go-to database for this setup.

sudo yum install mariadb-server -y
sudo systemctl enable mariadb --now

Lock down MariaDB:

sudo mysql_secure_installation

Choose a root password, scrap anonymous users, and restrict remote root login.

Build a new database and user:

sudo mysql -u root -p

Inside the database command line:

CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'nc_user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON nextcloud.* TO 'nc_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Swap ‘your_strong_password’ with, well, a real strong password.

Set Up Your Apache Web Server

To install Apache and make it run on boot:

sudo yum install httpd -y
sudo systemctl enable httpd --now

Adjust firewall to let web traffic in:

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

Step 2: Snag and Install Nextcloud

Grab the latest Nextcloud from its site:

cd /tmp
wget https://download.nextcloud.com/server/releases/latest.zip
unzip latest.zip
sudo mv nextcloud /var/www/html/

Ensure permissions are tight:

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

Step 3: Get Apache Ready for Nextcloud

Create a virtual host config file:

sudo nano /etc/httpd/conf.d/nextcloud.conf

Insert this setup:

<VirtualHost *:80>
    ServerName your-domain.com
    DocumentRoot /var/www/html/nextcloud

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

    ErrorLog /var/log/httpd/nextcloud_error.log
    CustomLog /var/log/httpd/nextcloud_access.log combined
</VirtualHost>

Save and close it.

Make Sure Apache Modules for Nextcloud Are Enabled

Ensure the mod_rewrite module is on (usually it’s already active) and that SELinux doesn’t block Apache from serving up content:

For SELinux status:

sestatus

If it’s on:

sudo setsebool -P httpd_unified 1
sudo chcon -R -t httpd_sys_rw_content_t /var/www/html/nextcloud

Restart Apache to apply settings:

sudo systemctl restart httpd

Step 4: Wrap Up Nextcloud Installation through Web

Head over to:

http://your-domain.com

You’ll land on the Nextcloud setup screen:

  • Create an admin account with a username and password.
  • Use these earlier database details:
    • Database user: nc_user
    • Password: the one you made earlier
    • Database name: nextcloud
    • Database host: localhost

Hit Finish Setup; Nextcloud will sort out tables and setup.

Step 5: Make Nextcloud Secure with HTTPS

Lock it down with SSL.

For a free certificate, try Let’s Encrypt:

sudo yum install certbot python3-certbot-apache -y
sudo certbot --apache -d your-domain.com

Follow the prompts to get and set up your certificate.

When you’re done, everything goes over HTTPS, securing data transfers.

Step 6: Fine-Tune PHP and Server for Nextcloud

Edit your PHP settings (/etc/php.ini) to make everything smooth:

memory_limit = 512M
upload_max_filesize = 200M
post_max_size = 200M
max_execution_time = 360
cgi.fix_pathinfo = 0

Reboot Apache to ensure those settings stick:

sudo systemctl restart httpd

For better speed on busy servers, consider turning on PHP OPcache and tweaking MySQL/MariaDB.

Real-World Tips and Tricks

Recently, I helped a medium-sized company switch their storage from the commercial cloud to a Nextcloud server on AlmaLinux 8. This move cut down costs and handed them back their data control. We wrapped this setup in under three hours (including installation, configuration, SSL setup, and initial data transfer).

Some lessons:

  • Test your PHP and database versions before going live. Compatibility issues are a headache.
  • Be aware of how SELinux could disrupt access.
  • Schedule regular backups for the database and Nextcloud data.
  • Use the Nextcloud desktop and mobile sync apps to improve usage.
  • Keep updating your server packages and Nextcloud to stay secure.

References for More Info

While this guide leans on official Nextcloud docs and best practices for CentOS/AlmaLinux:

Check out dhabaka.com for more tutorials on Linux and cloud setups.

Security and Trustworthiness Tips

Nextcloud champions HTTPS, two-factor authentication, and regulates data with what’s needed for GDPR compliance—if you configure it right.

Always:

  • Keep everything updated.
  • Use tough passwords for both database and admin logins.
  • Keep an eye on logs for anything fishy.
  • Control server access with firewalls.
  • Back up regularly to avoid losing data.

Wrapping Up

Setting up Nextcloud on CentOS or AlmaLinux can be pretty straightforward when following clear steps. Carefully configuring PHP, MariaDB, Apache, and Nextcloud ensures a smooth, secure private cloud environment. This guide is packed with real-life tips to avoid common pitfalls and sticks to RHEL install standards for ease.

You’ve got yourself a ready-to-go private cloud to handle file sharing, collaboration, and more while keeping your data under wraps.

To maintain security and performance, keep everything updated, secure it with SSL, and monitor activity regularly.


Ready for your own private cloud? Begin your Nextcloud CentOS installation today and seize control of your data.

Need Linux or cloud consulting assistance? Visit dhabaka.com for trusted advice and step-by-step tutorials.

Get in Touch