Building ownCloud 8 on CentOS 7
I’ve tried a number of times now to build ownCloud at home. I’ve tried a whole heap of guides, and they always seem to take me 80% of the way. I also tried the OpenSUSE ownCloud in a box VM, but it was an incomplete implementation as well.
My biggest gripe with the guides/builds is that they usually just use sqlite as the database, which is not recommended for multi-user deployments.
I also tried running it on Windows, but support for that has been dropped as of Version 8. If someone would like the instructions for that, I’ll be happy to provide those.
Part 1: Server Build and Configuration
Let’s start by turning off SELinux:
1 | sed -i 's/enforcing/disabled/g' /etc/selinux/config |
Note: in production environments, I’d recommend instead determining the SELinux policy that is required for the server instead of just turning it off. I’ll try to update this section in the future.
Restart the machine to apply the change:
1 | shutdown -r now |
Update the Server:
1 | yum update -y |
Install the Prerequisite packages:
1 | yum install yum-cron httpd php php-mysql sqlite php-dom php-mbstring php-gd php-pdo php-json php-xml php-zip php-gd curl php-curl php-pear wget mariadb-server mariadb realmd samba samba-common samba-client oddjob oddjob-mkhomedir sssd ntpdate samba-winbind-clients samba-winbind ntp -y |
Note: I’m going to connect this machine to a domain. You can omit all of the packages after “realmd” if you’re not joining it to a domain.
Set auto-updates for yum:
1 | sed -i 's/apply_updates = no/apply_updates = yes/g' /etc/yum/yum-cron.conf |
Network Configuration:
1 | firewall-cmd --permanent --zone=internal --change-interface=eth0 |
Disclaimer: I’m far from being a network security expert, so ensure you review these rules with a professional before deploying them into production. If you know a better way to implement these rules, please share your knowledge.
Set DNS Servers (this is just for my network, as my crappy router doesn’t let me define a different DNS Server for DHCP):
1 | echo "{DNS Server in Domain}" >> /etc/sysconfig/network-scripts/ifcfg-eth0 |
Restart the network service for the changes to take effect:
1 | systemctl restart network.service |
Set the Timezone:
1 | timedatectl set-timezone Australia/Sydney |
This is just specific to my environment, as I have a domain:
1 | systemctl enable ntpd.service |
And then add my user account to the Sudoers file:
1 | ## Add AD Domain Admins to sudoers file |
Then finally shut down the machine, and take a snapshot. If it’s a physical machine, take an image of the machine.
1 | shutdown now |
LAMP Configuration
Start Apache and MySQL:
1 | sudo systemctl start mariadb |
Set Apache and MySQL to start on boot:
1 | sudo systemctl enable mariadb |
Setup MySQL, substituting {mysqlrootpassword}
with your own desired password:
1 | sudo mysql_secure_installation |
Now create the OwnCloud database, substituting {ownclouduserpassword}
with your own desired password:
1 | mysql -uroot -p |
Set PHP charset to UTF-8:
1 | sudo vi /etc/php.ini |
Part 2: OwnCloud Installation
I chose to install it this way, as it allows for future updates to just come down via yum.
Add the OwnCloud Repository:
1 | cd /etc/yum.repos.d/ |
Install OwnCloud:
1 | sudo yum install owncloud -y |
Now we have to edit one of the files in owncloud, because otherwise it prevents you from installing apps from the owncloud appstore:
1 | sudo vi /var/www/html/owncloud/lib/private/httphelper.php |
Now you should be able to browse to the site, by going to http://{server_name}/owncloud
If it worked, take another snapshot in case you break it during the application setup.
Part 3: TLS Enablement
This is fairly straightforward, and there are plenty of guides out there, but I’ll include it here for completeness sake.
First we need the mod_ssl module for Apache:
1 | sudo yum install mod_ssl -y |
Now create the Key:
1 | sudo mkdir /etc/httpd/ssl |
Now output the CSR, to send to your certificate authority:
1 | cat /etc/httpd/ssl/apache.csr |
Get the CSR signed, and the copy the resultant certificate contents (as Base64) and put it on the server:
1 | sudo vi /etc/httpd/ssl/apache.crt |
Configure Apache to use the SSL Certificate:
1 | sudo vi /etc/httpd/conf.d/ssl.conf |
Finally restart apache to have your settings take effect:
1 | sudo service httpd restart |