Install CiviCRM on WordPress with Nginx

Over the weekend I installed a copy of CiviCRM on WordPress to demo for a small nonprofit that recently asked me to help with some of their data needs. CiviCRM is a constituent relationship management (CRM) system designed for nonprofit organizations. While I installed it as a WordPress plugin, it’s also available for Joomla and Drupal.

Install CiviCRM on WordPress with Nginx

This guide was written using:

WordPress 4.0.1,

CiviCRM 4.5.4

Nginx 1.6.2

MariaDB 10.0.15 (as a replacement for MySQL)

PHP 5.5.9

Ubuntu 14.04 LTS

Nginx, MariaDB or MySQL, and PHP/PHP-FPM should already be installed. Instructions for installing Nginx and MariaDB are can be found in my earlier LEMP stack tutorial. If you’re just interested in using PHP and not other languages like Python, you can substitute PHP-FPM for uWSGI.

Create CiviCRM and WordPress databases

While CiviCRM and WordPress can use the same database, it’s cleaner to keep them separate.

From the command line, log into MySQL/MariaDB as as root or your administrative user.

Create site directory and configure Nginx

For now, just create the root directory where you’ll be placing the WordPress files.

james@localhost:~$ mkdir -p /srv/www/democivi/public

Create the Nginx site configuration file.

james@localhost:~$ nano /etc/nginx/sites-available/democivi

This server block is probably familiar if you serve any other PHP sites with Nginx. It starts with standard directives telling Nginx where and how to listen for requests as well as where to look for files.

CiviCRM checkUploadsAreNotAccessible error

This last location directive tells Nginx to block HTTP access to files in the CiviCRM uploads directory. Without blocking access to these files, CiviCRM will display warning messages such as checkUploadsAreNotAccessible.

If reapplying permissions and changing the owner of /wp-content/ isn’t sufficient, you may need to change the ownership of all files to match the the Nginx and PHP-FPM users. If you use shared hosting and the Nginx/PHP-FPM user is something like www-data, www, nobody, or nginx then this isn’t a good idea.

Complete WordPress Installation

Run the WordPress installation by accessing your site with a web browser. The process is quick and easy, you just have to enter your MySQL/MariaDB credentials along with a few other settings and submit.

If the process was successful, you’ll be prompted to create an admin user and provide some basic information about your new site.

Download and Install CiviCRM on WordPress with Nginx

Switch to the directory below your site’s root if you’re not already there.

james@localhost:~$ cd /srv/www/democivi

Download the appropriate source file from SourceForge.net. The URL will look something like http://sourceforge.net/projects/civicrm/files/civicrm-stable/4.5.4/civicrm-4.5.4-wordpress.zip/download.

Log into WordPress using your administrator account and go to the Plugins page, http://yoururl/wp-admin/plugins.php. Click Activate under the CiviCRM listing.

CiviCRM installer

With the CiviCRM plugin activated, go to CiviCRM Installer under Settings, http://yoururl/wp-admin/options-general.php?page=civicrm-install.

On the CiviCRM Installer screen the red requirements have not been met. Many are red just because it doesn’t have your database settings yet. Go ahead and enter them and click Re-Check Requirements to refresh the screen. If everything is in order the bars will turn green and a Check Requirements and Install CiviCRM button will appear.

Click the button to finish installing CiviCRM on WordPress. Upon refreshing your dashboard, a CiviCRM icon will appear on the left menu. Congrats on your install of CiviCRM on WordPress with Nginx!

Could not create a trigger

If CiviCRM can connect to the database but complains about not being able to create triggers (and you’re using MySQL version 5.1.6 or higher), you may have binary logging enabled. If that’s the case, adding a line to to your MariaDB/MySQL configuration will resolve the problem.