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

加载更多搜索结果...

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

如何在 Debian 9 上安装 SuiteCRM

SuiteCRM 是 SugarCRM 的一个分支,是一个用 PHP 编程语言编写的企业开源客户关系管理 (CRM) 平台,可用于创建业务战略、行动和决策。

本教程描述了在 Debian 9 上安装最新版本的 SuiteCRM 平台所需的所有步骤,以便为您的企业部署一个强大的在线平台。 CRM 应用程序将部署在 Apache HTTP 服务器、PHP 和 MariaDB 数据库引擎下的 Debian Linux 上。

要求

  • 裸机服务器或虚拟专用服务器,内存至少为 2Gb,并安装了 Debian 9 服务器。
  • 通过机器控制台或通过 SSH 远程访问 root 帐户。除了 root 帐户,您还可以通过 sudo 命令使用具有 root 权限的帐户。
  • 配置有静态 IP 地址的外部网络接口或配置为为此接口租用静态 IP 地址的 DHCP 服务器。
  • 用于从互联网访问应用程序的公共注册域名。如果应用程序部署在内网,您可以执行安装过程并通过您的服务器IP地址访问网站。
  • 在您的场所配置的邮件服务器,以便使用网站注册或其他应用程序功能。您还可以使用公共邮件服务,例如 Gmail 或 Yahoo!、Microsoft Exchange 或其他服务来发送和接收邮件。

准备服务器

在第一步中,使用 root 帐户或具有通过 sudo 获得的 root 权限的用户登录到您的服务器控制台,并使用以下命令设置您的系统名称。确保相应地替换此示例中使用的机器主机名。

hostnamectl set-hostname www.mycrm.org

更改系统主机名后,发出以下命令以验证是否已正确应用机器名称。

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

接下来,确保通过发出以下命令更新系统存储库、软件包和内核。

apt update
apt upgrade

最后,更新过程完成后,通过执行以下命令重新启动机器以应用主机名更改和内核更新。

systemctl reboot

机器重启后,重新登录到服务器控制台并执行以下命令以安装一些命令行实用程序,例如 wget、curl 和 zip,这些实用程序稍后将用于通过 Internet 下载软件并提取 zip 存档文件。

apt install wget curl zip unzip

安装 Apache 和 PHP

SuiteCRM 应用程序将部署在 Debian 中的 LAMP 堆栈之上。我们将安装的 LAMP 堆栈的第一个组件是 Apache HTTP 服务器和 PHP 动态编程语言解释器。执行以下命令在您的系统中安装 Apache Web 服务器和所有必需的 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

安装 MariaDB 数据库

我们将在 Debian 服务器中安装的 LAMP 软件包的下一个组件是 MariaDB 数据库引擎。应用程序需要 RDBMS 数据库来存储不同的平台配置,例如用户、会话、联系人、产品、目录等。要安装 MariaDB 数据库引擎和访问数据库所需的 PHP 模块,请在您的计算机控制台中执行以下命令。

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

安装所有 LAMP 组件后,检查 Apache Web 服务器和 MariaDB 守护程序是否已启动并正在运行,并通过发出以下命令之一侦听端口 80 和 3306 TCP 上的网络连接。

netstat –tlpn
ss- tulpn

默认情况下,Debian 9 系统中不存在 Netstat 实用程序。要在 Debian Stretch 服务器中安装 netstat 实用程序,请执行以下命令。

apt install net-tools

我为了通过 HTTPS 协议安全访问 CRM 网站,该协议将保护服务器和客户端浏览器之间的流量,请确保您还通过发出以下命令启用 Apache TLS 模块和 SSL 站点配置文件。

a2enmod ssl
a2ensite default-ssl.conf

接下来,通过发出以下命令启用 Apache 重写模块。如果您想通过放置在域 webroot 中的 .htaccess 文件动态修改 Web 服务器配置,则需要重写模块。

a2enmod rewrite
systemctl restart apache2

接下来,通过在 Apache 配置文件中放置所需的规则来激活重写模块。首先,我们将在 Apache 默认配置文件中应用重写规则。因此,打开 /etc/apache2/sites-enabled/000-default.conf 文件以使用文本编辑器进行编辑,并在 之后插入以下 URL 重写规则DocumentRoot 语句,如以下摘录所示。

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

000-default.conf 文件摘录:

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

使用 CTRL+o 关闭 000-default.conf,然后使用 Ctrl+x 打开 Apache 默认 SSL 站点配置文件,并通过在 DocumentRoot 指令后添加以下代码行来插入 URL 重写规则,如图所示在下面的示例中:

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

SSL 站点配置文件摘录:

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

最后,在完成上述所有更改后,重新启动 Apache 守护程序以获取目前配置的所有新规则。

