Tutorials  /  Linux Basics

Install and Configure Nextcloud on CentOS 7 (LAMP Guide)

Ccentron Redaktion · July 2025 ·4 min read ·Linux Basics, Tutorial

Nextcloud serves as a powerful alternative to OwnCloud, offering a secure, open-source file hosting platform.

This guide demonstrates how to install Nextcloud on a CentOS 7 server, optimized for enterprise hosting environments like centron.

Requirements

  • A freshly deployed CentOS 7 server
  • A sudo-enabled user account
VM

Matching infrastructure at centron

No hardware needed to follow along: ccloud³ VMs with full root access start at €3.12 per month, billed by the hour and ready in seconds. Rent a cloud server →

Step 1: System Update

Connect to the server as a sudo user and apply all available updates:

Console
sudo yum install epel-release -y
sudo yum update -y
sudo shutdown -r now

Once the reboot completes, log in again as the same user.

Step 2: Apache Installation

Set up Apache as your web server:

Console
sudo yum install httpd -y
sudo sed -i 's/^/#&/g' /etc/httpd/conf.d/welcome.conf
sudo sed -i "s/Options Indexes FollowSymLinks/Options FollowSymLinks/" /etc/httpd/conf/httpd.conf
sudo sed -i 's/^/#&/g' /etc/httpd/conf.modules.d/00-dav.conf
sudo systemctl start httpd.service
sudo systemctl enable httpd.service

Step 3: PHP and Extensions Installation

Install PHP 5.6 and its required modules via the IUS repository:

Console
cd
wget https://centos7.iuscommunity.org/ius-release.rpm
sudo rpm -Uvh ius-release.rpm
sudo yum install php56u php56u-common php56u-xml php56u-gd php56u-mbstring php56u-process php56u-mysqlnd php56u-intl php56u-mcrypt php56u-imap php56u-cli -y

To support larger file uploads (e.g., 50 MB), update PHP configuration:

Console
sudo cp /etc/php.ini /etc/php.ini.bak
sudo sed -i "s/post_max_size = 8M/post_max_size = 50M/" /etc/php.ini
sudo sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 50M/" /etc/php.ini
sudo systemctl restart httpd.service

Step 4: MariaDB Setup

Install and configure MariaDB to serve as the database backend:

Console
sudo yum install mariadb mariadb-server -y
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
sudo /usr/bin/mysql_secure_installation

Follow the prompts to set the root password and secure your installation. Then log into MariaDB:

Code
mysql -u root -p

Create the Nextcloud database and user (replace values accordingly):

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

Step 5: Download and Configure Nextcloud

Retrieve and unpack the Nextcloud archive:

Console
cd
wget https://download.nextcloud.com/server/releases/nextcloud-9.0.53.zip
sudo yum install unzip -y
unzip nextcloud-9.0.53.zip
sudo mv nextcloud/* /var/www/html && sudo chown apache:apache -R /var/www/html

Install Nextcloud from the command line using your database and admin credentials:

Console
cd /var/www/html/
sudo -u apache php occ maintenance:install --database "mysql" --database-name "nextcloud" --database-user "nextclouduser" --database-pass "yourpassword" --admin-user "admin" --admin-pass "nextcloudadminpassword"

Step 6: Trusted Domains and File Permissions

Add trusted domains to the Nextcloud configuration:

Console
sudo vi /var/www/html/config/config.php

Locate:

Code
0 => 'localhost',

Append your server IP and domain:

Code
1 => '203.0.113.1',
2 => 'www.example.com',

Save and exit the editor.

Step 7: Secure Permissions

Apply strict permissions to prevent unauthorized access:

Console
sudo find /var/www/html -type f -print0 | sudo xargs -0 chmod 0640
sudo find /var/www/html -type d -print0 | sudo xargs -0 chmod 0750
sudo chown -R root:apache /var/www/html
sudo chown -R apache:apache /var/www/html/apps
sudo chown -R apache:apache /var/www/html/config
sudo chown -R apache:apache /var/www/html/data
sudo chown -R apache:apache /var/www/html/themes
sudo chown -R apache:apache /var/www/html/updater
sudo chmod 0644 /var/www/html/.htaccess
sudo chown root:apache /var/www/html/.htaccess
sudo chmod 0644 /var/www/html/data/.htaccess
sudo chown root:apache /var/www/html/data/.htaccess

If you later create the /var/www/html/assets directory, assign permissions accordingly:

Console
sudo chown -R apache:apache /var/www/html/assets

For updates, temporarily change ownership:

Console
sudo chown apache:apache -R /var/www/html

After updating, restore restrictive permissions.

Step 8: Firewall Rules and Service Reload

Enable HTTP and HTTPS traffic through the firewall and reload the service:

Console
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
sudo systemctl restart httpd.service

Conclusion

Your Nextcloud instance should now be accessible via http://203.0.113.1. Use the administrator credentials to log in and start managing your file-sharing platform securely.

Jetzt 200 € Guthaben sichern

Testen Sie Ihr Setup auf ccloud³

Registrieren Sie sich in der ccloud³ und erhalten Sie 200 € Startguthaben für Ihr Projekt – z. B. für eine PostgreSQL-VM mit automatischen Backups.

centron Redaktion Technische Redaktion

Das Redaktionsteam von centron schreibt Anleitungen aus dem Betriebsalltag: getestet auf unserer eigenen Plattform, betrieben im Rechenzentrum in Hallstadt bei Bamberg.

Kategorie Linux Basics
Teilen
Noch offene Fragen?

Our team will help you with your specific setup - in German or English, by people who run the platform themselves.

War dieses Tutorial hilfreich?

Your answer is stored anonymously and helps us improve our tutorials.

Kommentare

No comments yet - be the first to ask a question about this tutorial.

Sign in to comment

Comments are open to centron customers. Sign in to your account to ask a question about this tutorial.

Weiterlesen

Das könnte Sie auch interessieren

Jetzt kostenlos anfangen

Melden Sie sich an und erhalten Sie in den ersten 60 Tagen ein Guthaben von 200 € bei centron.

Dieses Werbeangebot gilt nur für neue Konten. Angebot ausschließlich für Gewerbetreibende.

Jetzt loslegen Sales kontaktieren