本页内容

  • 先决条件
  • 开始之前
  • 安装 Apache、MySQL 和 PHP
  • 为 Cerb 创建数据库
  • 安装 Cerb
  • 为 Cerb 创建 Apache 虚拟主机
  • 为 Cerb 安装 Let's Encrypt SSL
  • 访问 Cerb Web 界面
  • 结语

Cerb 是一个免费、开源、快速且灵活的业务协作与自动化平台。它是一款用于发送大量邮件的基于 Web 的工具。它提供基于 Web 的仪表盘,用于实时监控与目标跟踪。它拥有众多功能,包括通知、共享邮箱、邮件管理、移动端功能等。

本教程将向您展示如何在 Ubuntu 22.04 上安装 Cerb 自动化工具。

先决条件

  • 一台运行 Ubuntu 22.04 的服务器。
  • 一个已指向服务器 IP 的有效域名。
  • 服务器已配置 root 密码。

开始之前

首先,您必须将系统中的所有软件包更新到最新版本。可以运行以下命令来更新系统。

apt update -y
apt upgrade -y

系统更新完成后,即可进入下一步。

安装 Apache、MySQL 和 PHP

接下来,您需要在系统中安装 Apache Web 服务器、MySQL 数据库服务器、PHP 以及其他所需模块。可以使用以下命令一次性安装它们:

apt install apache2 mysql-server php libapache2-mod-php php-mysql php-mbstring php-gd php-imap php-curl php-mailparse php-yaml php-gmp php-dev php-pear git wget unzip -y

接下来,您还需要在服务器上安装 Mailparse PHP 扩展。

首先,使用以下命令下载最新版本的 Mailparse。

wget https://pecl.php.net/get/mailparse-3.1.4.tgz

接下来,使用以下命令解压下载的文件。

tar -xvzf mailparse-3.1.4.tgz

接下来,请切换到解压后的目录,并使用以下命令进行配置。

cd mailparse-3.1.4
phpize
./configure
sed -i 's/^\(#error .* the mbstring extension!\)/\/\/\1/' mailparse.c

现在,使用以下命令安装 Mailparse 扩展。

make 
make install

接下来,打开 php.ini 文件并修改默认设置:

nano /etc/php/8.1/apache2/php.ini

修改以下行:

memory_limit = 256M
upload_max_filesize = 100M
max_execution_time = 360
date.timezone = UTC
extension=mailparse.so

修改完成后,保存并关闭文件,然后重启 Apache 服务以使更改生效:

systemctl restart apache2

为 Cerb 创建数据库

接下来,您需要根据 Cerb 创建数据库和用户。首先,使用以下命令登录 MySQL shell:

mysql

登录后,运行以下命令创建数据库和用户:

mysql> CREATE DATABASE cerbdb CHARACTER SET utf8;
mysql> CREATE USER cerbuser@localhost IDENTIFIED BY 'password';

接下来,使用以下命令为 Cerb 授予所有权限:

mysql> GRANT ALL PRIVILEGES ON cerbdb.* TO cerbuser@localhost;

接下来,使用以下命令刷新权限并退出 MariaDB shell:

mysql> FLUSH PRIVILEGES;
mysql> EXIT;

至此,Cerb 所需的数据库和用户已创建完成。您可以进入下一步。

安装 Cerb

首先,使用以下命令从 Git 仓库下载最新版本的 Cerb 到 Apache Web 根目录:

cd /var/www/html
git clone https://github.com/cerb/cerb-release.git cerb

下载完成后,切换到 cerb 目录并重命名 .htaccess-dist 文件:

cd cerb
mv .htaccess-dist .htaccess

接下来,修改 cerb 目录的所属用户和权限:

chown -R www-data:www-data /var/www/html/cerb/
chmod -R 755 /var/www/html/cerb/

完成后,您可以进入下一步。

为 Cerb 创建 Apache 虚拟主机

接下来,您必须创建一个 Apache 虚拟主机配置文件来托管 Cerb。可以使用以下命令创建该文件:

nano /etc/apache2/sites-available/cerb.conf

添加以下内容:

<VirtualHost *:80>
     ServerAdmin 