systemctl restart apache2

现在,您应该从远程桌面计算机通过 HTTP 协议访问您的域或服务器 IP 地址。默认的 Debian 网页应该会显示在您的浏览器中。

http://yourdomain.tld

防火墙配置

如果看不到网页,请验证 Debian 服务器中是否启用了 UFW 防火墙应用程序。如果是这种情况,您应该插入以下规则以允许 HTTP 和 HTTPS 流量通过防火墙。

ufw allow 'WWW Full'

或者

ufw allow 80/tcp
ufw allow 443/tcp

允许端口 80 和 443 TCP 入站流量通过防火墙的 iptables 防火墙原始规则如下所述。

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

最后,添加所需的防火墙规则后,通过HTTPS协议访问您的域名或服务器IP地址,测试Apache Web服务器默认网页是否可以显示在远程浏览器中。执行 ifconfig 或 ip a 命令以显示服务器的 IP 地址。

http://yourdomain.tld

由于您在安装时使用的是 Apache 自动颁发的自签名证书,该证书不受浏览器信任,因此浏览器中应显示“您的连接不安全”的警告。按顺序接受不受信任的证书绕过错误并重定向到 Apache 默认网页,如下图所示。

配置 MariaDB 和 PHP

现在,开始保护 MariaDB root 帐户。登录 MySQL 控制台执行以下命令更新 root 帐户插件。

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 提供 Debian stretch 存储库以进一步保护 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 帐户登录 MySQL 控制台而不提供密码来测试是否已应用所有安全措施。如果没有为 root 帐户提供密码,则应拒绝对数据库的访问,如以下命令摘录所示:

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

现在,尝试使用 root 帐户和密码登录 MySQL 控制台,如下例所示。您应该能够登录到 MySQL 控制台。输入 exit 退出 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

在下一步中,更改 php.ini 配置文件中的以下 PHP 变量,如下所述。打开/etc/php/7.0/apache2/php.ini 文件进行编辑并修改以下行。首先,确保备份初始 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 = 128M
post_max_size = 60M
upload_max_filesize = 60M
memory_limit = 256M
max_input_time = 60
max_execution_time = 6000
date.timezone = Europe/London

根据您的服务器地理位置替换 PHP 配置文件中的 timezone 变量。 PHP 时区列表可以在以下链接中找到 http://php.net/manual/en/timezones.php

要提高网站页面的加载速度,请启用适用于 PHP7 的 OPCache 插件。在 PHP 解释器配置文件底部的 [opcache] 语句之后插入以下 OPCache 行,如以下摘录所示:

[opcache]
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 配置文件并重新启动 Apache 守护程序以通过发出以下命令来应用更改。

systemctl restart apache2

要在浏览器中显示所有 PHP 设置,请通过执行以下命令在您的域 webroot 路径中创建一个 PHP 信息文件。

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

从位于以下 URL 的远程浏览器访问 PHP 信息脚本文件。向下滚动到 date 设置以验证 PHP 时区配置和其他设置是否已成功应用。

https://domain.tld/info.php

安装 SuiteCRM

在我们配置了安装 SuiteCRM 应用程序所需的所有 LAMP 设置后,访问 SuiteCRM 官方下载页面 https://suitecrm.com/download/ 并通过发出以下命令在您的系统中获取最新的 zip 文件存档。在撰写本指南时,最新发布的 SuiteCRM 版本是 SuiteCRM-7.9.9.zip 文件。

wget https://suitecrm.com/files/158/SuiteCRM-7.9/178/SuiteCRM-7.9.9.zip
ls

SuiteCRM zip 文件存档下载完成后,将 zip 存档文件解压缩到您当前的工作目录,并通过发出以下命令列出解压缩的文件。

unzip SuiteCRM-7.9.9.zip
ls
ls –al SuiteCRM-7.9.9

在将安装文件复制到您的域 webroot 之前,请确保删除 Apache 包安装到 Web 服务器文档根路径的默认 index.html 文件,并删除之前创建的 info.php 文件。

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

SuiteCRM 应用程序的安装文件位于SuiteCRM-7.9.9/ 目录下的当前工作目录中。发出 ls 命令列出此目录文件。通过发出以下命令,将 SuiteCRM-7.9.9/ 目录的所有内容复制到您的 Web 服务器文档根路径。

