CiviCRM is a free, open-source, and cloud-based CRM system specifically tailored to the needs of non-profit, civil society, and association-based organizations. CiviCRM can be installed with WordPress, Drupal or Joomla to track contacts and their relationships with projects and initiatives. Many well-known organizations use CiviCRM, including the Free Software Foundation, Creative Commons, Amnesty International, and the Wikimedia Foundation.

This tutorial will teach us how to install CiviCRM with WordPress on Ubuntu.

Prerequisites

  • A server running Ubuntu 18.04.
  • A root password is set up on your server.

First steps

Before you start, you need to update your system to the latest version. You can do this by running the following command:

apt-get update -y
 apt-get upgrade -y

Once your system has been updated, restart it to apply the changes.

Install the LAMP server

Next, you must install the Apache web server, MariaDB server, PHP, and other required packages in your system. You can install all the packages by running the following command:

apt-get install apache2 mariadb-server libapache2-mod-php7.2 php7.2 php7.2-curl php7.2-gd php7.2-mbstring php7.2-mysql php7.2-zip php-dev libmcrypt-dev unzip -y

Once all the packages are installed, you also need to install the PHP module mcrypt in your system. You can install it with pecl as shown below:

pecl channel-update pecl.php.net
 pecl install mcrypt-1.0.1

Next, open the php.ini file and make some settings.

nano /etc/php/7.2/cli/php.ini

Change the following lines:

memory_limit = 256M 
upload_max_filesize = 64M
short_open_tag = On	
max_execution_time = 300
default_charset = "UTF-8"
extension=mcrypt.so

Save and close the file when you’re done.

Create a database for WordPress and CiviCRM

First you need to create a database and a user for WordPress. To do this, log into the MySQL shell with the following command:

mysql -u root -p

Enter your root password when prompted and create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE wordpressdb;
 MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'password';

Then set the permissions with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;

Next, create a database and user for CiviCRM with the following command:

MariaDB [(none)]> CREATE DATABASE civicrmdb;
 MariaDB [(none)]> GRANT ALL PRIVILEGES ON civicrmdb.* TO 'wpuser'@'localhost' IDENTIFIED BY 'password';

Flush the permissions and exit the MySQL shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
 MariaDB [(none)]> EXIT;

Once you’re done with that, you can move on to the next step.

Install WordPress

First, download the latest version of WordPress from the official website by executing the following command:

cd /var/www/html/
 wget https://wordpress.org/latest.zip

Once the download is complete, unzip the downloaded file with the following command:

unzip latest.zip

Next, give the www-data user the permissions as shown below:

chown -R www-data:www-data /var/www/html/wordpress

When you’re done, you can proceed to the next step.

Configure Apache for WordPress

First, you need to create an Apache Virtual Host file for WordPress. You can create it with the following command:

nano /etc/apache2/sites-available/wordpress.conf

Paste the following lines:

     ServerAdmin [email protected]
     DocumentRoot /var/www/html/wordpress
     ServerName example.com
     ServerAlias www.example.com

     
          Options FollowSymlinks
          AllowOverride All
          Require all granted
     

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined


Save and close the file when you’re done. Then activate the Apache virtual host and the rewrite module with the following command:

a2ensite wordpress
 a2enmod rewrite

Finally, restart the Apache web service for the changes to take effect:

systemctl restart apache2

Now open your web browser, enter the URL http://example.com and exit the WordPress installation.

Install CiviCRM

First, download the latest version of CiviCRM from the official website by executing the following command:

wget https://download.civicrm.org/civicrm-5.19.1-wordpress.zip

Once the download is complete, unzip the downloaded file with the following command:

unzip civicrm-5.19.1-wordpress.zip

Next, move the unzipped directory to the /var/www/html/wordpress/wp-content/plugins/ directory:

mv civicrm /var/www/html/wordpress/wp-content/plugins/

Give the plugins directory the correct permissions with the following command:

chown -R www-data:www-data /var/www/html/wordpress/wp-content/plugins/
 chmod -R 777 /var/www/html/wordpress/wp-content/plugins/civicrm

Now open your web browser and enter the URL http://example.com/wp-admin/plugins.php. You should see the following screen:

How to Install CiviCRM on Ubuntu linux ubuntu

Now click on the Activate button to activate the CiviCRM plugin. You should see the following screen:

How to Install CiviCRM on Ubuntu linux ubuntu

Now go to the WordPress dashboard and click on the CiviCRM installer in the left pane. You should see the following page:

How to Install CiviCRM on Ubuntu linux ubuntu

Now enter your CiviCRM database details and click on the Check Requirements and Install CiviCRM button. Once the installation is complete. You should see the following screen:

How to Install CiviCRM on Ubuntu linux ubuntu

How to Install CiviCRM on Ubuntu linux ubuntu

Conclusion

Congratulations! You have successfully installed CiviCRM with WordPress on the Ubuntu 18.04 server. Now you can configure and extend CiviCRM according to your needs.