Install CiviCRM on Ubuntu 20.04

Updated on November 18, 2021
Install CiviCRM on Ubuntu 20.04 header image

Introduction

CiviCRM is an open-source Constituent Relationship Management (CRM) system primarily used by non-governmental, non-profit, and civic sector organizations. It is designed to manage information about an organization's members, relationships, donors, subscribers, grant application seekers, and case contacts. It has a wide variety of features to enable organizations to manage members, fundraising, and events. In this article, you will learn how to install CiviCRM on an Ubuntu 20.04 cloud server.

Prerequisites

1. Install LAMP Stack

Update system package manager.

$ sudo apt update

Add the ppa:ondrej/php PPA repository.

$ sudo apt -y install software-properties-common

$ sudo add-apt-repository ppa:ondrej/php

Update system package manager.

$ sudo apt update

Install PHP 7.4 and additional packages.

$ sudo apt install apache2 mariadb-server php7.4 libapache2-mod-php7.4 php7.4-common php7.4-sqlite3 php7.4-json php7.4-curl php7.4-intl php7.4-mbstring php7.4-xmlrpc php7.4-mysql php7.4-gd php7.4-xml php7.4-cli php7.4-zip php7.4-soap php7.4-imap php7.4-bcmath php7.4-mcrypt wget unzip -y

Edit the PHP configuration file.

$ sudo nano /etc/php/7.4/apache2/php.ini

Modify the following values, save and close the file:

To search for a specific line, use Control + W, enter search phrase then press Enter.

max_execution_time = 300    
memory_limit = 512M
upload_max_filesize = 100M

2. Install WordPress

Download the latest version of WordPress installation files.

$ wget https://wordpress.org/latest.zip

Extract the downloaded files.

$ sudo unzip latest.zip

Create installation directory /var/www/civicrm.

$ sudo mkdir /var/www/civicrm

Move files to the installation directory.

$ sudo mv wordpress/* /var/www/civicrm

Change ownership of the installation directory.

$ sudo chown -R www-data:www-data /var/www/civicrm

Change access permissions for the directory.

$ sudo chmod -R 755 /var/www/civicrm

3. Create a Database for WordPress

Log in to MySQL shell. Then at password prompt, press Enter to continue.

$ sudo mysql -u root -p

Create a database named wordpressdb;

CREATE DATABASE wordpressdb;

Create a database user named wordpressuser with a password. Replace WordpressStrongPassword with your secure password.

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'WordpressStrongPassword';

Grant the user full access to the database.

GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wordpressuser'@'localhost';

Save the changes.

FLUSH PRIVILEGES;

Exit the shell.

exit;

4. Install CiviCRM

Download the latest version of CiviCRM. To find the newest version, please visit the official download site.

$ wget https://download.civicrm.org/civicrm-5.41.2-wordpress.zip

Extract it to the directory /var/www/civicrm/wp-content/plugins/ directory.

$ sudo unzip civicrm-5.41.2-wordpress.zip -d /var/www/civicrm/wp-content/plugins/

5. Configure Apache

Create a virtual host in Apache.

$ sudo nano /etc/apache2/sites-available/civicrm.conf

Add the following content to the file, save and close the file:

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName example.com
    DocumentRoot /var/www/civicrm

    <Directory /var/www/civicrm>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

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

Change to Apache configuration files directory.

$ cd /etc/apache2/sites-available/

Enable the created virtual host configuration.

$ sudo a2ensite civicrm.conf

Disable the default Apache configuration.

$ sudo a2dissite 000-default.conf

Enable the Apache rewrite module.

$ sudo a2enmod rewrite

Restart Apache service for the changes to take effect.

$ sudo systemctl restart apache2

6. Access the Web Interface

Open http://Server_IP/ in a web browser and finish the WordPress installation. Login to the WordPress dashboard For example:

http://192.0.2.10/

Activate the CiviCRM plugin by logging in to your WordPress backend, and go to http://Server_IP/wp-admin/plugins.php. For example:

http://192.0.2.10/wp-admin/plugins.php

You can always log in to the WordPress dashboard by going to http://Server_IP/wp-admin/ to configure your site and make changes. For example:

http://192.0.2.10/wp-admin/

Conclusion

You have successfully installed WordPress and CiviCRM. After successfully activating CiviCRM, you can log out of the WordPress dashboard.

More Information

To learn more about: