如何在 Debian 9 上安装 EspoCRM 开源 CRM 软件如何在 Debian 9 上安装 EspoCRM 开源 CRM 软件如何在 Debian 9 上安装 EspoCRM 开源 CRM 软件如何在 Debian 9 上安装 EspoCRM 开源 CRM 软件
  • 文章
  • 正则表达式
    • 工具
  • 登录
找到的结果: {phrase} (显示: {results_count} 共: {results_count_total})
显示: {results_count} 共: {results_count_total}

加载更多搜索结果...

搜索范围
模糊匹配
搜索标题
搜索内容
发表 admin at 2025年2月28日
类别
  • 未分类
标签

如何在 Debian 9 上安装 EspoCRM 开源 CRM 软件

在本指南中,我们将向您展示如何在 LAMP 堆栈之上的 Debian 9 上安装和配置最新版本的 EspoCRM 软件,以便为您的公司创建一个免费的在线客户关系管理平台。

EspoCRM 是一个灵活且易于使用的开源客户关系管理 (CRM) 平台,旨在快速、简单和可定制。该软件主要用 PHP 编程语言编写,可以轻松部署在 Apache 或 Nginx 网络服务器、PHP 编程语言和 MySQL 或 MariaDB 数据库管理系统之上的 Linux 中。 EspoCRM 支持多种语言,可以部署在呼叫中心、银行、教育、医疗保健、旅游、零售、房地产或电子商务业务中。

要求

  • 在 Debian 9 操作系统的虚拟机或物理服务器上进行最小安装
  • 根帐户权限或通过 sudo 命令具有根权限的帐户(通过控制台进行本地访问或通过 SSH 进行远程访问)
  • 配置了静态 IP 地址的服务器 NIC 之一
  • 一个公共注册域名,以便您通过网络界面执行安装并访问应用程序网站。在 Intranet 中,您可以通过本地域或通过您的服务器 IP 地址访问该应用程序
  • 在您的场所配置的邮件服务器或访问公共电子邮件服务,例如 Gmail、Outlook、Yahoo!

先决条件

首先,登录到您的 Debian 服务器控制台,并确保通过发出以下命令更新系统存储库、内核和软件包。

apt update
apt upgrade

接下来,通过执行以下命令配置机器主机名。请确保将本主题中使用的主机名值替换为您自己的表示法。

hostnamectl set-hostname www.mycrm.org

发出以下命令以检查机器主机名是否已正确配置。

hostnamectl
cat /etc/hostname
hostname –s
hostname –f

最后,重启 Debian 服务器以应用内核更新并正确更改主机名。

systemctl reboot

接下来,您应该在 Debian 系统中安装 LAMP 软件包。第一步,通过在服务器控制台中运行以下命令,安装 Apache Web 服务器和 PHP 处理网关解释器以及应用程序正常运行所需的所有必需 PHP 模块。

apt install apache2 libapache2-mod-php7.0 php7.0 php7.0-gd php7.0-opcache php7.0-mbstring php7.0-xml php7.0-json php7.0-zip php7.0-curl php7.0-imap php7.0-soap php7.0-mcrypt php-mailparse

接下来,安装 RDBMS 数据库后端。在本指南中,我们将配置 EspoCRM 应用程序以使用 MariaDB 数据库作为后端。发出以下命令以安装 MariaDB 数据库和访问 MySQL 数据库所需的 PHP 模块。

apt install mariadb-server php7.0-mysql mariadb-client

Apache、MySQL数据库和PHP安装完成后,打开PHP默认配置文件进行编辑,修改如下PHP变量。确保最初备份 PHP 配置文件。

cp /etc/php/7.0/apache2/php.ini{,.backup}
nano /etc/php/7.0/apache2/php.ini

在 php.ini 配置文件中搜索、编辑和更改以下变量:

file_uploads = On
default_charset = UTF-8
memory_limit = 256M
post_max_size = 50M
upload_max_filesize = 50M
memory_limit = 256M
max_input_time = 180
max_execution_time = 180
zend.assertions = 0
date.timezone = Europe/London

通过在以下链接 http://php.net/manual/ 中查阅 PHP 文档提供的时区列表,根据您的物理时间替换 time.zone 变量en/timezones.php

为了通过 PHP7 中可用的 OPCache 插件提高应用程序页面的加载速度,请在 PHP 解释器配置文件底部的 [opcache] 下方插入以下 OPCache 代码行/strong>声明,具体如下:

