Nextcloud is a fork of ownCloud, but better. Nextcloud has all of ownCloud’s Enterprise features available for free. Nextcloud is a great solution for a private cloud, contacts management, calendar, file-sync and more. Best of all, it’s free and open source.
If you have a CentOS-based distro like Fedora/RedHat/CentOS 7 – be it a VPS, a home server or even a desktop computer, you can use the following instructions and install Nextcloud on your CentOS 7:
Before we start with anything, you need a few things:
- A CentOS (duh) VPS with root access. We recommend SolaDrive if you need a cheap, managed KVM VPS. They have a great 24/7 technical support. It’s an affiliate link. I use SolaDrive for my sites and I love them.
- At least 512MB RAM (1GB or more recommended)
- PHP, Nginx/Apache, MariaDB/Mysql
- An up-to-date system!
If you haven’t already updated your system, do so by running the following command:
Now that you have an updated system, let’s continue.
Apache is a widely used web server. You probably already have it installed. If so, skip this step. If you don’t have it installed, you can install it by using these commands:
yum install httpd -y
Start Apache and set it to start up on boot.
systemctl start httpd.service systemctl enable httpd.service
Install PHP 7
You probably already have it. If you do have PHP installed on your server (PHP 5.5 minimum), then skip this step too. To install PHP 7, run the following command:
yum install mod_php70u php70u-cli php70u-mysqlnd
Restart Apache for all changes to take effect (including the PHP changes):
systemctl restart httpd.service
MariaDB and MySQL are essentially the same, but MariaDB is a new and improved version of MySQL. In this tutorial, we’ll be using MariaDB, but you can just as well use MySQL if you prefer it. To install MariaDB, run:
yum install -y mariadb-server mariadb
Now start MariaDB and enable it to automatically start on boot with:
sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
Run this script so you have a secure MariaDB installation:
Nevermind it saying ‘mysql’. You’ll be asked a few questions (all are preferably answered Yes). You will need to set a root password and stuff like that.
After you are done with the script, you need to create an actual database for Nextcloud. First, login to your MariaDB with:
mysql -u root -p
Enter the password you entered earlier. I feel like I don’t have to mention this, but use a strong password!
Now, create a database and a user for Nextcloud using:
CREATE DATABASE nextcloud; CREATE USER 'feentanextcloud'@'localhost' IDENTIFIED BY 'STRONGpassword'; GRANT ALL PRIVILEGES ON nextcloud.* TO 'feentanextcloud'@'localhost' IDENTIFIED BY 'STRONGpassword' WITH GRANT OPTION; FLUSH PRIVILEGES; EXIT;
Replace ‘feentanextcloud’ and ‘STRONGpassword’ with something of your choice.
Finally. The most important part. Actually installing Nextcloud. Download the latest version of Nextcloud server. At the moment of writing this tutorial, it’s 10.0.1, so we’ll be installing Nextloud 10.0.1 on CentOS 7. Again, if you are reading this from the future (are you a time traveler?) then use the latest version available. Anyway, to install Nextcloud, run the following commands:
cd wget https://download.nextcloud.com/server/releases/nextcloud-10.0.1.zip
Unzip the archive you just downloaded with:
If you don’t have ‘unzip’ already installed, you can install it by running:
yum install unzip -y
Move all those files to the web root directory with this command:
mv nextcloud/* /var/www/html
You’ll also need to grant proper permission to them. Run the following command:
chown apache:apache -R /var/www/html
You can install Nextcloud right from the command line. No need for a GUI or leaving the terminal window. Run the following command to move the /var/www directory:
Then, to install Nextcloud via the command line, run the command below, but be sure to replace the database name, user, password, admin-pass and everything else with your appropriate data.
-u apache php occ maintenance:install --database "mysql" --database-name "nextcloud" --database-user "feentanextcloud" --database-pass "STRONGpassword" --admin-user "feentAdmin" --admin-pass "anotherSTRONGpassword"
That’s it for the installation part.
Next, you need to add your server IP and your domain to Nextcloud’s trusted domains list by running the following command:
You can use whatever editor you like, including vim. Here, however, we’ll be using nano. Find the
0 => 'localhost'
line and add these 2 lines under it:
1 => '188.8.131.52', 2 => 'www.feenta.com',
Replace the IP and domain with your IP and domain. Save and close the file.
After you are done with that, set the proper (secure) permissions to Nextcloud’s directories and files with these commands:
find /var/www/html -type f -print0 | sudo xargs -0 chmod 0640 find /var/www/html -type d -print0 | sudo xargs -0 chmod 0750 chown -R root:apache /var/www/html chown -R apache:apache /var/www/html/apps chown -R apache:apache /var/www/html/config chown -R apache:apache /var/www/html/data chown -R apache:apache /var/www/html/themes chown -R apache:apache /var/www/html/updater chmod 0644 /var/www/html/.htaccess chown root:apache /var/www/html/.htaccess chmod 0644 /var/www/html/data/.htaccess chown root:apache /var/www/html/data/.htaccess
Note that there may be a ‘/var/www/html/assets’ directory in the future that hasn’t been created yet. If that directory is created, you will need to run the following command too:
sudo chown -R apache:apache /var/www/html/assets
Later on, if you need to update Nextcloud, you can change the permissions with this command:
chown apache:apache -R /var/www/html
But don’t forget to change them back after you are done with the update.
That’s it. Now, restart Apache for the changes to take effect:
sudo systemctl restart httpd.service
Based on your setup, you may need to edit your firewall rules too. Run the following commands:
firewall-cmd --zone=public --permanent --add-service=http firewall-cmd --zone=public --permanent --add-service=https firewall-cmd --reload
Done! Now you can access Nextcloud with your admin username and password from the previous steps by accessing your IP/domain ie. http://184.108.40.206
Please note that we are not a technical support company and we do not offer those services. If you have specific problems with your server or Nextcloud installation, please contact Nextcloud or your server provider. We recommend SolaDrive if you want a cheap managed KVM VPS. They will help your Nextcloud server.