2010-12-29
postfix 問題集
main.cf
virtual_mailbox_limit 不能比 message_size_limit 小,或二個都註解掉 restart
如果一直沒自動建立 收件者的 資料夾請看一下 權限
sudo chown vmail:vmail -R /home/vmail/
多看一下 /var/log/mail.log 及 /var/log/mail.warn
如果出現 Host or domain name not found. Name service error
sudo vim /var/spool/postfix/etc/resolv.conf
去設定
nameserver 168.95.1.1
nameserver 8.8.8.8
別忘了啟動
/etc/init.d/saslauthd start
/etc/init.d/postfix start
/etc/init.d/courier-pop start
/etc/init.d/courier-imap start
/etc/init.d/courier-authdaemon start
2010-12-24
ubuntu 10.4 的 postfix + mysql + postfixadmin 安裝記錄
sudo apt-get install mysql-client mysql-serversudo apt-get install phpmyadmin apache2 libapache2-mod-php5 php5 php5-mysqlsudo apt-get install postfix postfix-mysql postfix-doc courier-authdaemon courier-authlib-mysql courier-pop courier-pop-ssl courier-imap courier-imap-ssl postfix-tls libsasl2-2 libsasl2-modules libsasl2-modules-sql sasl2-bin libpam-mysql openssl#開始建 postfix to mysql的連結
sudo vim /etc/postfix/mysql_virtual_alias_maps.cf#################################user = mysql_usernamepassword = mysql_pass
#在 main.conf 中加入建立連結的選 項hosts = 127.0.0.1dbname = mysql_dbnametable = aliasselect_field = gotowhere_field = address#################################sudo vim /etc/postfix/mysql_virtual_domains_maps.cf#################################user = mysql_usernamepassword = mysql_passhosts = 127.0.0.1dbname = mysql_dbnametable = domainselect_field = domainwhere_field = domain#additional_conditions = and backupmx = '0' and active = '1'#################################sudo vim /etc/postfix/mysql_virtual_mailbox_maps.cf#################################user = mysql_usernamepassword = mysql_passhosts = 127.0.0.1dbname = mysql_dbnametable = mailboxselect_field = maildirwhere_field = username#additional_conditions = and active = '1'#################################sudo vim /etc/postfix/mysql_virtual_mailbox_limit_maps.cf#################################user = mysql_usernamepassword = mysql_passhosts = 127.0.0.1dbname = mysql_dbnametable = mailboxselect_field = quotawhere_field = username#additional_conditions = and active = '1'#################################sudo vim /etc/postfix/mysql_relay_domains_maps.cf#################################user = mysql_usernamepassword = mysql_passhosts = 127.0.0.1dbname = mysql_dbnametable = domainselect_field = domainwhere_field = domainadditional_conditions = and backupmx = '1'#################################sudo chgrp postfix /etc/postfix/mysql_*.cfsudo chmod 640 /etc/postfix/mysql_*.cf
sudo vim /etc/postfix/main.cf
#################################
# Virtual Mailbox Domain Settings
virtual_alias_maps = mysql:/etc/postfix/mysql_virtual_alias_maps.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf
virtual_mailbox_limit = 51200000
virtual_minimum_uid = 5000
virtual_uid_maps = static:5000
virtual_gid_maps = static:5000
virtual_mailbox_base = /home/vmail
virtual_transport = virtual
# Additional for quota support
virtual_create_maildirsize = yes
virtual_mailbox_extended = yes
virtual_mailbox_limit_maps = mysql:/etc/postfix/mysql_virtual_mailbox_limit_maps.cf
virtual_mailbox_limit_override = yes
virtual_maildir_limit_message = Sorry, the your maildir has overdrawn your diskspace quota, please free up some of spaces of your mailbox try again.
virtual_overquota_bounce = yes
#################################
### 改nameserversudo groupadd -g 5000 vmailsudo useradd -m -g vmail -u 5000 -d /home/vmail -s /bin/bash vmail
sudo vim /var/spool/postfix/etc/resolv.conf
#設定
nameserver 168.95.1.1
nameserver 8.8.8.8
##沒設定寄出的信會就出現Host or domain name not found. Name service error ,nameserver 可指定自家的不一定要用168.95.1.1
### smtp登入的使用者驗證
vi /etc/courier/authdaemonrc## Change to mysql modeauthmodulelist="authmysql"## 顯示 login 的 log 來 debugDEBUG_LOGIN=2sudo vim /etc/courier/authmysqlrc#################################MYSQL_SERVER 127.0.0.1MYSQL_USERNAME mysql_usernameMYSQL_PASSWORD mysql_passMYSQL_DATABASE mysql_dbnameMYSQL_USER_TABLE mailboxMYSQL_LOGIN_FIELD usernameMYSQL_NAME_FIELD nameMYSQL_CRYPT_PWFIELD password#MYSQL_CLEAR_PWFIELD passwordMYSQL_MAILDIR_FIELD maildirMYSQL_QUOTA_FIELD concat(quota,'S')MYSQL_HOME_FIELD '/home/vmail'MYSQL_UID_FIELD '5000'MYSQL_GID_FIELD '5000'#################################/etc/postfix/sasl/smtpd.conf不用這個#################################pwcheck_method: auxpropauxprop_plugin: sqlmech_list: plain login cram-md5 digest-md5sql_engine: mysqlsql_hostnames: 127.0.0.1sql_user: mysql_usernamesql_passwd: mysql_passsql_database: mysql_dbnamesql_select: select password from mailbox where username='%u@%r' and active = 1#################################改這個##########################pwcheck_method: saslauthdmech_list: plain loginallow_plaintext: trueauxprop_plugin: mysqlsql_hostnames: 127.0.0.1sql_user: mysql_usernamesql_passwd: mysql_passsql_database: mysql_dbnamesql_select: select password from mailbox where username='%u@%r' and active = 1##########################sudo vim /etc/pam.d/smtp##########################auth required pam_mysql.so user=mysql_username passwd=mysql_pass host=127.0.0.1 db=mysql_dbname table=mailbox usercolumn=username passwdcolumn=password crypt=1account sufficient pam_mysql.so user=mysql_username passwd=mysql_pass host=127.0.0.1 db=mysql_dbname table=mailbox usercolumn=username passwdcolumn=password crypt=1##########################
### 加入 smtp 的驗証
sudo vim /etc/postfix/main.cf##########################smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain reject_unauth_destination, permit# modify the existing smtpd_sender_restrictionssmtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit# then add thesesmtpd_sasl_auth_enable = yesbroken_sasl_auth_clients = yessmtpd_sasl_security_options = noanonymoussmtpd_sasl_local_domain =##########################
### 建立 key
sudo openssl req -new -outform PEM -out /etc/postfix/smtpd.cert -newkey rsa:2048 -nodes -keyout /etc/postfix/smtpd.key -keyform PEM -days 3650 -x509sudo chmod 640 /etc/postfix/smtpd.key
### 啟用 saslauthd
sudo adduser postfix sasl
sudo mkdir -p /var/spool/postfix/var/run/saslauthd
### 編輯 /etc/default/saslauthd
sudo vim /etc/default/saslauthd
######只改
START=yes
OPTIONS="-c -m /var/spool/postfix/var/run/saslauthd -r"
############
參考來源:http://www.debiantutorials.com/installing-postfix-with-mysql-backend-and-sasl-for-smtp-authentication/sudo /etc/init.d/saslauthd restart
Postfix的Relay Control
Postfix的Relay控制,是在/etc/postfix/main.cf裡面做設定,主要有四個部份:
一、inet_interfaces
二、mynetworks_style
三、mynetworks
四、relay_domains
一、inet_interfaces:
預設值是「all」,如果你的機器有多張網路卡,但又不想要全部都開放 relay,就可以指定只開放給某張網路卡。
二、mynetworks_style:
有三種型態:class、subnet及host,預設值是「subnet」
1. class是可以指定開放給A/B/C class的來源,這種設定方式滿冒險。
2. subnet代表你的機器的IP所在網域的任何一個IP都可以接受relay。(如果同一個subnet裡的機器多,要小心可能被當成垃圾信跳板)
3. host表示只會設定localhost為信任的網域而已。
三、mynetworks:
這可以設定成檔案的方式或是直接以IP/netmask來做設定。
例如:
mynetworks=192.168.1.0/24, 127.0.0.0/8
而如果要用檔案方式:
mynetworks = 127.0.0.0/8, hash:/etc/postfix/access
記得postmap一下這個access檔。
注意:
1. 如果沒有設定mynetworks的話,記得把mynetworks_style改成「host」,不然同一個子網域的IP都可以透過你的機器relay信件(當然如果所有子網域的使用者你都認識的話倒還ok)
2. 如果有設定 mynetworks_style 以及 mynetwork 時,mynetworks的設定會取代掉mynetworks_style。
四、relay_domains:
可以一次指定一個domain來開放relay。
例如:
relay_domains = eddie.com.tw
這樣的設定是代表所有由eddie.com.tw這個domain來的信件都會被當做可信任的,postfix會幫忙relay。
但要注意的是,由「任何地方」來的信件,並且要寄往eddie.com.tw網域的信件,postfix 主機也會幫忙Relay。
詳細設定在/etc/postfix/main.cf裡有說明。
ubuntu 10.4 的 bind9 無法 include 外部路徑
的解決方法
使用 mount --bind 把外部路徑 掛到 /etc/bind 底下
mount --bind 請看 :http://z-win.blogspot.com/2010/05/linux-ftp.html
/bin/bash: Permission denied 及 /bin/ls: Permission denied的問題
/bin/bash: Permission denied 及 /bin/ls: Permission denied的問題
無法使用 ssh 登入
請用root 登入
stat / 看一下是不是 x 的權限不見了
chmod 755 /
就能修正
2010-12-03
在ubuntu安設定openoffice 的service 給 php用
Install Open Office Service on Debian/(K)Ubuntu (versions > 2.3)
- Install OpenOffice-Headless as root (through su, sudo, etc.):
sudo apt-get install openoffice.org-headless
- Create and edit a file named openoffice.sh (for example) with you favorite editor over /etc/init.d:
vi /etc/init.d/openoffice.sh
#!/bin/bash # openoffice.org headless server script # # chkconfig: 2345 80 30 # description: headless openoffice server script # processname: openoffice # # Author: Vic Vijayakumar # Modified by Federico Ch. Tomasczik # OOo_HOME=/usr/bin SOFFICE_PATH=$OOo_HOME/soffice PIDFILE=/var/run/openoffice-server.pid set -e case "$1" in start) if [ -f $PIDFILE ]; then echo "OpenOffice headless server has already started." sleep 5 exit fi echo "Starting OpenOffice headless server" $SOFFICE_PATH -headless -nologo -nofirststartwizard -accept="socket,host=127.0.0.1,port=8100;urp" & > /dev/null 2>&1 touch $PIDFILE ;; stop) if [ -f $PIDFILE ]; then echo "Stopping OpenOffice headless server." killall -9 soffice && killall -9 soffice.bin rm -f $PIDFILE exit fi echo "Openoffice headless server is not running." exit ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0
- Change the permssions to this file:
chmod 0755 /etc/init.d/openoffice.sh
- Install openoffice.sh init script links:
update-rc.d openoffice.sh defaults
- Start the service:
/etc/init.d/./openoffice.sh start
- You can see if openofice is running with this command:
netstat -nap | grep office
tcp 0 0 127.0.0.1:8100 0.0.0.0:* LISTEN 2467/soffice.bin