cp -rf SuiteCRM-7.9.9/* /var/www/html/

接下来,通过发出以下命令授予 Apache 运行时用户 (www-data) 对 Apache 文档根路径的完全写入权限。运行 ls 命令以列出位于 /var/www/html/ 目录下的已安装文件的权限。

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

接下来,登录MariaDB数据库控制台,创建SuiteCRM数据库。通过发出以下命令,为此数据库选择一个名称和一个具有强密码的用户来管理应用程序数据库。确保使用您自己的设置更改本教程中使用的数据库名称、用户和密码。

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)]> 创建数据库 mycrm_db;

Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all privileges on mycrm_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

现在,让我们开始 SuiteCRM 应用程序的安装过程。打开浏览器并通过 HTTPS 协议浏览您服务器的 IP 地址或域名。

http://yourdomain.tld

在第一个安装屏幕上,SuiteCRM 安装程序将显示许可协议。选中“我接受”复选框以同意许可条款和条件,选择安装应用程序的语言并点击下一步按钮以开始安装过程,如下面的屏幕截图所示。

在下一个安装屏幕中,SuiteCRM 安装程序将检查您的系统环境要求,如果所有 PHP 和服务器配置均已通过,将显示 OK 消息。为了继续安装过程,点击下一步按钮,如下图所示。

接下来,安装程序将显示数据库连接设置和站点配置页面。在左窗格中,选择 MySQL with MySQLi Extension 作为数据库类型,并提供为安装 SuiteCRM 应用程序而创建的 MySQL 数据库名称、数据库服务器主机地址、数据库用户名和访问 SuiteCRM 数据库所需的密码。另外,在“SuiteCRM数据库用户/”中选择“与管理员用户相同”。在右侧平面上,添加一个应用程序管理员用户名并为管理员帐户设置一个强密码。通过 HTTPS 协议检查 SuiteCRM 实例的 URL 地址以匹配您的域名,在端口 443 上并添加管理员帐户的电子邮件地址。使用下图作为配置此步骤的指南。

接下来,在同一安装屏幕中,从“更多选项”菜单中点击“选择演示”数据,然后选择不使用演示数据填充 SuiteCRM 数据库。然后,单击场景选择菜单并选择启用以下 SuiteCRM 模块:销售、市场营销、财务、服务和项目管理。如果您在安装应用程序时不需要某个模块,您可以不选中它,并在安装过程完成后使用应用程序管理页面启用它。

接下来,向下滚动并点击 SMTP 服务器规范菜单以启用 SuiteCRM 电子邮件选项。添加您希望显示在“发件人”电子邮件标题中的姓名和电子邮件地址。然后,选择您的电子邮件服务提供商并指定邮件服务器设置。在本指南中,我们将使用 Gmail 服务提供商发送电子邮件,并且邮件服务器设置可以在下面的屏幕截图中找到。完成启用邮件服务提供商所需的设置后,点击品牌菜单并添加一个名称以显示在 SuiteCRM 应用程序的浏览器标题栏中,然后上传您自己的名称网站标志图像。

接下来,再次向下滚动并点击系统区域设置菜单,并指定时间格式、时区和货币设置应如何在 SuiteCRM 应用程序中显示。最后,暂时不选中“站点安全”选项,然后点击“下一步”按钮完成安装过程。您可以使用下图来完成此步骤。

安装过程完成后,您将被重定向到 SuiteCRM 登录页面。为了访问应用程序管理面板,请使用在安装过程中配置的管理员帐户凭据登录 SuiteCRM,如下图所示。

在登录 SuiteCRM 管理面板之前,首先,返回服务器控制台并发出以下命令以删除不再需要且可能代表安全漏洞的安装目录。

rm -rf /var/www/html/install/

您还可以通过 HTTPS 协议导航到您的服务器 IP 地址或域名来访问 SuiteCRM 仪表板。 SuiteCRM 管理仪表板的视图显示在下面的屏幕截图中。

http://yourdomain.tld

最后,为了自动将访问者重定向到 HTTPS,以便他们可以从浏览器安全地访问 SuiteCRM 界面,返回到您的服务器终端并编辑位于您的域文档根路径中的自动生成的 .htaccess 文件,通过发出以下命令。

nano /var/www/html/.htaccess

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

.htaccess 文件摘录:

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

在文件底部,您可以通过添加其他行来修改 Web 服务器本机 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

为了执行 SuiteCRM 调度程序,请使用以下命令编辑您的 Web 服务器运行时帐户 crontab 文件,并添加以下 cron 任务以每分钟运行一次。

crontab -e -u www-data

crontab 文件示例:

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

如果您想避免每次客户端访问您的应用程序时生成的浏览器警告,您应该考虑购买由受信任的证书颁发机构颁发的证书或从 Let's Encrypt CA 颁发的免费证书。

就这样! SuiteCRM Web 应用程序已在 LAMP 堆栈顶部的 Debian 9 服务器中成功安装和配置。

为了进一步自定义 SuiteCRM 平台,请确保访问以下地址的应用程序 wiki 页面:https://suitecrm.com/wiki/index.php/Main_Page

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