You are on page 1of 10

HOW TO INSTALL OWNCLOUD 9 ON CENTOS 7

In this tutorial we are going to install the latest up to date version of ownCloud 9 (v9.0.2) on
CentOS 7. ownCloud requires the below softwares to run:
MySQL/MariaDB
PHP 5.5 +
Apache 2.4 with mod_php

Install MariaDB 5.5


Run the below command to install MariaDB server and client. We will use MariaDB to connect
ownCloud to its own MySQL database.
# yum install mariadb-server mariadb
# systemctl start mariadb
# systemctl enable mariadb
Configure MySQL to ensure it is secured and running:

# mysql_secure_installation

Install Apache 2.4


ownCloud 9 has a friendly web interface. This requires the installation of Apache. Run the below
command to install Apache 2.4.6
# yum install httpd
# systemctl start httpd
# systemctl enable httpd

Install PHP 5.5


If you run yum install php you will be installing PHP v5.4. Unfortunately, this version is not
supported anymore and has reached EOL. That is why ownCloud recommends installing PHP
5.5+ .
The first step is to install the SCL repository:
# yum install centos-release-scl
Then install PHP 5.5 and these modules:
# yum install php55 php55-php php55-php-gd php55-php-mbstring
This installs the new PHP 5.5 module for MySQL/MariaDB
# yum install php55-php-mysqlnd
If you are using the ownCloud LDAP app, you need this module:
# yum install php55-php-ldap
Disable loading the old PHP Apache modules by changing their names (Optional):
# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php54.off
# mv /etc/httpd/conf.modules.d/10-php.conf /etc/httpd/conf.modules.d/10-php54.off
Copy the PHP 5.5 Apache modules into place:
# cp /opt/rh/httpd24/root/etc/httpd/conf.d/php55-php.conf /etc/httpd/conf.d/
# cp /opt/rh/httpd24/root/etc/httpd/conf.modules.d/10-php55-php.conf /etc/httpd/conf.modules.d/
# cp /opt/rh/httpd24/root/etc/httpd/modules/libphp55-php5.so /etc/httpd/modules/
# cp /opt/rh/httpd24/root/etc/httpd/modules/libphp55-php5.so /etc/httpd/modules/
Then restart Apache:
service httpd restart
Verify with phpinfo that your Apache server is using PHP 5.5 and loading the correct modules.
Create a new file in the httpd directory:
# vi /var/www/html/info.php
<?php
phpinfo();
?>
Add service http, https in firewalld
# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https
# firewall-cmd --reload

Install ownCloud 9 (v9.0.2)


Run the following shell commands as root to trust the repository.
# rpm --import
https://download.owncloud.org/download/repositories/stable/CentOS_7/repodata/repomd.xml.ke
y
Run the following shell commands as root to add the repository and install from there
# wget http://download.owncloud.org/download/repositories/stable/CentOS_7/ce:stable.repo
-O /etc/yum.repos.d/ce:stable.repo
# yum clean expire-cache
# yum install owncloud-files
Trusted Domains
# vi /var/www/html/owncloud/config/config.php
'trusted_domains' =>
array (
0 => 'localhost',
1 => 'owncloud.napas.com.vn',
2 => '192.168.100.131',
),
Configure Apache Virtual Host
Create the file /etc/httpd/conf.d/owncloud.conf with the following contents :
Once done with the installation, browse to http://your-server-ip/owncloud . You should get the
following page. However, there are some directory permissions that need to be fixed in order to
continue with the ownCloud 9 installation wizard.
Fix Permissons
ownCloud has created a bash script that fixes those permissions. Create a new file in the /tmp
directory and give it execute permissions.
# vi /dirperm.sh
#!/bin/bash
ocpath='/var/www/html/owncloud'
htuser='apache'
htgroup='apache'
rootuser='root'

printf "Creating possible missing Directories\n"


mkdir -p $ocpath/data
mkdir -p $ocpath/assets
mkdir -p $ocpath/updater

