

步骤1.首先,通过apt在终端中运行以下命令来确保所有系统软件包都是最新的。
sudo apt update sudo apt upgrade
步骤2.,安装LEMP堆栈。
需要Ubuntu 20.04 LEMP服务器。
步骤3.在Ubuntu 20.04上安装Mattermost。
创建一个单独的用户和组来运行Mattermost,您可以使用以下命令创建它:
useradd --system --user-group mattermost
现在,我们从其官方网站下载最新版本的Mattermost:
wget https://releases.mattermost.com/5.28.1/mattermost-5.28.1-linux-amd64.tar.gz
下载后,将Mattermost存档解压缩到服务器上的文档根目录中:
tar -xvzf mattermost-5.28.1-linux-amd64.tar.gz mv mattermost /opt/ mkdir /opt/mattermost/data
我们将需要更改一些文件夹权限:
chown -R mattermost:mattermost /opt/mattermost chmod -R g+w /opt/mattermost
之后,编辑Mattermost配置文件并定义您的站点URL和数据库设置:
nano /opt/mattermost/config/config.json
根据需要更改以下行:
\"SiteURL\": \"http://mattermost.example.com\", \"DriverName\": \"mysql\", \"DataSource\": \"mattermost:secure-your-password@tcp(localhost:3306)/mattermostdb?charset=utf8mb4,utf8\\u0026readTimeout=30s\\u0026writeTimeout=30s\",
步骤4.为Mattermost配置MariaDB。
默认情况下,不会对MariaDB进行加固。您可以使用mysql_secure_installation脚本保护MariaDB 。您应该仔细阅读每个步骤,并在每个步骤下面仔细进行操作,这将设置root密码,删除匿名用户,禁止远程root登录以及删除测试数据库并访问安全的MariaDB:
mysql_secure_installation
像这样配置它:
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
接下来,我们将需要登录MariaDB控制台并为Mattermost创建一个数据库。运行以下命令:
mysql -u root -p
这将提示您输入密码,因此输入您的MariaDB根密码,然后按Enter。登录数据库服务器后,您需要为Mattermost安装创建数据库:
MariaDB [(none)]> CREATE DATABASE mattermostdb; MariaDB [(none)]> CREATE USER \'mattermost\'@\'%\' IDENTIFIED BY \'your-secure-password\'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO \'mattermost\'@\'%\'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> EXIT;
步骤5.为Mattermost创建一个Systemd服务文件。
现在,我们创建一个systemd服务文件来管理Mattermost服务。您可以使用以下命令创建它:
nano /lib/systemd/system/mattermost.service
添加以下行:
[Unit] Description=Mattermost After=network.target After=mysql.service Requires=mysql.service [Service] Type=notify User=mattermost Group=mattermost ExecStart=/opt/mattermost/bin/mattermost TimeoutStartSec=3600 Restart=always RestartSec=10 WorkingDirectory=/opt/mattermost LimitNOFILE=49152 [Install] WantedBy=mariadb.service
保存并关闭文件,然后systemd使用以下命令重新加载守护程序:
sudo systemctl daemon-reload sudo systemctl start mattermost sudo systemctl enable mattermos
步骤6.将Nginx配置为反向代理。
现在,使用以下命令创建Nginx虚拟主机配置文件:
nano /etc/nginx/sites-available/mattermost.conf
添加以下行:
upstream mattermost {
server localhost:8065;
keepalive 32;
}
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;
server {
listen 80;
server_name mattermost.yundongfang.com;
location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection \"upgrade\";
client_max_body_size 50M;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
client_body_timeout 65;
send_timeout 200;
lingering_timeout 5;
proxy_connect_timeout 80;
proxy_send_timeout 300;
proxy_read_timeout 80s;
proxy_pass http://mattermost;
}
location / {
client_max_body_size 50M;
proxy_set_header Connection \"\";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
proxy_cache mattermost_cache;
proxy_cache_revalidate on;
proxy_cache_min_uses 2;
proxy_cache_use_stale timeout;
proxy_cache_lock on;
proxy_http_version 1.1;
proxy_pass http://mattermost;
}
}
保存并关闭文件,然后使用以下命令激活虚拟主机配置:
ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf sudo systemctl restart nginx
步骤7.设置HTTPS。
我们应该在Nextcloud上启用安全的HTTPS连接。我们可以从Let\’s Encrypt获得免费的TLS证书。从Ubuntu 20.04存储库安装Let\’s Encrypt客户端(Certbot):
sudo apt install python3-certbot-nginx
接下来,运行以下命令为您的网站安装“让我们加密SSL”:
certbot --nginx -d mattermost.yundongfang.com
如果测试成功,请重新加载Nginx以使更改生效:
sudo nginx -t sudo systemctl restart nginx
步骤8.配置防火墙。
运行以下命令以打开HTTP和HTTPS服务端口:
sudo ufw allow \'Nginx Full\'
步骤9.访问Mattermost。
默认情况下,Mattermost将在HTTP端口80上可用。打开您喜欢的浏览器,然后通过输入电子邮件地址并创建一个帐户导航到并继续配置Mattermost。https://mattermost.yundongfang.com
恭喜你!您已经成功安装了Mattermost。使用本教程在Ubuntu 20.04 LTS Focal Fossa系统上安装Mattermost。有关其他帮助或有用信息,我们建议您检查Mattermost官方网站。