opcache.enable=1 
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

关闭 php.ini 配置文件并检查变量是否已正确添加,您可以通过发出以下命令来执行此操作。

grep opcache /etc/php/7.0/apache2/php.ini| grep -v ";"

接下来,通过发出以下命令,在您的系统中添加以下 UFW 防火墙应用程序规则,以允许 HTTP 流量通过防火墙。

ufw allow WWW

或者

ufw allow 80/tcp

一些系统管理员更喜欢使用 iptables 原始规则来管理 Debian 服务器中的防火墙规则。在 iptables 的情况下,发出以下命令来安装防火墙并添加以下规则以允许端口 80 和 22(在 SSH 远程连接的情况下)入站流量,以便您可以访问系统并通过 Web 浏览器浏览应用程序。

apt-get install -y iptables-persistent
iptables -I INPUT -p tcp --destination-port 80 -j ACCEPT
iptables -I INPUT -p tcp --destination-port 22 -j ACCEPT
netfilter-persistent save
systemctl restart netfilter-persistent
systemctl status netfilter-persistent
systemctl enable netfilter-persistent.service

最后,打开浏览器并通过 HTTP 协议访问您的 Debian 机器 IP 地址或您的域名。如果您不知道您的机器 IP 地址,请执行 ifconfig 或 ip a 命令来获取您服务器的 IP 地址。如果已建立与 Web 服务器的连接,您应该能够在浏览器中查看 Apache Web 服务器默认网页。

http://your_domain.tld

在下一步中,通过发出以下命令启用 EspoCRM 正确运行所需的 Apache 重写和压缩 SSL 模块。

a2enmod rewrite deflate ssl

SSL 模块要求您还启用默认的 SSL 配置文件,以便通过 HTTPS 协议访问应用程序。 HTTPS 协议用于保护服务器和客户端之间的流量。执行以下命令以启用 Apache SSL 站点配置文件。

a2ensite default-ssl.conf

然后,使用文本编辑器打开 Apache 默认 SSL 站点配置文件,并在 DocumentRoot 指令后插入以下代码行,如下例所示,以激活放置在 .htaccess 文件中的规则。 .htaccess 文件通常位于您的域 webroot 之上。

nano /etc/apache2/sites-enabled/default-ssl.conf

SSL 站点配置文件摘录:

<Directory /var/www/html>
  Options +FollowSymlinks
  AllowOverride All
  Require all granted
</Directory>

您还应该打开 /etc/apache2/sites-enabled/000-default.conf 文件进行编辑并添加相同的 URL 重写规则插入到 SSL 配置文件中。在 DocumentRoot 语句之后添加代码行,如下例所示。

<Directory /var/www/html>
  Options +FollowSymlinks
  AllowOverride All
  Require all granted
</Directory>

最后,重新启动 Apache 守护程序以应用到目前为止配置的所有规则并通过 HTTPS 协议访问您的域。因为您使用的是 Apache 在安装时自动颁发的自签名证书对,该证书不受浏览器信任,因此浏览器中应显示不安全的连接错误警告。接受警告以接受不受信任的证书并继续被重定向到 Apache 默认网页。

systemctl restart apache2

https://yourdomain.tld

如果您计划在互联网上公开您的 EspoCRM 生产平台,您应该考虑购买由受信任的证书颁发机构颁发的证书或从 Let's Encrypt CA 获得免费证书对,以便客户可以访问应用程序而不会在浏览器中显示错误.

如果 UFW 防火墙应用程序阻止到 HTTPS 端口的传入网络连接,您应该通过发出以下命令添加一个新规则以允许 HTTPS 流量通过防火墙。

ufw allow HTTPS

或者

ufw allow 443/tcp

对于iptables防火墙,在防火墙中添加如下规则,允许443端口入站流量,这样就可以浏览域名了。保存并重启 iptables 服务,以便在系统重启后应用规则。

iptables -I INPUT -p tcp --destination-port 443 -j ACCEPT
netfilter-persistent save
systemctl restart netfilter-persistent
systemctl status netfilter-persistent

最后,通过执行以下命令在您的域 webroot 路径中创建一个 PHP 信息文件。

echo '<?php phpinfo(); ?>'| tee /var/www/html/info.php

通过从浏览器访问以下 URL 中的 PHP 信息脚本文件来检查 PHP 设置和时区配置,如下图所示。向下滚动到日期 设置以检查 PHP 时区配置。

