各位先進好..
最近小弟測試使用Postfix與Mysql搭配,並開啟Selinux
使用測試指令postmap -q xxx mysql:/etc/postfix/mysql-virtual_alias_maps.cf
時會出現以下錯誤
postmap: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket sql.sock' (13)
在Selinux方面有關postfix與mysql部份的限制都已開啟了,但仍無法成功查詢。
不知是否有人知道在不關閉Selinux下,要開啟Selinux那個選項或者其它,才可以查詢成功
底下是main.cfy內容
alias_database = hash:/etc/aliases
alias_maps = mysql:/etc/postfix/mysql-virtual_alias_maps.cf
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
debug_peer_level = 2
html_directory = no
inet_interfaces = all
local_recipient_maps = mysql:/etc/postfix/mysql-virtual_localrecip.cf
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, 172.20.0.11
myhostname = smtps.sytes.net
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.3.3/README_FILES
sample_directory = /usr/share/doc/postfix-2.3.3/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_authenticated_header = yes
smtpd_sasl_path = smtpd
smtpd_sasl_security_options = noanonymous
unknown_local_recipient_reject_code = 550
錯誤訊息已經告訴你,是因為找不到 mysql 的 socket (sql.sock),所以無法連到 mysql。
假如你的 mysql 是用 rpm/yum 裝的,那麼 socket 預設會在
/var/lib/mysql/mysql.sock
假如你的 mysql 是自己編譯的,那麼 socket 應該預設會在
/tmp/mysql.sock
看一下自己系統中,哪個才是 socket 正確的位置。
再找一下 postfix 是哪個設定把 socket 設到 sql.sock 去的,把它改到正確的 socket 位置即可。