ผลต่างระหว่างรุ่นของ "2. ขั้นตอนการติดตั้งและตั้งค่า mariadb , Postfix , Dovecot (Centos7)"

จาก Wiki_EAI
ไปยังการนำทาง ไปยังการค้นหา
แถว 3: แถว 3:
 
  '''# yum install dovecot mariadb-server dovecot-mysql'''
 
  '''# yum install dovecot mariadb-server dovecot-mysql'''
 
  '''# systemctl enable dovecot'''
 
  '''# systemctl enable dovecot'''
 +
  
 
2 เนื่องจาก Postfix version 2.x.x นั้นไม่รองรับกับระบบ EAI จำเป็นต้องใช้ version 3.x.x ขึ้นไป โดยถอด postfix เดิมออก
 
2 เนื่องจาก Postfix version 2.x.x นั้นไม่รองรับกับระบบ EAI จำเป็นต้องใช้ version 3.x.x ขึ้นไป โดยถอด postfix เดิมออก
  '"# yum remove postfix"'
+
  '''# yum remove postfix'''
 
  '''# yum remove ssmtp'''
 
  '''# yum remove ssmtp'''
 
  '''# yum remove sendmail'''
 
  '''# yum remove sendmail'''
 +
  
 
3 เพิ่ม Repo ใหม่ เพื่อให้สามารถติดตั้ง postfix version 3 ขึ้นไปได้ โดยสร้าง repo
 
3 เพิ่ม Repo ใหม่ เพื่อให้สามารถติดตั้ง postfix version 3 ขึ้นไปได้ โดยสร้าง repo
# vi /etc/yum.repos.d/gf.repo
+
'''# vi /etc/yum.repos.d/gf.repo'''
[gf]
+
 
name=Ghettoforge packages that won't overwrite core distro packages.
+
'''[gf]
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/gf/$basearch/mirrorlist
+
name=Ghettoforge packages that won't overwrite core distro packages.
enabled=1
+
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/gf/$basearch/mirrorlist
gpgcheck=1
+
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
+
gpgcheck=1
failovermethod=priority
+
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'''
 +
 
 +
 
 +
4. โหลด Key ที่ใช้กับ Repo วางไว้ใน path : /etc/pki/rpm-gpg/
 +
'''# cd /etc/pki/rpm-gpg/
 +
# wget http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7'''
 +
 
 +
 
 +
5. ติดตั้ง postfix version 3.x
 +
'''# yum install postfix3 postfix-mysql
 +
# systemctl start postfix
 +
# systemctl enable postfix'''
 +
 
 +
 
 +
6. ตั่งค่า MariaDB
 +
'''# systemctl start mariadb
 +
# systemctl enable mariadb'''
 +
 
 +
 
 +
7. ดูสถานะการใช้งานของ MariaDB
 +
'''# systemctl status mariadb'''
 +
 
 +
 
 +
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
 
   
 
   
[gf-plus]
+
#
name=Ghettoforge packages that will overwrite core distro packages.
+
# include all files from the config directory
mirrorlist=http://mirrorlist.ghettoforge.org/el/7/plus/$basearch/mirrorlist
+
#
# Please read http://ghettoforge.org/index.php/Usage *before* enabling this repository!
+
!includedir /etc/my.cnf.d'''
enabled=1
+
 
gpgcheck=1
+
 
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-gf.el7
+
9. สั่ง restart mariadb
failovermethod=priority
+
'''# 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'''

รุ่นแก้ไขเมื่อ 13:23, 8 พฤษภาคม 2563

1 ติดตั้ง mariadb , Postfix , Dovecot และ Packet ที่จำเป็นกับ Server

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


2 เนื่องจาก Postfix version 2.x.x นั้นไม่รองรับกับระบบ EAI จำเป็นต้องใช้ version 3.x.x ขึ้นไป โดยถอด postfix เดิมออก

# yum remove postfix
# yum remove ssmtp
# yum remove sendmail


3 เพิ่ม Repo ใหม่ เพื่อให้สามารถติดตั้ง postfix version 3 ขึ้นไปได้ โดยสร้าง repo

# 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


4. โหลด Key ที่ใช้กับ Repo วางไว้ใน path : /etc/pki/rpm-gpg/

# cd /etc/pki/rpm-gpg/
# wget http://mirror.ghettoforge.org/distributions/gf/RPM-GPG-KEY-gf.el7


5. ติดตั้ง postfix version 3.x # yum install postfix3 postfix-mysql

# systemctl start postfix
# systemctl enable postfix


6. ตั่งค่า MariaDB

# systemctl start mariadb
# systemctl enable mariadb


7. ดูสถานะการใช้งานของ MariaDB

# systemctl status mariadb


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