How to Install OroCRM on CentOS 7

Spread the love

 

How to Install OroCRM on CentOS 7

In this tutorial, we will provide you a detailed instruction on how to install OroCRM Community Edition, on CentOS 7.OroCRM is a free and open source CRM software. It is very flexible, easy to use, and it can integrate with other softwares like Magento. It cames with buil-in automation tools for marketing your eCommerce business. OroCRM is complete CRM solutions for both sales and marketing. Let’s get started with the installation of OroCRM on your Ubuntu 16.04 Virtual Server

Install Nginx, run and enable it on boot.

In this tutorial, we will use Nginx with PHP-FPM and PHP 7.1, we have to use PHP version higher than 7.0 to install OroCRM

sudo yum -y install nginx
sudo systemctl start nginx
sudo systemctl enable nginx

We will use Remi repository to install the latest builds of PHP 7. First, we have to add and enable the repository.

sudo rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php71

Install PHP 7.1 with the required modules

sudo yum -y install php php-fpm php-ctype php-curl php-intl php-json php-mbstring php-mcrypt php-fileinfo php-gd php-tokenizer php-xml php-mysql php-pcre php-simplexml php-zip php-posix php-tidy php-soap php-opcache

Edit the default PHP configuration file.

sudo nano /etc/php.ini

Increase memory limit and change your timezone value

date.timezone = America/Los_Angeles
memory_limit = 512M
cgi.fix_pathinfo=0

Edit the PHP-FPM configuration file.

sudo nano /etc/php-fpm.d/www.conf

We will change php-fpm default configuration, its user and group, and the listening port to Unix socket file.

user = nginx
group = nginx

;listen = 127.0.0.1:9000

Comment out or remove the above line and add the following line.

listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nobody
listen.group = nobody

Start PHP-FPM and enable it to start at boot.

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

Change the ownership of PHP-FPM socket file to Nginx user.

sudo chown nginx:nginx /var/run/php-fpm/php-fpm.sock

Install MariaDB

sudo yum -y install mariadb mariadb-server

Start MariaDB and enable it at boot.

sudo systemctl start mariadb
sudo systemctl enable mariadb

Then, we need to run mysql_secure_installation script to secure MariaDB Server.

sudo mysql_secure_installation

In this step, you will be asked for the current MariaDB root password. Then, set a strong password for the root user and answer Y to all the other questions asked thereafter.

Create the Database for OroCRM

Log in to the MySQL shell as the root user by running.

mysql -u root -p

You will be asked for MariaDB root password you created earlier.

Run the following queries to create a database and a database user for OroCRM installation.

CREATE DATABASE orocrm_db;
GRANT ALL PRIVILEGES ON orocrm_db.* TO 'orocrm_user'@'localhost' IDENTIFIED BY 'ModifyThisPassword';;
FLUSH PRIVILEGES;
EXIT;

Make sure to change ModifyThisPassword to a very strong and hard to guess password.

Install Node.js, Git and Composer

sudo curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash -

sudo yum -y install nodejs git

Install Composer.

sudo curl -sS https://getcomposer.org/installer | php

Move Composer to the /usr/bin directory so that it can be executed from anywhere in the system.

sudo mv composer.phar /usr/bin/composer

Provide execution permission to the Composer.

sudo chmod +x /usr/bin/composer

Install OroCRM