[email protected]

     DocumentRoot /var/www/html/cerb
     ServerName cerb.linuxbuz.com

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

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

修改完成后,保存并关闭文件,然后使用以下命令启用 Cerb 虚拟主机文件:

a2ensite cerb.conf

接下来,重新加载 Apache 服务以应用配置更改:

systemctl restart apache2

您可以使用以下命令验证 Apache 服务的状态:

systemctl status apache2

您应该会看到类似以下的输出:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-01-10 04:57:10 UTC; 5s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 59977 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 59981 (apache2)
      Tasks: 6 (limit: 2237)
     Memory: 13.2M
        CPU: 57ms
     CGroup: /system.slice/apache2.service
             ??59981 /usr/sbin/apache2 -k start
             ??59983 /usr/sbin/apache2 -k start
             ??59984 /usr/sbin/apache2 -k start
             ??59985 /usr/sbin/apache2 -k start
             ??59986 /usr/sbin/apache2 -k start
             ??59987 /usr/sbin/apache2 -k start

Jan 10 04:57:10 vultr systemd[1]: Starting The Apache HTTP Server...
Jan 10 04:57:10 vultr systemd[1]: Started The Apache HTTP Server.

完成后,您可以进入下一步。

为 Cerb 安装 Let's Encrypt SSL

接下来,强烈建议使用 Let's Encrypt SSL 来保护您的 Cerb Web 界面。首先,您需要在系统中安装 Certbot 客户端,以便安装和管理 SSL。

首先,使用以下命令安装 Snap 软件包管理器:

apt install snapd

接下来,将 Snap 软件包更新到最新版本:

snap install core
snap refresh core

接下来,使用以下命令安装 certbot 软件包:

snap install --classic certbot

接下来,为 Certbot 二进制文件创建指向系统路径的符号链接:

ln -s /snap/bin/certbot /usr/bin/certbot

接下来,运行以下命令下载并安装 Let's Encrypt SSL 证书:

certbot --apache

系统会要求您选择域名并提供有效邮箱地址,以安装 Let's Encrypt SSL。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 
[email protected]


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.3-September-21-2022.pdf. You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Yes

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Yes
Account registered.

Which names would you like to activate HTTPS for?
We recommend selecting either all domains, or all domains in a VirtualHost/server block.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: cerb.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1
Requesting a certificate for cerb.linuxbuz.com

Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/cerb.linuxbuz.com/fullchain.pem
Key is saved at:         /etc/letsencrypt/live/cerb.linuxbuz.com/privkey.pem
This certificate expires on 2023-04-10.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.

Deploying certificate
Successfully deployed certificate for cerb.linuxbuz.com to /etc/apache2/sites-available/cerb-le-ssl.conf
Congratulations! You have successfully enabled HTTPS on https://cerb.linuxbuz.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
 * Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
 * Donating to EFF:                    https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

至此,您的网站已通过 Let's Encrypt SSL 进行了保护。

访问 Cerb Web 界面

现在,打开 Web 浏览器,使用网址 https://cerb.linuxbuz.com 访问 Cerb Web 界面。您将被重定向到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

验证所有 PHP 扩展后,点击 Continue 按钮。您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

点击 Accept 按钮以接受许可协议。您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

填写数据库详细信息并点击 Verify database connection 按钮。您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

选择邮件设置并点击 Verify mail settings 按钮。您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

现在,填写姓名、邮箱和密码,然后点击 Continue 按钮。您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

点击 Continue 按钮。您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

选择 Demo 并点击 Continue 按钮以开始安装。安装完成后,您应该会看到以下页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

点击 Log in and get started 按钮。您应该会看到 Cerb 登录页面:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

填写邮箱和密码,然后点击 Continue 按钮。您应该会在下一页看到 Cerb 仪表盘:

在Ubuntu 22.04系统上安装Cerb协作与邮件自动化平台

结语

本教程介绍了如何在 Ubuntu 22.04 上为 Cerb 安装 Let's Encrypt SSL。您现在可以探索 Cerb 的各项功能,并开始与团队进行协作。如有任何疑问,欢迎随时向我提问。