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

จาก Wiki_EAI
ไปยังการนำทาง ไปยังการค้นหา
แถว 78: แถว 78:
  
  
6. ตั้งค่าความปลอดภัยการเข้างาน mysql โดยจะมีการตั้ง password ของ root user เพื่อ login เข้าใช้งาน (*กำหนดเพียง password ใหม่ และในส่วนอื่นๆให้ enter ผ่านได้เลย)
+
6. ตั้งค่าความปลอดภัยการเข้างาน mariadb โดยจะมีการตั้ง password ของ root user เพื่อ login เข้าใช้งาน (*กำหนดเพียง password ใหม่ และในส่วนอื่นๆให้ enter ผ่านได้เลย)
 
  '''#  mysql_secure_installation'''
 
  '''#  mysql_secure_installation'''
  

รุ่นแก้ไขเมื่อ 04:19, 12 ตุลาคม 2563

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

# yum install postfix dovecot mariadb-server dovecot-mysql postfix-mysql


2. สั่ง start service ของ postfix , dovecot , mariadb ทุกครั้งที่เปิด Server

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


3. ดูสถานะการทำงานของ postfix , dovecot , maridb

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


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

# vi /etc/my.cnf.d/mariadb-server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
# 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 mysqld/mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[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
log-error=/var/log/mariadb/mariadb.log
pid-file=/run/mariadb/mariadb.pid
#
# * Galera-related settings
#
[galera]
# Mandatory settings
#wsrep_on=ON
#wsrep_provider=
#wsrep_cluster_address=
#binlog_format=row
#default_storage_engine=InnoDB
#innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0 
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
# This group is only read by MariaDB-10.3 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.3]


5. สั่ง restart mariadb

# systemctl restart mariadb


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

#  mysql_secure_installation


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

# mysql -u root -p


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

# CREATE DATABASE eaimail;
# USE eaimail;


9. สร้าง user พร้อมกำหนดสิทธิ์การใช้งานให้กับ eaimail database ที่สร้างขึ้นมา

# 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;


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

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


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

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


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

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


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

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


15. สั่ง restart mariadb

# systemctl restart mariadb.service