ผลต่างระหว่างรุ่นของ "3. ติดตั้ง mariadb, postfix, dovecot ของ EAI Email Server บน CentOS 7"

จาก Wiki_EAI
ไปยังการนำทาง ไปยังการค้นหา
แถว 2: แถว 2:
 
  '''# yum --enablerepo=centosplus install postfix'''
 
  '''# yum --enablerepo=centosplus install postfix'''
 
  '''# yum install dovecot mariadb-server dovecot-mysql'''
 
  '''# yum install dovecot mariadb-server dovecot-mysql'''
'''# systemctl enable dovecot'''
 
  
2. ติดตั้ง postfix version 3.x.x  
+
2. อัพเดตจาก postfix version 2.x.x เป็น version 3.x.x  
*remove postfix version 2.x.x ออกก่อน เนื่องจาก postfix version 2.x.x ยังไม่รองรับ EAI ต้องอัพเกรดเป็น version 3.x.x ขึ้นไป
+
*บน CentOS 7 จะติดตั้ง postfix version 2.x.x เป็นค่าเริ่มต้น เราต้อง remove ออกก่อน เนื่องจาก postfix version 2.x.x ยังไม่รองรับ EAI และอัพเกรดเป็น version 3.x.x ขึ้นไป
 
  '''# yum remove postfix'''
 
  '''# yum remove postfix'''
 
  '''# yum remove ssmtp'''
 
  '''# yum remove ssmtp'''
 
  '''# yum remove sendmail'''
 
  '''# yum remove sendmail'''
  
3. สร้างไฟล์ repo ชื่อ gf.repo เพื่อติดตั้ง postfix version 3.x.x ขึ้นไป  
+
*สร้างไฟล์ repo ชื่อ gf.repo เพื่อติดตั้ง postfix version 3.x.x ขึ้นไป  
 
  '''# vi /etc/yum.repos.d/gf.repo'''
 
  '''# vi /etc/yum.repos.d/gf.repo'''
  
แถว 32: แถว 31:
 
  '''failovermethod=priority'''
 
  '''failovermethod=priority'''
  
4. โหลด key ที่ใช้กับ repo วางไว้ใน path : /etc/pki/rpm-gpg/
+
*โหลด key ที่ใช้กับ repo วางไว้ใน path : /etc/pki/rpm-gpg/
 
  '''# cd /etc/pki/rpm-gpg/
 
  '''# cd /etc/pki/rpm-gpg/
 
  '''# wget http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7'''
 
  '''# wget http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7'''
  
5. ติดตั้ง postfix version 3.x.x
+
*ติดตั้ง postfix version 3.x.x
 
  '''# yum install postfix3 postfix-mysql
 
  '''# yum install postfix3 postfix-mysql
'''# systemctl start postfix
 
'''# systemctl enable postfix'''
 
  
6. ตั่งค่า MariaDB
+
3. ตั้งค่า mariadb, postfix, dovecot ให้เริ่มทำงานทุกครั้งที่เปิดเครื่อง
 
  '''# systemctl start mariadb'''
 
  '''# systemctl start mariadb'''
 
  '''# systemctl enable mariadb'''
 
  '''# systemctl enable mariadb'''
 +
'''# systemctl start postfix'''
 +
'''# systemctl enable postfix'''
 +
'''# systemctl start dovecot'''
 +
'''# systemctl enable dovecot'''
  
7. ดูสถานะการใช้งานของ MariaDB
+
4. ตรวจสอบสถานะการทำงานของ mariadb, postfix, dovecot
 
  '''# systemctl status mariadb'''
 
  '''# systemctl status mariadb'''
 +
'''# systemctl status postfix'''
 +
'''# systemctl status dovecot'''
  
 
8. ตั้งค่า UTF8 ให้กับ mysql เพื่อให้รองรับภาษาไทย โดยเพิ่มคำสั่งด้าล่างลงใน /etc/my.cnf ใต้ [mysqld]
 
8. ตั้งค่า UTF8 ให้กับ mysql เพื่อให้รองรับภาษาไทย โดยเพิ่มคำสั่งด้าล่างลงใน /etc/my.cnf ใต้ [mysqld]

รุ่นแก้ไขเมื่อ 20:42, 27 ตุลาคม 2563

1. เริ่มติดตั้ง mariadb, postfix, dovecot ด้วยคำสั่ง

