CentOS7 install Mattermost

发布于 2019-04-07  592 次阅读


环境:CentOS7

ip :172.18.119.26

[title]升级[/title]

yum update
yum upgrade

[title]安装MySQL 5.7[/title]

yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
yum install mysql-community-server

#启动mysql

systemctl start mysqld

#设置自动启动 mysql

systemctl enable mysqld

#查看mysql启动状态

systemctl status mysqld

#查看mysql的root账号的密码

[root@localhost ~]# cat /var/log/mysqld.log | grep 'temporary password'
2019-03-11T05:33:42.505109Z 1 [Note] A temporary password is generated for root@localhost: y!

#登录mysql

[root@localhost ~]# mysql -uroot -p
Enter password: 【输入mysql 密码】
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25
Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>

#修改密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Gx9PassEx^&!';

#修改root用户可远程登录

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'Gx9PassEx^&!' WITH GRANT OPTION;

#刷新
flush privileges;
#建立mmuser用户,并赋予密码

create user 'mmuser'@'%' identified by 'M2PassEx!@#z';

#建立数据库

create database mattermost;

#给操作权限

grant all privileges on mattermost.* to 'mmuser'@'%';

[title]安装Mattermost Server[/title]
#下载Mattermost Server

cd /opt
wget https://releases.mattermost.com/5.8.0/mattermost-5.8.0-linux-amd64.tar.gz
tar -xvzf mattermost-5.8.0-linux-amd64.tar.gz
mkdir -p /opt/mattermost/data

#建立mattermost用户、用户组

useradd --system --user-group mattermost

赋予目录权限

chown -R mattermost:mattermost /opt/mattermost

赋予执行权限

chmod -R g+w /opt/mattermost

#修改配置

vi /opt/mattermost/config/config.json

1.设置 "DriverName" 为 "mysql"
2.设置 "

mmuser:@tcp(:3306)/mattermost?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s

改为数据库密码
改为数据库地址,通常是 localhost
attermost_test 改为attermost

#测试
进入mattermost目录

cd /opt/mattermost

使用mattermost用户执行脚本

sudo -u mattermost ./bin/mattermost

运作正常后,CTRL+C解除进程

[title]启动systemctl服务[/title]

sudo vi /etc/systemd/system/mattermost.service
[Unit]
Description=Mattermost
After=syslog.target network.target postgresql-9.4.service

[Service]
Type=notify
WorkingDirectory=/opt/mattermost
User=mattermost
ExecStart=/opt/mattermost/bin/mattermost
PIDFile=/var/spool/mattermost/pid/master.pid
TimeoutStartSec=3600
LimitNOFILE=49152

[Install]
WantedBy=multi-user.target

#给service 启动权限

sudo chmod 664 /etc/systemd/system/mattermost.service

#设置开机启动

sudo systemctl enable mattermost

#启动mattermost 服务

sudo systemctl start mattermost

#curl 测试,IP:8065

curl http://localhost:8065

#设置防火墙

firewall-cmd --permanent --zone=public --add-service=http 
firewall-cmd --permanent --zone=public --add-port=3306/tcp
firewall-cmd --permanent --zone=public --add-port=8065/tcp
firewall-cmd --reload

一沙一世界,一花一天堂。君掌盛无边,刹那成永恒。