OroCRM là một ứng dụng Trình quản lý quan hệ khách hàng (CRM) miễn phí và mã nguồn mở được xây dựng trên OroPl Platform. OroPl Platform là phần mềm nền tảng ứng dụng kinh doanh mã nguồn mở hoàn toàn tùy biến. OroPl Platform cung cấp cho bạn tất cả các tính năng cần thiết để tạo một ứng dụng tùy chỉnh. OroCRM được xây dựng bằng khung công tác PHP Symfony và lưu trữ dữ liệu của nó vào máy chủ cơ sở dữ liệu MySQL / MariaDB. Nó là một ứng dụng CRM dành cho doanh nghiệp cung cấp hàng tấn tính năng. Nó cũng tích hợp với nhiều ứng dụng của bên thứ 3 như Magento Store, MailChimp, Zendesk, v.v ... Nó là đa ngôn ngữ và có giao diện người dùng đáp ứng đầy đủ, cung cấp cho bạn khả năng quản lý nó bằng thiết bị di động.
Điều kiện tiên quyết
Trong hướng dẫn này, chúng tôi sẽ sử dụng crm.example.comlàm tên miền được trỏ đến máy chủ. Thay thế tất cả các lần xuất hiện crm.example.comvới tên miền thực của bạn.
Cập nhật hệ thống cơ sở của bạn bằng hướng dẫn Cách cập nhật CentOS 7 . Khi hệ thống của bạn đã được cập nhật, hãy tiến hành cài đặt các phụ thuộc cần thiết.
Cài đặt Nginx và PHP 7
OroCRM có thể được cài đặt trên bất kỳ máy chủ web sản xuất nào hỗ trợ PHP. OroCRM hỗ trợ tất cả các phiên bản PHP lớn hơn 7.0. Trong hướng dẫn này, chúng tôi sẽ sử dụng Nginx với PHP-FPM và PHP 7.1.
Cài đặt Nginx.
sudo yum -y install nginx
Bắt đầu Nginx và cho phép nó tự động bắt đầu khi khởi động.
sudo systemctl start nginx
sudo systemctl enable nginx
PHP 7 không có sẵn trong kho YUM mặc định, nhưng chúng ta có thể sử dụng kho Remi để lấy và cài đặt các bản dựng mới nhất của PHP 7. Đầu tiên, thêm và kích hoạt kho Remi.
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
Cài đặt phiên bản PHP 7 mới nhất cùng với các mô-đun PHP theo yêu cầu của OroCRM.
sudo yum -y install php php-fpm php-ctype php-curl php-fileinfo php-gd php-intl php-json php-mbstring php-mcrypt php-mysql php-pcre php-simplexml php-tokenizer php-xml php-zip php-tidy php-soap php-opcache php-posix
Chỉnh sửa tệp cấu hình PHP mặc định.
sudo nano /etc/php.ini
Tìm các dòng sau. Uncomment và thực hiện thay đổi như được hiển thị.
date.timezone = Asia/Kolkata
;Replace "Asia/Kolkata" with your appropriate timezone
memory_limit = 512M
cgi.fix_pathinfo=0
Chỉnh sửa tệp cấu hình PHP-FPM.
sudo nano /etc/php-fpm.d/www.conf
Theo mặc định, PHP-FPM được cấu hình để chạy với Apache và lắng nghe cổng 9000. Chúng tôi sẽ cần thay đổi người dùng và nhóm, cũng như tệp ổ cắm Unix mà nó sẽ chạy. Tìm các dòng sau và thực hiện các thay đổi cần thiết như được hiển thị.
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
Khởi động PHP-FPM và cho phép nó khởi động khi khởi động.
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
Cung cấp quyền sở hữu tệp ổ cắm PHP-FPM cho người dùng Nginx.
sudo chown nginx:nginx /var/run/php-fpm/php-fpm.sock
Cài đặt MariaDB
MariaDB là một ngã ba mã nguồn mở của MySQL. Cài đặt MariaDB.
sudo yum -y install mariadb mariadb-server
Start MariaDB and enable it to automatically start at boot.
sudo systemctl start mariadb
sudo systemctl enable mariadb
The default installation of MariaDB comes with a few test databases and anonymous users. Before configuring the database, you will need to secure the MariaDB server first. You can secure it by running the mysql_secure_installation script.
sudo mysql_secure_installation
You will be asked for the current MariaDB root password. By default, there is no root password in a fresh MariaDB installation. Press the Enter key to proceed. Set a strong password for the root user of your MariaDB server and answer Y to all the other questions asked. The questions asked are self-explanatory.
Create the Database for OroCRM
Log in to the MySQL shell as the root user by running.
mysql -u root -p
Provide the password for the MariaDB root user to log in.
Run the following queries to create a database and a database user for OroCRM installation.
CREATE DATABASE oro_data;
CREATE USER 'oro_user'@'localhost' IDENTIFIED BY 'StrongPassword';
GRANT ALL PRIVILEGES ON oro_data.* TO 'oro_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
You can replace the database name oro_data and username oro_user according to your choice. Be sure to change StrongPassword to a very strong password.
Install Node.js and Composer
OroCRM also requires Node.js JavaScript runtime. Node.js will be used by OroCRM to compile the JavaScript, which is used to build the user interface of the application. The default repository of CentOS contains an outdated version of Node.js, thus you will need to add the Nodesource repository to your system to obtain the latest version.
sudo curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
Install Node.js and Git.
sudo yum -y install nodejs git
Git will be used to clone the OroCRM repository from the internet. You will also need to install Composer. Composer is a dependency manager tool for PHP applications. Because OroCRM is written in Symfony framework, you will need Composer to install the dependencies and application.
Install Composer.
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.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 on your server. The most appropriate way to get the most updated version is to clone the repository through Git.
Clone the OroCRM repository.
cd /usr/share/nginx/
sudo git clone -b 2.3 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
Before you can proceed further, you will need to update the parameters.yml file to provide database and email information.
sudo nano app/config/parameters.yml
Find the following lines.
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: oro_crm
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: oro_data
database_user: oro_user
database_password: StrongPassword
If you have an SMTP server ready and you wish to use email sending features immediately, you can update the mailer settings as shown.
mailer_transport: smtp
mailer_host: mail.example.com
mailer_port: 456
mailer_encryption: ssl
mailer_user: [email protected]
mailer_password: EMailPassword
If you do not have a mail server ready, you can skip it for now by leaving the existing values. You can always change email configuration through the dashboard.
Set a random string in secret by replacing ThisTokenIsNotSoSecretChangeIt. A random string is required to encode the session data. An example string will look like this.
secret: uxvpXHhDxCFc9yU1hV1fMwjSoyVUzGh4WBMBBBa3XEgrRUF5OuB2h8iNl9JRDqcd
You can generate a random string using the pwgen utility. Install pwgen utility by running sudo yum -y install pwgen. To generate a random string, run pwgen -s 64 1.
Save the file and exit from the editor. Install the required PHP dependencies through composer.
sudo composer install --prefer-dist --no-dev
Using --no-dev will ensure that the Composer only installs the dependencies required to run the web server in production mode. The script will take a few minutes to download and install the required PHP dependencies.
Install the application.
sudo php app/console oro:install --env=prod
This will build the web cache and write the database. The --env=prod parameter is provided to install the application in production mode. The installation will only proceed if all the required dependencies are installed and configured.
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://crm.example.com
Organization name (OroCRM): My Organization
Username (admin):
Email: [email protected]
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
Configuring Nginx, Firewall and Permissions
Create an Nginx server block file to serve the application to the users.
sudo nano /etc/nginx/conf.d/orocrm.conf
Populate the file.
server {
server_name crm.example.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
# One week for javascript and css
location ~* \.(?:css|js) {
expires 1w;
access_log off;
add_header Cache-Control public;
}
# Three weeks for media: images, fonts, icons, video, audio etc.
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 crm.example.com with your actual domain name. The above configuration also includes the configuration required for GZip compression and browser caching. Gzip compression compresses the data before sending it to the browser. Enabling browser caching stores the static resources to the web cache of the client computer. The next time the user accesses the site, most of the static content is loaded from the user's own web cache. These two methods increase the speed of the application dramatically.
Check the Nginx configuration file for any errors.
sudo nginx -t
The output should look like the following.
[user@vultr ~]$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Provide the ownership of the OrOCRM files to the Nginx user.
sudo chown -R nginx:nginx /usr/share/nginx/orocrm
Restart Nginx to apply the new configuration.
sudo systemctl restart nginx
If you are running a firewall on your server, you will need to configure the firewall to set an exception for HTTP service. Allow Nginx to connect from outside the network.
sudo firewall-cmd --zone=public --permanent --add-service=http
sudo firewall-cmd --zone=public --permanent --add-service=https
sudo firewall-cmd --reload
You can now access the application at http://crm.example.com. Log in using the administrator username and password you have set during installation.
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 start supervisord
sudo systemctl enable supervisord
You can view the status of the processes by running the following.
sudo supervisorctl status
You should see that the processes are running.
[user@vultr ~]$ sudo supervisorctl status
oro_message_consumer:oro_message_consumer_00 RUNNING pid 13596, uptime 0:02:13
oro_message_consumer:oro_message_consumer_01 RUNNING pid 13595, uptime 0:02:13
oro_message_consumer:oro_message_consumer_02 RUNNING pid 13594, uptime 0:02:13
oro_message_consumer:oro_message_consumer_03 RUNNING pid 13593, uptime 0:02:13
OroCRM is now installed on your server. You can now use the application to manage the routine tasks of your organization. To learn more about OroCRM, you can visit its official website.