• CentOS 7

To Do

These are the steps that we will do in this tutorial:

  • Disable SELinux and configure firewalld.
  • Instal and configure Nginx, MariaDB, php-fpm.
  • Create a database and configure SSL.
  • Install OwnCloud.
  • Configure a virtualhost for OwnCloud.
  • Test OwnCloud in the browser.

Disable SELinux and configure firewalld

To disable SELinux, edit the file /etc/sysconfig/selinux, and change enforced to disabled.

vim /etc/sysconfig/selinux


Run these commands to open port 80/http and 443/https in firewalld so that we can reach the OwnCloud interface by http and https later.

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

Install and configure LEMP

These are the steps to setup the basic LEMP (Linux – Nginx – MariaDB – PHP) Server to run OwnCloud on.

Step 1 – Enable epel-repository

To install LEMP(Linux, Nginx, MariaDB and PHP) you must enable epel-repository.

yum -y install epel-release

Step 2 – Installing Nginx, MariaDB and php-fpm

sudo rpm -Uvh
yum -y install nginx mariadb mariadb-server php-fpm php-cli php-gd php-mcrypt php-mysql php-pear php-xml bzip2 vim

Step 3 – Start and Configure MariaDB

systemctl start mariadb

the first time you just press Enter.

Step 4 – Configure php-fpm

Edit file /etc/php-fpm.d/www.conf.

vim /etc/php-fpm.d/www.conf

make sure the line listen is :

And edit the line for user – group :

Create directory for session-path.

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

Start php-fpm.

systemctl start php-fpm

Step 5 – Start nginx

systemctl start nginx

At this step you can visit your web server


Create a database and Configure SSL

Step 1 – Create Database and User

Login to MariaDB with the mysql commandline client:

mysql -u root -p

Create the database:

create database owncloud_db;

Add a user:

create user [email protected] identified by ‘ownclouduser’;

Grant permissions for the user to the database

grant all privileges on owncloud_db.* to [email protected] identified by ‘ownclouduser’;
flush privileges;


Step 2 – Create SSL Certificate

mkdir -p /etc/nginx/cert/
cd /etc/nginx/cert/
openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/owncloud.crt -keyout /etc/nginx/cert/owncloud.key

the command will generate a owncloud.crt and owncloud.key in directory /etc/nginx/cert/.

Change permission certificate file.

chmod 600 owncloud.crt
chmod 600 owncloud.key

Install OwnCloud

Download the application source with wget.

yum -y install wget
cd /tmp/

Extract and move owncloud directory to /usr/share/nginx/html.

tar -xjvf owncloud-8.0.0.tar.bz2
mv owncloud/ /usr/share/nginx/html/

Change the owner of owncloud directory to nginx.

cd /usr/share/nginx/html/
chown nginx:nginx -R owncloud/

Create directory called data on owncloud directory, and change owner to nginx.

mkdir -p owncloud/data/
chown nginx:nginx -R owncloud/data/

Configure a Virtualhost for OwnCloud

The last step is to configure a virtualhost for owncloud.

cd /etc/nginx/conf.d/
mv default.conf default

add owncloud configuration to /etc/nginx/conf.d/

vim owncloud.conf

Paste configuration below :

And then restart the LEMP stack:

systemctl restart nginx mariadb php-fpm

Now configure the LEMP Services to start on boot.

systemctl enable nginx
systemctl enable php-fpm
systemctl enable mariadb

Then reboot your server:


Test OwnCloud and you will be redirect to ssl connection

Create admin account and fill all Database(Username,Password,dbname) then click Finish Setup.



OwnCloud is the right solution for a private cloud today. Easy to use and configure and with a userfriendly interface which makes it easy to use and install. Owncloud is fast, stable and has many features.