EspoCRM is a free and open source web-based customer relationship manager application. It is written in PHP and uses MySQL database server to store its data. It is responsive, has an easy to use web interface and comes with many languages. It can be used in various industries like wholesale and retails, e-commerce, banking, call centres etc. More than 20,000 small and medium companies are already using EspoCRM.
In this tutorial, we will install EspoCRM on CentOS 7 server.
Requirements
EspoCRM does not require any special hardware requirements. Recommended Memory requirement is 1GB. All the required dependencies will be installed throughout the tutorial. You will need a minimal installation of CentOS 7 with root access on it. If you are logged in as a non-root user, you can run sudo -i
to switch to root user.
Installing EspoCRM
Before installing any package it is recommended that you update the packages and repository using the following command.
yum -y update
Once you have your system updated, you can proceed to install the LAMP stack. Start the LAMP installation by installing Apache web server and MariaDB, which is a fork of MySQL using the following command.
yum -y install httpd mariadb-server mariadb
EspoCRM can be installed on any version of PHP greater than 5.5. Since PHP 5.5 has reached the end of life, we will install PHP 7.1 to obtain high performance and security. PHP 7.1 is not included in default YUM repository, hence you will need to add the Webtatic repository in your system. Webtatic repository requires EPEL repository to work. Run the following command to install EPEL repository.
yum -y install epel-release
yum -y update
Now install Webtatic repository using the following commands.
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y update
To install PHP 7.1 and all the required PHP modules, run the following command.
yum -y install php71w php71w-cli php71w-pdo php71w-json php71w-gd php71w-openssl php71w-zip php71w-imap php71w-mbstring php71w-pdo_mysql php71w-curl
Once you have PHP installed, you can check the version of PHP using the following command.
php -v
You should get output similar to this.
[root@liptan-pc ~]# php -v
PHP 7.1.5 (cli) (built: May 12 2017 21:54:58) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
You will also need to make a change into PHP configuration file /etc/php.ini
. Open /etc/php.ini
using your favorite editor.
nano /etc/php.ini
If you do not have nano installed, you can install it using yum -y install nano
. Scroll down to find the following lines.
[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
Remove the semicolon from the start of the line and provide the appropriate time zone. For example
date.timezone = Asia/Kolkata
Now find the following lines and change the values according to instructions given.
memory_limit = 128M #Change the value to at least 256M
upload_max_filesize = 2M #Change the value to at least 50M
post_max_size = 8M #Change the value to at least 50M
max_execution_time = 30 #Change the value to at least 180
max_input_time = 180 #Change the value to at least 180
Save the file and exit from editor. Now start Apache web server and enable it to start at boot time using the following command.
systemctl start httpd
systemctl enable httpd
To start MariaDB and enable it to start at boot time using the following commands.
systemctl start mariadb
systemctl enable mariadb
Now run the following commands to secure your MySQL or MariaDB installation.
mysql_secure_installation
It will run a small script which asks you to provide the root password for MariaDB. As we have just installed MariaDB, the root password is not set, just press enter to proceed further. It will ask you if you want to set a root password for your MariaDB installation, choose y
and set a strong password for the installation. It will also ask you for removing test databases and anonymous users. Most of the questions are self-explanatory and you should answer y
to all the questions.
To create a database we will need to login to MySQL command line first. Run the following command.
mysql -u root -p
This will prompt you for the password, provide the root password of MySQL which you have set earlier. Now run the following query to create a new database for your EspoCRM installation.
CREATE DATABASE ecrm_data;
The above query will create a database named ecrm_data
. Make sure that you use semicolon at the end of each query as the query always ends with a semicolon. Once the database is created you can create a new user and grant all the permissions to the user for the database. Using root user is not recommended for the databases. To create a new database user, run the following query.
CREATE USER 'ecrm_user'@'localhost' IDENTIFIED BY 'StrongPassword';
The above query will create a user with username ecrm_user
. Now provide the appropriate privileges to your database user over the database you have created. Run the following command.
GRANT ALL PRIVILEGES ON ecrm_data.* TO 'ecrm_user'@'localhost';
Now run the following command to immediately apply the changes on the database privileges.
FLUSH PRIVILEGES;
Exit from MySQL prompt using exit
command.
As we have all the dependencies ready, we can now download the install package from EspoCRM website.
cd /var/www
wget https://www.espocrm.com/downloads/EspoCRM-4.7.0.zip
You can always find the link to the latest version of the application on EspoCRM download page.Extract the archive using the following command.
unzip EspoCRM*.zip
If you don’t have unzip installed, you can run yum -y install unzip
. The above command will extract the content of the archive to EspoCRM-4.7.0
directory. Rename the directory using the following command.
mv EspoCRM-4.7.0 espocrm
Now you will need to disable your SELinux. To temporary disable SELinux, run the following command.
setenforce 0
To completely disable the SELinux you will need to edit /etc/selinux/config
file.
nano /etc/selinux/config
Find the following line:
SELINUX=enforcing
Change it to:
SELINUX=disabled
Now, you will need to provide the ownership of the application to web server user using the following command.
chown -R apache:apache /var/www/espocrm
You will also need to set the appropriate permissions to the files and directories, Run the following commands for same.
cd /var/www/espocrm
find . -type d -exec chmod 755 {} + && find . -type f -exec chmod 644 {} +;
find data custom -type d -exec chmod 775 {} + && find data custom -type f -exec chmod 664 {} +;
You may also need to allow HTTP traffic on port 80
through the firewall if you are running one. Run the following commands for same.
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --reload
Now create a virtual host for the EspoCRM application. Run the following command to do so.
nano /etc/httpd/conf.d/crm.yourdomain.com.conf
Paste the following lines into the file.
<VirtualHost *:80>
ServerAdmin me@liptanbiswas.com
DocumentRoot "/var/www/espocrm"
ServerName crm.yourdomain.com
ServerAlias www.crm.yourdomain.com
<Directory "/var/www/espocrm">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/httpd/crm.yourdomain.com-error_log"
CustomLog "/var/log/httpd/crm.yourdomain.com-access_log" combined
</VirtualHost>
Replace crm.yourdomain.com
with any domain or sub-domain you want to use to access the application. Save the file and exit from the editor. Run the following command to restart your Apache server.
systemctl restart httpd
Now complete the installation using a web browser, go to the following link using your favourite web browser.
http://crm.yourdomain.com
You will be welcomed by the following page.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/264286233.png” alt=”” />
Click on Start button to go to the next step of installation. In this step, you will need to provide the details of the database you created earlier to store EspoCRM data. Provide the database username, password and database name. Click Test Connection button to check the connection.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/1960638531.png” alt=”” />
Click Next button to proceed to the next step. The installer will check if your system meets all the requirements needed to install the software. If you have followed the tutorial correctly, you should have all the requirements satisfied.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/816567527.png” alt=”” />
Click Install button. You will now need to provide administrator account details.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/650445581.png” alt=”” />
Click on Next button. Now you will need to provide some system settings.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/1218996660.png” alt=”” />
Choose the date and time format. Select the timezone and the first date of the week. Choose currency and language and click Next.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/1024210456.png” alt=”” />
Provide your mail server details and click Next. The software is now installed. Proceed to login page and login using the administrator account credentials. You will see the following screen.
HP_NO_IMG/data/uploads/users/96ef1f90-83ed-46f0-9b58-aa6ee50a1451/2106605132.png” alt=”” />
Finally, you will need to add a cron job for executing EspoCRM scheduled tasks. Run the following command to open crontab editor.
crontab -e
Paste the following line into the file.
* * * * * cd /var/www/espocrm; /usr/bin/php -f cron.php > /dev/null 2>&1
Conclusion
In this tutorial, we learned how to install EspoCRM on CentOS 7. You can now successfully deploy the EspoCRM application to manage the relationships with your customers, which will increase the sales and revenue.