记 搭建邮件服务器(postfix)踩过的坑

来源:互联网 发布:风尚设计美工教程 编辑:程序博客网 时间:2024/05/21 06:25

首先搭建 postfix 邮件服务器本身难度不大,主要是当遇到问题了能够找打解决办法,有些问题是系统配置问题,你得找到地方修改,再次是有些问题不是那么明显的就在终端显示出来了,你得学会分析日志,分析日志的前提是你得知道有对应日志的存在。先附上链接  www.cmhello.com/lnmp-centos-postfix.html, 基本上按照这篇文章的方法来配置,就可以成功了,但是还是会遇到一些坑,废话不多说了,接下来说说我踩到的坑。

1.error while loading shared libraries:/usr/lib64/mysql/libmysqlclient.so.16: cannot open shared object file: No such file or directory


大致意思是说 libmysqlclient.so.16 这个库文件没有找到

然后通过google找到了这个链接  https://kb.plesk.com/en/120923

大致解决办法就是 先用 ldd命令查看缺少的库文件(ldd命令用于判断某个可执行的 binary 档案含有什么动态函式库。


Cause

#动态链接库默认是在 /usr/lib64或者 /usr/lib 这两个地址寻找,但是这个两个路径下的子目录 在 /etc/ld.co.conf 里面没有提到会被忽略

Dynamic library is being searched in the'/usr/lib64' or '/usr/lib' folders, but subfolders not mentioned in /etc/ld.co.conf are ignored.

Resolution

#找到对应的动态链接库的地址

Find the folder where shared libraries are located, for example,/usr/lib64/mysql or /usr/lib64/sw

~# echo '/usr/lib64/mysql' >> /etc/ld.so.conf.d/mysqlclient.conf~# echo '/usr/lib64/sw' >> /etc/ld.so.conf.d/sw_libs.conf~# echo '/usr/lib/sw' >> /etc/ld.so.conf.d/sw_libs.conf~# echo '/usr/lib/libboost-plesk-1.54.0/' >> /etc/ld.so.conf.d/sw_libs.conf~# ldconfig -v 


其实这个坑百度了好久都没有解决,启示是要用google


2. 邮件服务器搭建完了然后用shell 下面的 mail -s "" 命令测试了一下发送成功,本以为就大功告成了,到实际的业务代码里面(python smtplib 发送邮件却失败了),python里面报错大意是 connection断了,拿了错误 直接google了找了好久也没有答案,然后自己用telnet localhost 25 连,也是报connection断了。然后 查看邮件日志/var/log/maillog,fatal: non-null host address bits in "127.0.0.1/8", perhaps you should use "127.0.0.0/8" instead



然后就回到 postfix 的 main.cf 里面 修改了  mynetworks 的配置,最后 在 telnet ,成功了,业务代码也成功了。

启示,在没有搞明白到底是什么错误之前,直接去google的时候很难找到问题所在,先找错误日志,在日志中找到问题所在,再google错误。


0 0