There are many ways to download OroCRM (https://oroinc.com/orocrm/download), the most appropriate way to get the most updated version is to clone the repository through Git.

cd /usr/share/nginx/
sudo git clone -b 2.6.1 https://github.com/oroinc/crm-application.git orocrm

Copy the example parameters file to the default parameters file used by OroCRM.

cd orocrm
sudo cp app/config/parameters.yml.dist app/config/parameters.yml

next step is to  update the parameters.yml file to provide database configuration.

sudo nano app/config/parameters.yml

Find the following lines.

database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: orocrm
database_user: root
database_password: ~

Update the above configuration according to the database you have created to store OroCRM data. In our case, it should look like this.

database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: 3306
database_name: orocrm_db
database_user: orocrm_user
database_password: ModifyThisPassword

If you have an SMTP server and you wish to use email sending feature, you can update the mailer settings.
You can also skip it by leaving the existing values. You can always change email configuration through the dashboard.

Set a random string in secret by replacing ThisTokenIsNotSoSecretChangeIt.

secret: mlDVXWO7QbGmwVz98Rq3TrKMNJQuTuwtrIs3RKWfjJuluI4N7ClrJmr6ksuw6cEU

You can generate a random string using the pwgen utility.
To generate a random string, run

pwgen -s 64 1

If you don’t have pwgen, you can install the utility by running

sudo yum install pwgen -y

Save the file and exit from the editor.

Install the required PHP dependencies through composer.

sudo composer install --prefer-dist --no-dev

–no-dev means that the Composer will only install the dependencies required to run the web server in production mode.
Install the application.

sudo php app/console oro:install --env=prod --timeout=600

This will build the web cache and write the database. The installation will only proceed if all required dependencies are installed.

During the installation, you will be asked few questions for setting up the administrator account. The questions are as follows.

Administration setup.
Application URL (http://localhost): http://orocrm.yourdomain.com
Organization name (OroCRM): My Organization
Username (admin):
Email: mail@example.com
First name: John
Last name: Doe
Password:
Load sample data (y/n): y

Provide the information. Load the sample data to evaluate the product before using it for production.

Warm up the API documentation cache:

sudo php app/console oro:api:doc:cache:clear

Configure Nginx

Create an Nginx server block file to serve the application to the users.

sudo nano /etc/nginx/conf.d/orocrm.yourdomain.conf
server {
server_name orocrm.yourdomain.com;
root /usr/share/nginx/orocrm/web;

location / {
# try to serve file directly, fallback to app.php
try_files $uri /app.php$is_args$args;
}

location ~ ^/(app|app_dev|config|install)\.php(/|$) {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}

# Enable Gzip compression
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_min_length 1000;
gzip_http_version 1.0;
gzip_proxied any;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css image/svg+xml;
gzip_vary on;

# enable browser caching
location ~* \.(?:css|js) {
expires 1w;
access_log off;
add_header Cache-Control public;
}

location ~* \.(?:jpg|jpeg|gif|png|ico|tiff|woff|eot|ttf|svg|svgz|mp4|ogg|ogv|webm|swf|flv)$ {
expires 3w;
access_log off;
add_header Cache-Control public;
}

error_log /var/log/nginx/orocrm_error.log;
access_log /var/log/nginx/orocrm_access.log;
}

Make sure that you change the orocrm.yourdomain.com with your actual domain name.

Check the Nginx configuration file for any errors.

sudo nginx -t

Make sure you don’t see any error messages.

Provide the ownership of the OrOCRM files to the Nginx user.

sudo chown -R nginx: /usr/share/nginx/orocrm

Restart Nginx to apply the new configuration.

sudo systemctl restart nginx

Setup Scheduled Tasks and Background Jobs
To automatically run the scheduled tasks you can add a Cron job entry. Open crontab.

sudo crontab -e

Add the following line to the file.

*/1 * * * * /usr/bin/php /usr/share/nginx/orocrm/app/console oro:cron --env=prod > /dev/null

This will run the cron job every minute so that the scheduled tasks such as email queues are processed earliest.

You will also need to setup Supervisor to run the Message Queue service. It is required that at least one process is running at all times for a consumer to process the messages. A consumer can normally interrupt the message process through many ways. To ensure that the service is running continuously, we will use the Supervisor service. We will configure Supervisor to run four processes in parallel. If any of the four processes is stopped for any reason, the Supervisor will try to start it again.

Install Supervisor

sudo yum -y install supervisor

Edit the Supervisor configuration file

sudo nano /etc/supervisord.conf

Add the following lines at the end of the file

[program:oro_message_consumer]
command=/usr/bin/php /usr/share/nginx/orocrm/app/console --env=prod --no-debug oro:message-queue:consume
process_name=%(program_name)s_%(process_num)02d
numprocs=4
autostart=true
autorestart=true
startsecs=0
user=nginx
redirect_stderr=true

Start and enable Supervisor to automatically start at boot time.

sudo systemctl enable supervisord
sudo systemctl start supervisord

OroCRM is now installed on your server at http://orocrm.yourdomain.com. Log in using the administrator username and password you have set earlier during the installation. To learn more about OroCRM, you can visit its official website.

PS. If you liked this post, on how to install OroCRM on Ubuntu 16.04, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

 

Be the first to write a comment.

Your feedback