How to Install NextCloud on CentOS 7

NextCloud is a free and open source self-hosted alternative to Dropbox or Google Drive. It lets you host your files onto your own private server, providing you full control over your data.


  1. A new ECS instance with CentOS 7.4 as the operating system.
  2. Connect to your ECS instance and log in as the root user.
  3. A domain name which is pointed towards your ECS instance.

Once you are logged into your CentOS 7 instance, run the following command to update your base system with the latest available packages.

yum -y update

Create a new user.

adduser nextcloud
passwd nextcloud

Add the user to sudo group and switch to the newly created user.

usermod -aG wheel nextcloud
sudo su - nextcloud

Install Nginx with PHP 7

sudo yum -y install epel-release yum-utils nano unzip
sudo rpm -Uvh
sudo yum-config-manager --enable remi-php71

Install Nginx web server and PHP 7.1 along with the required PHP modules.

sudo yum -y install nginx php php-fpm php-mysqlnd php-ctype php-dom php-gd php-iconv php-json php-libxml php-mbstring php-posix php-xml php-zip php-openssl php-zlib php-curl php-fileinfo php-bz2 php-intl php-mcrypt php-ftp php-exif php-gmp php-memcached php-imagick

Edit the loaded PHP configuration file.

sudo nano /etc/php.ini

Set the appropriate time zone and memory limit. If you want, you can use -1 as the memory limit, which will remove the limits on the amount of memory a script may consume. Uncomment and set 0 to the value of cgi.fix_pathinfo and increase the file upload limits. Once you have updated the parameters, the updates should look like as shown below.

; Maximum amount of memory a script may consume (128MB)
memory_limit = 512M
; Defines the default timezone used by the date functions
date.timezone =Asia/Kolkata
post_max_size = 512M
upload_max_filesize = 512M

Once you have done configuring php.ini, open the php-fpm configuration file.

sudo nano /etc/php-fpm.d/www.conf

Look for the user and group parameters and change it from apache to nginx. Find listen = file to comment it out and append listen = /var/run/php-fpm/php-fpm.sock just below it. Finally, uncomment listen.owner and change its value from nobody to nginx. Once you have updated the parameters, the updates should look like as shown below.

user = nginx
group = nginx
... ;listen =
listen = /var/run/php-fpm/php-fpm.sock
...listen.owner = nginx = nginx

Also, search for the following line and uncomment them to enable php environment variables.

env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

Save the file and exit from the editor. Now create a new directory to store the PHP session data.

sudo mkdir -p /var/lib/php/session
sudo chown nginx:nginx -R /var/lib/php/session/

Set appropriate permission and ownership to php-fpm socket file.

sudo chown nginx:nginx /var/run/php-fpm/php-fpm.sock
sudo chmod 660 /var/run/php-fpm/php-fpm.sock

Now, start php-fpm and enable it to automatically start at boot time.

sudo systemctl restart php-fpm
sudo systemctl enable php-fpm

Also, start Nginx web server and enable it to automatically start at boot time.

sudo systemctl restart nginx
sudo systemctl enable nginx

Now you have installed Nginx with php 7 successfully, then you can download NextCloud, setup SSL, setup mySql database, finalize the web-based installation and configure Cron Job as this tutorial shows.

Related Blog Posts

How to Setup PHP on Ubuntu 16.04

In this article, you will get some information on the installation of some tools with php on Ubuntu 16.04.

How to Install ClipBucket and Nginx on CentOS 7

In this tutorial, we will be installing and configuring ClipBucket and Nginx on an Alibaba Cloud Elastic Compute Service (ECS) instance with CentOS 7.

Related Market Products

PHP infrastructure powered by Websoft9( LAMP | CentOS7.2)

CentOS 7.0 64bit

Related Documentation

Change the PHP version

If the default PHP version is different from what is required by your program, you can change the PHP version.

Obtain visitors’ real IP addresses: ASP, PHP, ASPX, JSP

Related Products

Web Hosting

Web Application Firewall

Related Course

Web Application Attacks and Defense Deep Dive

How to Troubleshoot Web Hosting Service Issues

Database Connection Issue
DNS Record Issue
Invalid Response Issue