# yum --enablerepo=centosplus install postfix
# yum install dovecot mariadb-server dovecot-mysql

2. อัพเดตจาก postfix version 2.x.x เป็น version 3.x.x

  • บน CentOS 7 จะติดตั้ง postfix version 2.x.x เป็นค่าเริ่มต้น เราต้อง remove ออกก่อน เนื่องจาก postfix version 2.x.x ยังไม่รองรับ EAI และอัพเกรดเป็น version 3.x.x ขึ้นไป
# yum remove postfix
# yum remove ssmtp
# yum remove sendmail
  • สร้างไฟล์ repo ชื่อ gf.repo เพื่อติดตั้ง postfix version 3.x.x ขึ้นไป
# vi /etc/yum.repos.d/gf.repo

ตัวอย่าง

[gf]
name=Ghettoforge packages that won't overwrite core distro packages.
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/gf/$basearch/mirrorlist
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
failovermethod=priority
 
[gf-plus]
name=Ghettoforge packages that will overwrite core distro packages.
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/plus/$basearch/mirrorlist
# Please read http://ghettoforge.org/index.php/Usage *before* enabling this repository!
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
failovermethod=priority
  • โหลด key ที่ใช้กับ repo วางไว้ใน path : /etc/pki/rpm-gpg/
# cd /etc/pki/rpm-gpg/
# wget http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7
  • ติดตั้ง postfix version 3.x.x
# yum install postfix3 postfix-mysql

3. ตั้งค่า mariadb, postfix, dovecot ให้เริ่มทำงานทุกครั้งที่เปิดเครื่อง

# systemctl start mariadb
# systemctl enable mariadb
# systemctl start postfix
# systemctl enable postfix
# systemctl start dovecot
# systemctl enable dovecot

4. ตรวจสอบสถานะการทำงานของ mariadb, postfix, dovecot

# systemctl status mariadb
# systemctl status postfix
# systemctl status dovecot

8. ตั้งค่า UTF8 ให้กับ mysql เพื่อให้รองรับภาษาไทย โดยเพิ่มคำสั่งด้าล่างลงใน /etc/my.cnf ใต้ [mysqld]

# vi /etc/my.cnf

ตัวอย่าง

[mysqld]
character-set-server = utf8
collation-server = utf8_general_ci
skip-character-set-client-handshake
bind-address=127.0.0.1
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d


9. สั่ง restart mariadb

# systemctl restart mariadb

10. ตั้งค่าความปลอดภัยการเข้างาน mysql โดยจะมีการตั้ง password ของ root user เพื่อ login เข้าใช้งาน (*กำหนดเพียง password ใหม่ และในส่วนอื่นๆให้ enter ผ่านได้เลย)

# mysql_secure_installation

11. Login ข้าใช้งาน mysql โดยใช้ password ของ root user ที่ได้ตั้งไว้

# mysql -u root -p

12. สร้าง DB เพื่อใช้งานการเก็บข้อมูลของการใช้งาน Email Server

# CREATE DATABASE eaimail;
 # USE eaimail;


13. สร้าง user พร้อมกำหนดสิทธิ์การใช้งานให้กับ eaimail db

# GRANT SELECT, INSERT, UPDATE, DELETE ON eaimail.* TO 'yourdbuser'@'localhost' IDENTIFIED BY 'yourdbpassword';
# GRANT SELECT, INSERT, UPDATE, DELETE ON eaimail.* TO 'yourdbuser'@'localhost.localdomain' IDENTIFIED BY 'yourdbpassword';
# FLUSH PRIVILEGES;

14. ตรวจสอบ userที่สร้างขึ้นใหม่โดย

# SHOW GRANTS FOR 'yourdbuser'@'localhost';

15. สร้างตารางใช้เก็บค่า Domain

# CREATE TABLE domains (domain varchar(50) NOT NULL, PRIMARY KEY (domain) );

16. สร้างตารางใช้สำหรับ forward mail

# CREATE TABLE forwardings (source varchar(80) NOT NULL, destination TEXT NOT NULL, PRIMARY KEY (source) );

17. สร้างตาราง user เพื่อใช้สร้าง mailbox และออกจาก mysql

# CREATE TABLE users (email varchar(80) NOT NULL, password varchar(20) NOT NULL, PRIMARY KEY (email) );
# quit

18. สั่ง restart mariadb

# systemctl restart mariadb.service