OwnCloud 8 on CentOS 6.6 Using Nginx and PHP-FPM

Earlier this week I decided to test drive ownCloud; an open source alternative to cloud sync services like Google Drive or Dropbox. The main difference is that you install and run ownCloud on your own server.

ownCloud provides packages for most Linux distributions including CentOS here; the advantage of installing from the package is that it will automatically install required dependencies and you can  update ownCloud with yum. If you use the ownCloud package, you will also need Remi’s RPM repository as CentOS 6 provides PHP 5.3 and ownCloud 8 requires PHP 5.4.

Since I already had a server running Nginx I decided to skip the package installation of ownCloud because it also installs Apache as a dependency. The steps below can be used to set up ownCloud 8 on CentOS using Nginx, PHP-FPM and MySQL.

Set up Nginx and Remi repos:

Install Nginx, MySQL and PHP components:

Start MySQL and run mysql_secure_installation script to create root password (answer Y to all questions):

Now create the database and user for ownCloud:

Create document root for Nginx and install ownCloud:

Edit /etc/php-fpm.d/www.conf to replace apache user with nginx on lines 39 and 41:

Give nginx user permissions on /var/lib/php/session (this fixed a redirect loop I was getting when trying to login):

Make sure services start automatically on boot:

Now you just need to configure Nginx to work with ownCloud; below is my configuration file that I made based on the ownCloud documentation here.

Once you have Nginx configured correctly, browse to your server and you will be greeted by the following screen where you will create the admin account and provide the details of the MySQL database you created earlier:


For added security, you can configure Fail2Ban to protect the ownCloud login page from brute force attempts by using the guide located here: http://www.tech-and-dev.com/2014/11/protecting-owncloud-against-bruteforce-attacks-with-fail2ban.html