recent
أخبار ساخنة

شرح خطوات تثبيت Mattermost Team Messaging System للدردشة ومشاركة الملفات والبحث على Ubuntu

الصفحة الرئيسية
شرح خطوات تثبيت  Mattermost Team Messaging System للدردشة ومشاركة الملفات والبحث على Ubuntu



Mattermost هو تطبيق مراسلة مفتوح المصدر (open-source) وذاتي الاستضافة (self-hosted) يُستخدم للدردشة ومشاركة الملفات والبحث.

إنه بديل لـ Slack chat الذي يجمع كل اتصالات فريقك في مكان واحد.

يستخدم PostgreSQL أو قاعدة بيانات MySQL في الواجهة الخلفية.

المميزات

 يوفر مجموعة غنية من الميزات بما في ذلك الإشعارات وسجل بحث غير محدود  ورموز تعبيرية مخصصة  وWebhooks وأوامر ويب  وActive directory ودعم قاعدة بيانات Multi-node وForum و لوحة Discussion وغيرها.


سنشرح هنا تثبيت Mattermost باستخدام Nginx و Let's Encrypt SSL على Ubuntu 20.04.


المتطلبات الأساسية

خادم يعمل بنظام التشغيل Ubuntu 20.04.
اسم مجال (domain name) صالح يشير عنوان الـ IP الخاص بالخادم.
إعداد كلمة مرور للـ root على الخادم.

الخطوات

أولاً ، يوصى بتحديث حزم النظام بأحدث إصدار.
يمكنك تحديثها عن طريق تشغيل الأمر التالي:


apt-get update -y

بعد تحديث جميع الحزم  قم بتثبيت كل الحزم المطلوبة عن طريق تشغيل الأمر التالي:


apt-get install curl wget vim git unzip gnupg2 -y


تثبيت وإعداد MariaDB


يستخدم Mattermost كلاً من MySQL / MariaDB كخلفية لقاعدة البيانات. 
لذلك يجب تثبيت خادم MariaDB في الخادم الخاص بك.
إذا لم يكن مثبتًا ، يمكنك تثبيته باستخدام الأمر التالي:


apt-get install mariadb-server -y

بعد تثبيت خادم MariaDB قم بتسجيل الدخول إلى MariaDB باستخدام الأمر التالي:


mysql

قم بإنشاء قاعدة بيانات ومستخدم لـ Mattermost باستخدام الأمر التالي:


MariaDB [(none)]> CREATE DATABASE mattermostdb;
MariaDB [(none)]> CREATE USER 'mattermost'@'%' IDENTIFIED BY 'password';

امنح جميع الصلاحيات إلى Mattermost باستخدام الأمر التالي:


MariaDB [(none)]> GRANT ALL PRIVILEGES ON mattermostdb.* TO 'mattermost'@'%';

اخرج من MariaDB shell باستخدام الأمر التالي:


MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;


تثبيت وإعداد Mattermost



ستحتاج إلى تنزيل أحدث إصدار من Mattermost من الموقع الرسمي على الويب. يمكنك تنزيله بالأمر التالي:


wget https://releases.mattermost.com/5.24.2/mattermost-5.24.2-linux-amd64.tar.gz

قم بفك ضغط الملف الذي تم تنزيله باستخدام الأمر التالي:


tar -xvzf mattermost-5.24.2-linux-amd64.tar.gz

انسخ المجلد المستخرج إلى  opt/

cp -r mattermost /opt

قم بإنشاء مجلد بيانات لـ Mattermost:


mkdir /opt/mattermost/data

ستحتاج إلى إنشاء مستخدم منفصل لتشغيل Mattermost.
يمكنك إنشائه بالأمر التالي:

useradd --system --user-group mattermost

قم بتغيير ملكية مجلد mattermost إلى المستخدم mattermost.
امنحه الصلاحيات المناسبة باستخدام الأمر التالي:

chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost

قم بتتعديل ملف التكوين الافتراضي Mattermost وحدد إعدادات قاعدة البيانات وعنوان URL الخاص بالموقع.

nano /opt/mattermost/config/config.json

قم بتغيير الأسطر التالية حسب حاجتك:


    "SiteURL": "https://mattermost.linuxbuz.com",

    "DriverName": "mysql",
    "DataSource": "mattermost:password@tcp(localhost:3306)/mattermostdb?charset=utf8mb4,utf8\u0026readTimeout=30s\u0026writeTimeout=30s",

احفظ وأغلق الملف عند الانتهاء.

إنشاء ملف خدمة Systemd لـ Mattermost


ستحتاج إلى إنشاء ملف خدمة (service file) لـ 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 بالأمر التالي:

systemctl daemon-reload

بعد ذلك ، ابدأ خدمة Mattermost وقم بتمكينها من البدء عند إعادة تشغيل النظام باستخدام الأمر التالي:

