August 30, 2013

ownCloud with Apache, SSL, and MariaDB on CentOS 6.4 X64

 Here is the procedure for installing ownCloud on CentOS 6.4 x64



1. Install CentOS 6.4 x64 from media.
2. Add repositories: rpm -Uvh http://mirror.cogentco.com/pub/linux/epel/6/x86_64/epel-release-6-8.noarch.rpm | rpm –Uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm 
3. Create a repository for MariaDB: vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 5.5 CentOS repository list - created 2013-08-30 14:03 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

4. Let’s get some packages: yum update –y | yum install –y httpd php MariaDB-server MariaDB-client php-mysql apr-util-ldap mailcap ntp ntpdate php-cli php-gd php-mbstring php-pear php-pear-MDB2 php-pear-MDB2-Driver-mysqli php-pear-Net-Curl php-process php-xml samba-client mod_ssl

5. Start services set to start on boot: chkconfig httpd on | service httpd start | chkconfig mysql on | service mysql start

6. Secure MariaDB: mysql_secure_installation

7. Create a database and user for ownCloud: mysql –u root –p

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS owncloud;
GRANT ALL PRIVILEGES ON owncloud.* TO 'username'@'localhost' IDENTIFIED BY 'password';
8. Download the ownCloud repository and install ownCloud:
cd /etc/yum.repos.d
wget http://download.opensuse.org/repositories/isv:ownCloud:community/CentOS_CentOS-6/isv:ownCloud:community.repo
yum install owncloud
9. Configure ownCloud to use MariaDB: vi /var/www/html/owncloud/config/config.php
 "dbtype"        => "mysql",
  "dbname"        => "owncloud",
  "dbuser"        => "username",
  "dbpassword"    => "password",
  "dbhost"        => "localhost",
  "dbtableprefix" => "",
10. Create a self-signed SSL certificate for the site: mkdir /etc/ssl/Apache | cd /etc/ssl/apache  | openssl genrsa –out cloud.example.com.key 2048 | openssl req –new –key cloud.example.com.key –out cloud.example.com.csr | openssl x509 –req –days 365 –in cloud.example.com.csr –signkey cloud.example.com.key –out cloud.example.com.crt
11. Create a virtual host on Apache for our SSL certificate: vi /etc/httpd/conf.d/owncloud-ssl.conf

LoadModule ssl_module modules/mod_ssl.so
Listen 443


<VirtualHost *:80>
      ServerName cloud.example.com
      Redirect /
https://cloud.example.com
</VirtualHost>
<VirtualHost *:443>
      ServerName cloud.example.com
      SSLEngine on
      SSLCertificateFile /etc/ssl/Apache/cloud.example.com.crt
      SSLCertificateKeyFile /etc/ssl/Apache/cloud.example.com.key
      DocumentRoot /var/www/html/owncloud
</VirtualHost>
12. Move an unused Apache config files:
cd /etc/httpd/conf.d
mv ssl.conf ssl.conf.bak
mv welcome.conf welcome.conf.bak
13. Restart Apache and log into ownCloud:
service httpd restart
http://cloud.example.com