printf "chmod Files and Directories\n"


find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n"


chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/updater/

chmod +x ${ocpath}/occ
printf "chmod/chown .htaccess\n"
if [ -f ${ocpath}/.htaccess ]
then
chmod 0644 ${ocpath}/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
then
chmod 0644 ${ocpath}/data/.htaccess
chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi
# chmod 755 /dirperm.sh
# ./dirperm.sh
# sudo -u apache ls -lisa /var/www/html/owncloud/data/

When you have Firewall and SELinux enabled on your Linux distribution, you may run into
permissions problems after a new ownCloud installation, and see permission denied errors in
your ownCloud logs. Run these commands as root:
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/owncloud/data'
# restorecon '/var/www/html/owncloud/data'
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/owncloud/config'
# restorecon '/var/www/html/owncloud/config'
# semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/owncloud/apps'
# restorecon '/var/www/html/owncloud/apps'
Allow access to a remote database
# setsebool -P httpd_can_network_connect_db on
Allow access to LDAP server
# setsebool -P httpd_can_connect_ldap on
Allow access to remote network
# setsebool -P httpd_can_network_connect on
Allow access to SMTP/sendmail
# setsebool -P httpd_can_sendmail on
Refresh the page and you should get the following:

Moving to other location for ownCloud storage:


# mkdir -p /owncloud/data
# systemctl stop httpd
# vi /var/www/html/owncloud/config/config.php
<?php
$CONFIG = array (
'datadirectory' => '/owncloud/data',
'dbtype' => ...
# mv /var/www/owncloud/data /owncloud/
# find /owncloud/ -type f -exec chmod 0640 {} \;
# find /owncloud/ -type d -exec chmod 0750 {} \;
# chown -R root:apache /owncloud/
# chown -R apache:apache /owncloud/data/
# sudo -u apache ls -lisa /owncloud/data
# systemctl start httpd

Configure Database
To continue with the installation wizard, we need to create a database for ownCloud and a user to
access this database:
# mysql -u root -p
Enter password:
MariaDB [(none)]> create database ownclouddb;
MariaDB [(none)]> create user 'owncloudadmin'@'localhost' identified by 'Napas@kt2';
MariaDB [(none)]> grant all on ownclouddb.* to 'owncloudadmin'@'localhost' identified by
'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
# set password for 'techonthenet'@'localhost' = password('newpassword');

Setup OwnCloud
Navigate your browser to http://Your-IP/owncloud, Enter the username, password & MariaDB
details, then hit Finish Setupbutton. It will take a while to complete the setup and you will be
redirected to admin page.
Setup Libre Office
Download and Extract
# wget
http://ftp5.gwdg.de/pub/tdf/libreoffice/stable/5.1.4/rpm/x86_64/LibreOffice_5.1.4_Linux_x86-
64_rpm.tar.gz
# tar -zxvf LibreOffice_5.1.4_Linux_x86-64_rpm.tar.gz C /tmp
Install and Configuration
# cd /tmp/LibreOffice.x.x.x/RPMS
# yum install *.rpm
# cd /var/www//html/owncloud/config/
# vi config.php
'preview_libreoffice_path' => '/usr/bin/libreoffice5.1',
# systemctl restart httpd

Enable SMB/CIFS
# yum install epel-release
Or
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/ epel-release-7-7.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# yum install php-smbclient
# yum install samba-client

Configuring the ClamAV Antivirus Scanner


# yum install epel-release
# yum install clamav clamav-scanner clamav-scanner-systemd clamav-server clamav-server
systemd clamav-update
# vi /etc/freshclam.conf
# vi /etc/clamd.d/scan.conf
# crontab -u apache -e
47 * * * * /usr/bin/freshclam --quiet
Enable APCu:
# yum install php-pecl-APCu
# yum install php-pecl-redis
# vi config.php
'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
'host' => 'localhost',
'port' => 6379,
),

You might also like