systemctl start mattermost
systemctl enable mattermost

بعد ذلك ، تحقق من حالة خدمة Mattermost باستخدام الأمر التالي:

systemctl status mattermost

ستحصل على النتيجة التالية

? mattermost.service - Mattermost
     Loaded: loaded (/lib/systemd/system/mattermost.service; disabled; vendor preset: enabled)
     Active: active (running) since Sat 2020-08-01 09:12:52 UTC; 17s ago
   Main PID: 4106 (mattermost)
      Tasks: 20 (limit: 2353)
     Memory: 85.9M
     CGroup: /system.slice/mattermost.service
             ??4106 /opt/mattermost/bin/mattermost
             ??4198 plugins/com.mattermost.nps/server/dist/plugin-linux-amd64

Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.131499,"caller":"mlog/sugar.go:19","msg":"Sent notification of ne>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1841655,"caller":"jobs/workers.go:73","msg":"Starting workers"}
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1842792,"caller":"bleveengine/bleve.go:267","msg":"UpdateConf Ble>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.1930475,"caller":"jobs/schedulers.go:74","msg":"Starting schedule>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.20063,"caller":"app/web_hub.go:83","msg":"Starting websocket hubs>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2099638,"caller":"app/license.go:37","msg":"License key from http>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2205582,"caller":"app/server.go:525","msg":"Starting Server..."}
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2208374,"caller":"app/server.go:594","msg":"Server is listening o>
Aug 01 09:12:52 ubuntu2004 mattermost[4106]: {"level":"info","ts":1596273172.2211802,"caller":"commands/server.go:106","msg":"Sending systemd >
Aug 01 09:12:52 ubuntu2004 systemd[1]: Started Mattermost.


يتم تشغيل Mattermost والاستماع على المنفذ 8065.

إعداد Nginx كوكيل عكسي (Reverse Proxy)


ستحتاج إلى إعداد Nginx كوكيل عكسي (reverse proxy)  لـ Mattermost. 

قم بتثبيت حزمة Nginx باستخدام الأمر التالي:

apt-get install nginx -y

قم بإنشاء ملف إعداد مضيف (virtual host) لـ  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.linuxbuz.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 60;
       send_timeout 300;
       lingering_timeout 5;
       proxy_connect_timeout 90;
       proxy_send_timeout 300;
       proxy_read_timeout 90s;
       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;
   }
}

احفظ وأغلق الملف.

قم بتفعيل إعدادات الـ virtual host بالأمر التالي:


ln -s /etc/nginx/sites-available/mattermost.conf /etc/nginx/sites-enabled/mattermost.conf

تحقق من Nginx بحثًا عن أي خطأ في الإعدادات:

nginx -t

ستحصل على النتيجة التالية

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

أعد تشغيل خدمة Nginx لتطبيق التغييرات:

systemctl restart nginx

تأمين Mattermost باستخدام Let's Encrypt SSL


ستحتاج إلى تثبيت Certbot client في نظامك لإدارة Let's Encrypt SSL. 

يمكنك تثبيته بالأمر التالي:


apt-get install python3-certbot-nginx -y

بعد تثبيت Certbot قم بتشغيل الأمر التالي لتثبيت Let's Encrypt SSL لموقع الويب الخاص بك.


certbot --nginx -d mattermost.linuxbuz.com

سيُطلب منك تقديم عنوان بريد إلكتروني صالح وقبول شروط الخدمة كما هو موضح:


Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): hitjethva@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing 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: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for mattermost.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/sites-enabled/mattermost.conf

بعد ذلك ، حدد ما إذا كنت تريد إعادة توجيه HTTP إلى HTTPS أم لا:


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

اكتب 2 واضغط على Enter لتثبيت Let's Encrypt SSL على المجال الخاص بك. 
بمجرد التثبيت ، سترى النتيجة التالية:


Redirecting all traffic on port 80 to ssl in /etc/nginx/sites-enabled/mattermost.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://mattermost.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=mattermost.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/mattermost.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/mattermost.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-10-30. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - 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

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

واجهة الويب لـ Mattermost 


افتح متصفح الويب الخاص بك واكتب عنوان URL:
https://mattermost.linuxbuz.com.
ستتم إعادة توجيهك إلى شاشة تسجيل Mattermost





أدخل عنوان بريدك الإلكتروني واسمك وكلمة مرورك وانقر على زر Create Account.

سترى الشاشة التالية:







انقر على  زر Create a team.

سترى الشاشة التالية:




أدخل اسم فريقك وانقر على زر Next .

سترى الشاشة التالية:




أدخل عنوان URL لفريقك وانقر على زر Finish.

ستشاهد شاشة Mattermost Welcome






Click on the Skip Tutorials button. You should see the Mattermost dashboard in the following screen:
انقر فوق زر Skip Tutorials.

ستشاهد لوحة معلومات Mattermost





google-playkhamsatmostaqltradent