https://domain.tld/info.php

在下一步中,登录到 MySQL 服务器控制台并通过执行以下命令保护 MariaDB root 帐户。输入 exit 退出数据库控制台。

mysql -h localhost
Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

 

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 使用 mysql;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

 

Database changed

MariaDB [mysql]> update user set plugin= where user=root;

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [mysql]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

MariaDB [mysql]> exit

Bye

此外,执行 mysql_secure_installation 脚本以进一步保护 MariaDB 守护进程。在运行脚本时,系统会询问您一系列旨在保护 MariaDB 数据库安全的问题,例如:更改 MySQL root 密码、删除匿名用户、禁用远程 root 登录和删除测试数据库。对所有询问的问题输入“是”,如下面的摘录所示。

mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

 

In order to log into MariaDB to secure it, we'll need the current

password for the root user.  If you've just installed MariaDB, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

 

Enter current password for root (enter for none):

OK, successfully used password, moving on...

 

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

 

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] y

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

 ... Success!

 

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

 

Remove anonymous users? [Y/n] y

 ... Success!

 

Normally, root should only be allowed to connect from 'localhost'.  This

ensures that someone cannot guess at the root password from the network.

 

Disallow root login remotely? [Y/n] y

 ... Success!

 

By default, MariaDB comes with a database named 'test' that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

 

Remove test database and access to it? [Y/n] y

 - Dropping test database...

 ... Success!

 - Removing privileges on test database...

 ... Success!

 

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

 

Reload privilege tables now? [Y/n] y

 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

通过不使用 root 密码尝试通过控制台登录数据库来验证 MariaDB 服务器安全问题。如果没有为 root 帐户提供密码,则应拒绝对数据库的访问,如以下命令摘录所示:

mysql -h localhost -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

现在,尝试使用 root 密码登录数据库。您应该能够访问 MySQL 控制台,如以下命令示例所示:

mysql -h localhost -u root -p
Enter password:

Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 15

Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> exit

Bye

安装 EspoCRM

在 Apache HTTP 服务器之后,MariaDB 守护程序和 PHP 解释器已正确配置,以便在您的 Debian 系统中安装 EspoCRM 应用程序。执行以下命令以安装其中提到的命令行实用程序。

apt install wget bash-completion zip unzip curl

下一步,访问 EspoCRM 官方下载页面 https://www.espocrm.com/download/ 并通过 wget 实用程序获取系统中最新的 zip 包压缩存档。在编写本教程时 EspoCRM 的当前版本是 EspoCRM-5.0.3

wget https://www.espocrm.com/downloads/EspoCRM-5.0.3.zip
ls

zip 存档下载完成后,将 zip 存档文件解压缩到当前工作目录,并通过发出以下命令列出解压缩的文件。该应用程序的安装文件位于EspoCRM-5.0.3 目录中。

unzip EspoCRM-5.0.3.zip
ls
ls -al EspoCRM-5.0.3

接下来,确保从 webroot 目录中删除 index.html 和 info.php 文件:

rm /var/www/html/index.html
rm /var/www/html/info.php

通过发出以下命令,将提取目录中的所有文件复制到您的 Web 服务器文档根路径。另外,确保将隐藏文件 .htaccess 复制到 webroot 路径。

