Setup Owncloud on CentOS 7

From rdkwiki
Jump to: navigation, search

Intro

The steps below will configure a working Owncloud 9.1.1 server. The steps assume that you have a (fresh) CentOS 7 server running with a working local installation of MySQL.

Apache installation

  • yum install httpd --> install httpd (Apache)
  • systemctl start httpd --> start Apache
  • systemctl enable httpd --> enable Apache at boot

Download and install Owncloud

  • yum install xz bzip2 --> tools needed to extract the package
  • cd /home/<folder> --> go to a folder to download the package
  • wget https://download.owncloud.org/community/owncloud-9.1.1.tar.bz2 --> download the package (in this case Owncloud 9.1.1
  • cp owncloud-9.1.1.tar.bz2 /var/www/html/ --> Copy the package to the active folder of the webserver
  • tar -jxvf /var/www/html/owncloud-9.1.1.tar.bz2 --> extract the package
  • rm /var/www/html/owncloud-9.1.1.tar.bz2 --> remove the package after extraction
  • mkdir /owncloud-data --> make the directory which will hold the data of the Owncloud-users
  • chown apache:apache /owncloud-data --> make apache owner of the folders
  • chown apache:apache /var/www/html/owncloud --> make apache owner of the folders

Firewall configuration

  • firewall-cmd --permanent --add-service=http --> allow http(tcp/80) traffic through the firewall
  • firewall-cmd --permanent --add-service=https --> allow https(tcp/443) traffic through the firewall
  • firewall-cmd --reload --> restart firewall with new config

Disable SE-Linux (optional)

  • nano /etc/selinux/config
change "SELINUX=enforcing" in "SEXLINUX=disabled"

MySQL configuration

  • mysql -h localhost -u root -p --> connnect to existing MySQL server (on the localhost in this example)
  • create database owncloud; --> create a database for Owncloud
  • create user <user>@localhost identified by ‘<password>’; --> Create a user for the Owncloud services (@localhost assumes that MySQL is running on the same server)
  • grant all privileges on owncloud.* to <user>@localhost identified by ‘<password>’; --> apply rights to the user
  • flush privileges; --> reload the rights
  • exit --> exit MySQL console

PHP installation

  • yum install php php-mysql php-curl php-xmlreader php-xmlwriter php-gd --> install required PHP modules
  • systemctl restart httpd.service --> Restart Apache to load new modules

Vhost configuration

  • mkdir /etc/httpd/sites-available --> create folder where the vhost-files will be configured
  • mkdir /etc/httpd/sites-enabled --> create a folder where the vhost-files will be linked as active sites
  • nano /etc/httpd/conf/httpd.conf --> add "includeOptional sites-enabled/*.conf" to end of file
  • nano /etc/httpd/sites-available/<site>.conf --> create a vhost-file
 <VirtualHost *:80>
   ServerName <host>.<domain>.<tld>
   ServerAlias <domain>.<tld>
   DocumentRoot /var/www/html/owncloud
 </VirtualHost>
  • ln -s /etc/httpd/sites-available/<site>.conf /etc/httpd/sites-enabled/<site>.conf --> link a site to make it active

Enable HTTPS/SSL (optional)

I personally prefer doing this with a trusted certificate. Even possible for free with Let's Encrypt for example.

  • yum install mod_ssl --> install required components
  • cd /etc/pki/tls/certs --> goto folder
  • make server.key --> create key (give in passphrase and confirm)
  • openssl rsa -in server.key -out server.key (give in passphrase)
  • make server.csr (give in country, state, city, company, department, common name, email-address)
  • openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
  • nano /etc/httpd/conf.d/ssl.conf
 uncomment DocumentRoot “/var/www/html/owncloud”
 ServerName <host>.<domain>.<tld>:443
 SSLCertificateFile /etc/pki/tls/certs/server.crt
 SSLCertificateKeyFile /etc/pki/tls/certs/server.key
  • systemctl restart httpd --> restart Apache with new configuration