cp -rf EspoCRM-5.0.3/* /var/www/html/
cp EspoCRM-5.0.3/.htaccess /var/www/html/

接下来,执行以下命令以授予 Apache www-data 帐户对 Web 根路径的完全写入权限。使用 ls 命令列出位于 /var/www/html/ 目录中的 EspoCRM 安装文件的权限。

chown -R www-data:www-data /var/www/html/
ls –al /var/www/html/

接下来,登录MariaDB数据库控制台,创建EspoCRM数据库。为数据库使用一个描述性名称,并创建一个具有强密码的用户来管理该数据库。用您自己的值替换此示例中使用的数据库名称、用户和密码。用于此步骤的命令显示在下面的摘录中。

mysql –u root -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.

Your MariaDB connection id is 2

Server version: 10.1.26-MariaDB-0+deb9u1 Debian 9.1

 

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 创建数据库 espocrm_db;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on espocrm_db.* to crm_user@localhost identified by password1234;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit

Bye

现在,打开浏览器,通过HTTPS协议访问您服务器的IP地址或域名,即可进行EspoCRM平台安装过程。在第一个安装屏幕上,EspoCRM 安装程序将显示一条欢迎消息和一个列表,您可以从中选择安装语言。从显示的列表中选择合适的语言,然后点击“开始”按钮以开始安装过程,如下图所示。

https://yourdomain.tld

在下一个屏幕中,阅读许可协议声明并选中“我接受协议t”复选框,然后点击“下一步”按钮进入下一步。

在下一个安装屏幕中,设置 MySQL 数据库连接设置。提供 MySQL 数据库主机地址(127.0.0.1 或本地主机)、数据库名称、用户名和为 EspoCRM 应用程序配置的密码。完成所有必填的数据库字段后,点击下一步按钮进入下一个安装步骤。使用下面的屏幕截图作为指南来完成此步骤。

在下一个屏幕中,EspoCRM 安装程序将检查您的服务器环境配置,以确定是否正确配置了所有推荐的 MySQL 变量和 PHP 模块和设置。如果所有配置都通过,点击安装按钮开始 EspoCRM 安装过程。

在下一步中,为 EspoCRM 添加一个管理员帐户,并为此管理员帐户设置一个强密码。完成后,点击下一步按钮继续安装过程。

接下来,通过选择合适的日期格式和时间格式来设置 EspoCRM 系统设置。此外,通过从提供的时区列表中选择离您最近的大洲/城市,选择适合您的应用程序的时区设置。设置一周的第一天、应用程序默认货币、千位和小数点分隔符以及系统语言。配置完上述所有设置后,点击下一步按钮继续安装过程。

在下一步中,配置 EspoCRM 外发邮件设置。为“发件人姓名”电子邮件标题和管理员帐户的电子邮件联系地址添加名称。该地址将用于向外部客户发送电子邮件。此外,确保添加电子邮件服务器地址、邮件服务器的端口号并选中 Auth 复选框并提供服务器身份验证凭据和安全级别(如果是这样的话)。完成此步骤后,点击下一步按钮以完成安装过程。

导入数据库结构并将所有平台设置写入应用程序配置文件后,安装过程将完成。安装程序将显示通知您安装已成功完成,并将显示有关您需要添加到服务器 crontab 文件中的 EspoCRM 计划作业的注释。

要访问和管理您的 CRM 应用程序,请打开浏览器并通过 HTTPS 导航至您的服务器 IP 地址或域名。使用在安装过程中配置的凭据以登录到 EspoCRM 后端面板,如下面的屏幕截图所示。

https://yourdomain.tld

到目前为止,默认的 EspoCRM 仪表板应该不包含任何数据。下面的屏幕截图显示了 EspoCRM 初始仪表板上的预览。

为了进一步配置 EspoCRM 平台设置,点击右上角的三个水平线图标,然后点击自上而下菜单中的管理链接,如下图所示。

为了强制访问者通过加密服务器和客户端浏览器之间流量的 HTTPS 协议安全访问 EspoCRM 后端界面,返回到您的服务器终端并编辑位于您网站文档根路径中的 .htaccess 文件, 通过发出以下命令。

nano /var/www/html/.htaccess

在 .htaccess 文件中,搜索 行并在 RewriteEngine On 之后添加以下规则语句以便自动将所有域流量重定向到 HTTPS。

# Redirect to HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

在顶部,您可以更改本机 PHP 服务器设置的文件,例如增加 upload_max_filesize 和 post_max_size PHP 变量的值,以支持将大文件上传到应用程序存储.修改这些 PHP 设置时要格外小心。确保这些变量与您的服务器资源和配置相匹配。

# Modify PHP settings
php_value session.use_trans_sid 0
php_value register_globals 1
php_value upload_max_filesize 100M
php_value post_max_size 100M

接下来,在将计划的作业添加到 crontab 守护程序文件之前测试它,方法是发出以下命令。 crontask 作业应使用 Apache HTTP 服务器运行时帐户权限执行。

sudo -u www-data /usr/bin/php7.0 -f /var/www/html/cron.php

最后,通过发出以下命令添加 Apache www-data 帐户拥有的以下 crontab 作业。

crontab -u www-data –e

Crontab 文件摘录:

*    *    *    *    *     /usr/bin/php7.0 -f /var/www/html/cron.php > /dev/null 2>&1

就这样!您已经在 Debian 9 中成功安装并配置了 EspoCRM 平台。有关 EspoCRM 平台的其他设置,请访问以下地址的文档页面:https://www.espocrm.com/documentation/

©2015-2025 艾丽卡 support@alaica.com