精選

2012年11月26日 星期一

ubuntu 12.04 server安裝及使用

052522 移除無效連結,保留供參考用。
※100816個人貼圖不見不再更新
※010313 squirrelmail中文亂碼處理對策
※010213安裝phpMyadmin→第四步
※122412 SquirrelMail及thunderbird都可以正常收發了
※122212 SquirrelMail收發成功→第三步
※121812 postfix寄信收發成功
※120712 DNS完成→web svr完成
※120512安裝lxde桌面←如有需要
※120312文件共享
※113012成功安裝client機xp,在win用Xming Putty連入使用→第二步
112712開始安裝於約5年前的老舊機

※010913追加 postfix設定檔位置
/etc/postfix/main.cf
dovecot設定檔位置
/etc/dovecot/dovecot.conf
squirrelmail設定檔位置
/etc/squirrelmail/config.php及/etc/php5/apache2/php.ini
改squirrelmail寄出付加檔2M到任意值
010913參考取自

不自量力のWeithenn: OpenLDAP-SquirrelMail Auth With←已無連結

摘要如下...

步驟2.修改 PHP 設定檔 (php.ini)

必須修改 PHP 設定檔 (php.ini) 否則屆時將造成連接登入視窗發生錯誤,順便將上傳附件最大容量限制改為 10MB (也就是屆時使用者可夾帶的 E-Mail 附件大小)
 #vi /usr/local/etc/php.ini
 file_uploads = On
 session.auto_start = 1
 upload_max_filesize = 10M   2^3        //設定上傳附件最大容量限制為 10MB (預設為 2M)
修改原因 php.ini 請參考如下 SquirrelMail 說明
 For SquirrelMail to work properly you will need to make sure the following option is set in your php.ini file:
 file_uploads = On
 If you have problems with SquirrelMail saying "you must login" after you just have, the following php.ini option may help:
 session.auto_start = 1

查我的php在/etc/php5/apache2/php.ini
用nano找到改如upload_max_filesize = 10M
然後apacge2重啟動

參考資料

A Mailserver on Ubuntu 12.04: Postfix, Dovecot, MySQL


※我的svr與internet間有brazilFW防火牆Server安裝參考以下二處



Step By Step Ubuntu 12.04 (Precise) LAMP Server Setup
重點如下:
1. 固定IP
2. 主機名,使用者名2次同
3. 第3處serverguide.pdf
4. 安裝openssh或Puppet

管理第一步→如何看server主機的內容
參考以下2資料

Ubuntu Server 10.04LTS @ 和風←已無連結

How to install webmin on ubuntu 12.04 (Precise) server | Ubuntu Geek←已無連結

參考第2...
sudo apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl apt-show-versions python
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.580_all.deb
sudo dpkg -i webmin_1.580_all.deb
now you need to access https://ubuntu-serverip:10000
登入後即可如下圖
如要換語言,參考第1
...安裝Webminubuntu Server...
如要看各目錄→上圖其他上傳和下載檔案管理者(112812)
進入檔案管理員→要安裝plugin,firefox直接安裝,
chrome參考

How to install Oracle Java web plugin on Chrome in 12.0


sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java7-installer


再由ubuntu軟体中心找
Icedtea Java外掛程式(瀏覽器外掛)後即可用。(120512)

113012
第二步→成功安裝client虛擬機xp如下圖
重點後述
參考

Installing KVM Guests With virt-install On Ubun

如要原機clone,直接完成。(120312)


在win要先安裝Xming及其字型和putty,
由putty→X11(SSH)→Enable X11 forwarding要選,
下一格填入localhost:0
連入port和預設22不同,因有brazilfw軟体port轉換
登入後鍵入virt-manager即可管理使用,但由win連到svr的virt-manager中文亂碼,而進入虛擬機操作正常。

120312
※120312文件共享,參考
Kvm教程- Ubuntu中文 6.1文件共享,然後在Webmin→
伺服器→Samba視窗檔案分享→新增檔案分享。如下圖
如加入usb,選後設好先離開virt-manager再進入才可使用。

120512
※120512安裝lxde桌面,參考
ubuntu server 12.04 安裝 LXDE 版桌面環境←連結失效
摘錄部份如下...
3.安裝 lxde
升級 0 個,新安裝 235 個,移除 0 個,有 56 個未被升級。
需要下載 62.0 MB 的套件檔。
此操作完成之後,會多佔用 191 MB 的磁碟空間。

安裝步驟很簡單:    1. 執行:apt-get install lxde
    2. 安裝之後,重新開機
    3. 進入桌面環境之後,看不到中文,中文變成像撲克牌一樣的方塊字
三、解決方塊字問題,因為沒有中文字形的關係
    1. 執行:apt-get install ttf-arphic-uming
    2. 下列【新】套件將會被安裝:fonts-arphic-uming、ttf-arphic-uming,將佔用 21.6 MB 的磁碟空間。
    3. 登出後,中文顯示OK了。
四、切換開機自動進入 X Window 還是文字模式
在桌面環境安裝好之後,我一直在嘗試讓系統一開始進入文字模式,等到需要的時候在進入桌面環境。卻一直都無法成功,直到後來我找到這篇memo。
2.Debian、Ubuntu的方式
Debian 或 UbuntuDebian或Ubuntu是利用SysVinit啟動X Display Manager,亦即是所謂的圖像模式登入畫面。只要你安裝任何一個X Display Manager(包括xdm、gdm、kdm和wdm),系統開機時就會自動執行,進入圖像模式。如果你想開機自動進入文字模式,你可以選擇移除所有X Display Manager
    1. 執行: apt-get remove xdm gdm kdm wdm lxdm
    2. 安裝: apt-get install xinit
    3. 從此你就可以開機先進入文字模式,再使用 startx 進入桌面環境
3.如果你要更改桌面管理程式:設定default display manager
    1. 執行:dpkg-reconfigure lightdm(或是gdm、lxdm)
    2. 或是更改 /etc/X11/default-display-manager 這個檔案
    3. gdm的話:/user/sbin/gdm
    4. lightdm:/user/sbin/lightdm
    5. lxdm:/usr/sbin/lxdm
※此部份現未使用,現用webmin 如果忘記密碼
Reset Password Webmin in Ubuntu

 
Login to computer and login terminal with as root
to change root password in webmin use this included Perl Script
 
# /usr/share/webmin/changepass.pl /etc/webmin root 
login to webmin with your reset password

※120712 DNS完成→web svr完成
先架BrazilFW於internet與lan間,參考個人110912 "安裝LAMP..."
在/var/www/index.html修改web svr啟用內容,記後先設定權限777

※121012 Brazilfw從internet web管理
在win或ubuntu都要安裝Putty,現以ubuntu固定IP方式,
以下參考取自http://www.phcno1.net/modules/tad_book3/page.php?tbdsn=5
...

3)透過SSH遠端管理Brazilfw
很多人喜歡透過web方式遠端登入主機來進行管理,不過一般而言使用SSH來管理就可以了,在windows系統中可以下載putty來做管理
執行putty,於Host Name填入Brazilfw主機的WAN IP、選取使用SSH,接著按下Open
之後會做帳號、密碼的認證,請輸入root及密碼,認證通過後會出現如下畫面
你會發現和本機登入的畫面一樣,操作和本機登入一樣。
使用Tunnels方式遠端使用Web登入管理
但必須使用固定IP,否則必須透過NO-IP 或者 dynDNS方式才能由外網使用domain方式來遠端web管理,有個外掛叫「ipupdate」是很有用的。http://www.brazilfw.com.br/downloads/addons/
 
使用Putty-->(SSH/Tunnels)-->Source port set to 8180 
Destination set to 192.168.0.1:8180-->Add
 
點選Session填入遠端Brazilfw主機的WAN IPPort 22SSH-->Open連線成功後使用root及其密碼登入,接著把SSH視窗縮小開啟瀏覽器,於網址處輸入http://127.0.0.1:8180/就可以看到登入畫面,點選「Welcome to tne Administrator」會出現帳號、密碼認証對話方塊,請輸入使用者:root及其密碼,接著按下「確定」,你應該就可看到BrazilfwWeb管理介面了。

※121812 postfix寄信收發成功
在/etc/hostname改us124→mail.xxx.idv.tw
BrazilFw開port 25
相關檔案
/etc/postfix/main.cf→webmin/postfix/一般
/var/log/mail.log→看

收信未成功,將mail.xxx.idv.tw加入註冊的DNS主機代管後即可
收信成功→僅在server上

121812
參考Webmin使用教程:图形配置Linux服务器- Linux - 烈火网←連結失效
摘要如下:我參考5
...


  4、配置postfix
  在“server”中选择“postfix configuration”—〉选择“general options”—〉设定“what domain to use in outbound”为“use domainname”表示使用当前邮件服务器的域名作为邮件发送者的域名;设定“what domains to receive mail for”为“whole domain”,表示当前邮件服务器接收整个域的所有邮件;设置“network interfaces for receiving mail”为“all”,表示通过所有的网卡来接收邮件;设置“hostname of this mail system”为当前邮件服务器的主机名输入“mail.test.com”;在“local internet domain name”中输入当前主机所在的域名“test.com”;其他项保持默认值—〉按“save and apply”后完成
  5、为邮件服务器添加用户帐号
  在“webmin”的“system”中的“users and groups”—〉选择“local groups”按“create a new group”—〉在“group name”中输入“mailuser”—〉在“local user”中选择“create a new user”—〉在“username”中输入“mailuser1”,在“home directory”中输入“/home/mailuser1”,在“password”中输入“normal password”,在“group membership”中“primary group”的“existing group”选择“mailuser”—〉按“create”按钮完成用户创建
  5、 邮件别名和虚拟域
  邮件别名:
  在“webmin”的“server”中选择“postfix configuration”—〉选择“mail aliases”—〉选择“create a new alias”—〉在“alias options”中设置“alias databases used by the local delivery agent”和“alias databases built by newaliases command”为“hash:/etc/postfix/aliases”—〉选择“create a new alias”—〉在“alias properties edition”页中“name”输入“mailuser3”在“alias to…”中输入“mailuser2”(mailuser3为不存在的账号alias to mailuser2为已存在的账号,所以发给mailuser3的邮件会自动转到mailuser2)
  邮件的虚拟域:
  在“webmin”的“server”的“postfix configuration”中—〉选择“virtual domain”—〉设置“domain mapping lookup tables”为“hash:/etc/postfix/virtual”—〉选择“save and apply”—〉在次进入“virtual domains”选择“new mapping”新建一个映射—〉在“edit a map”中设置“name”为“@newtest.com”,“maps to…”为“@test.com”(表示把所有发往@newtest.com的信映射到@test.com)--〉按“save mapping”保存

121912
外網可寄但仍不能收
參考http://yunol.com.tw/phpbb3/viewtopic.php?f=15&t=25136
摘要如下:
安裝squirrelmail的webmail
....
安裝Webmail介面---Squirrelmail:
sudo apt-get install squirrelmail

接著跑設定:
squirrelmail-configure
之後自行依照對話選框設定
比較需要設定是第2大項Server Settings
Command >> 2
裡面有Domain需改成自己的Domain
Command >> 1
例如mail.unas.com.tw
然後按下去Enter鍵,跳出之後就看到1. Domain,顯示為剛剛的設定囉!
squirrelmail-configure01.png
squirrelmail-configure01.png (60.13 KiB) 被瀏覽 2856 次

R Return to Main Menu→按R鍵回主選單→Command >>10。
還有第10大項的語言設定(10. Languages)要設定
1. Default Language:en_US改成zh_TW
2. Default Charset:iso-8859-1改成Unicode
按Q離開

改完之後要修改apache2對應squirrelmail的畫面位置,好讓apache2知道squirrelmail該如何進去

sudo cp /etc/squirrelmail/apache.conf /etc/apache2/sites-enabled/squirrelmail
可以修改 /etc/apache2/sites-enable/squirrelmail這個檔案第一行的Alias
例如原本:Alias /squirrelmail /usr/share/squirrelmai
改成:Alias /unasmail /usr/share/squirrelmail

讓要進去squirrelmail網頁介面只需打:
http://unas.com.tw/unasmail/

之後要編輯dovecot讓squirrelmail可以存取POP跟IMAP的服務

sudo gedit /etc/dovecot/dovecot.conf
搜尋並加上protocols = imap imaps
listen = * 前面的註解也拿掉,允許所有的port口使用
之後重啟dovecot跟apache2的服務

接著就可以開啟遊覽器打入:你的domain/squirrelmail

就可以看到一隻松鼠在遊覽器上面了!
sm_logo.png

登入後顯示IMAP錯誤
再參考第5篇,
...
設定imap與pop3
修改dovecot.conf:
sudo gedit /etc/dovecot/dovecot.conf
#listen = *, :: #前方的#拿掉啟用。
修改10-mail.conf
sudo gedit /etc/dovecot/conf.d/10-mail.conf
# mail_location = maildir:~/Maildir
# mail_location = mbox:~/mail:INBOX=/var/mail/%u
# mail_location = mbox:/var/mail/%d/%1n/%n:INDEX=/var/indexes/%d/%1n/%n
mail_location = maildir:~/Maildir
修改10-master.conf(我自己使用沒設定這個)
sudo gedit /etc/dovecot/conf.d/10-master.conf
service imap-login {
inet_listener imap {
port = 143
}
inet_listener imaps {
port = 993
ssl = yes
}
service pop3-login {
inet_listener pop3 {
port = 110
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
改完後儲存
重新啟動postfix和dovecot
sudo /etc/init.d/dovecot restart
sudo /etc/init.d/postfix restart

安裝sqmail
sudo apt-get install squirrelmail

設定squirrelmail-configure
依照對話選框設定
比較需要設定是第2大項
裡面有Domain需改成自己的Domain
例如mail.unas.com.tw
還有第10大項的語言設定
en_US改成zh_TW
iso-8859-1改成Unicode

修改apache2對應sqmail的畫面位置,好讓apache2知道sqmail該如何進去。
cp /etc/squirrelmail/apache.conf /etc/apache2/sites-enabled/squirrelmail
可以修改 /etc/apache2/sites-enable/squirrelmail這個檔案第一行的Alias
例如原本:Alias /squirrelmail /usr/share/squirrelmai
改成:Alias /unasmail /usr/share/squirrelmail
讓要進去sqmail網頁介面只需打:
http://unas.com.tw/unasmail/

開啟遊覽器打入:你的domain/squirrelmail
就可以看到一隻松鼠在遊覽器上面了!
修改squirrelmail的介面 
/etc/squirrelmail/config.php
網頁存放(自製LOGO可以放入images的資料夾):
/usr/share/squirrelmail
我的squirrelmail就改了自製的LOGO

可寄信了,但仍收不到信,如下圖
有人建議改用roundcube,現未測試,
如果squirrelmail-configure改亂了,到/etc/squirrelmail下刪除config.php,再將config_default.php複製並命名config.php。 

122112
問題在svr未安裝啟用dns伺服器,由nslookup檢查
在Webmin由BIND 8 DNS伺服器的下方(現存的D
S區域)→建一新,如xxxx.idv.tw
後,在其
1.  位址→mail.xxx.idv.tw
2.  名稱伺服器→xxx.idv.tw
3.  郵件伺服器→xxx.idv.tw優先值 10

nslookup
> mail.xxx.idv.tw
Server:        192.168.0.1
Address:    192.168.0.1#53

Non-authoritative answer:
Name:    mail.xxx.idv.tw
Address: xxx.xxx.xxxx.xxx
> server
xxx.xxx.xxxx.xxx
 Default server: xxx.xxx.xxxx.xxx 
Address: xxx.xxx.xxxx.xxx#53 ...未完
 
※122212 SquirrelMail收發成功→第三步
今天可以了,但thunderbird仍不能寄出(好像是認證問題)。
在/var/log/mail.err找到→chmod 0600 /var/mail/*
詳看http://wiki2.dovecot.org/Errors/ChgrpNoPerm
只讓使用者有讀取及寫入權
之後SquirrelMail正常收發了

※122412 SquirrelMail及thunderbird都可以正常收發了。   
終於稍了解Dovecot 設定mail_location 的重點,由Webmin檔案管理者查看進出信件的位置,當Webmin由使用者新建user後,可能也要手動在建該user,並改該使用者權限,
Dovecot設定如下
dovecot.conf上圖文字設定為
mail_location = mbox:~/mail/:INBOX=/var/mail/%u

thunderbird設定如下
安全與認證
連線安全性 STARTTLS,認證方式 普通密碼

※010313 squirrelmail中文亂碼處理對策
※010713測試ok
參考取自Vega的筆記本: SquirrelMail安裝設定備忘
http://vega02.blogspot.tw/2011/07/squirrelmail.html
摘要如下:
...
 2.操作介面中文出現亂碼
編輯 /usr/share/squirrelmail/functions/i18n.php

$languages['zh_TW']['NAME'] = ‘Chinese Trad’;
$languages['zh_TW']['CHARSET'] = ‘big5′;
$languages['zh_TW']['LOCALE'] = array(‘zh_TW.UTF-8′, ‘zh_TW.big5′);
$languages['tw']['ALIAS'] = ‘zh_TW’;

3.下載附件中文檔名亂碼
編輯 /usr/share/squirrelmail/src/download.php
$filename = charset_encode($filename,$default_charset,false);
$filename = iconv(‘big5’,’utf-8’,$filename);

※010213安裝phpMyadmin
參考取自

ubuntu 12.04 伺服器版安裝

http://blog.dgps.kh.edu.tw/blog/jimjye/ubuntuc/2012/06/20/3655←連結失效
摘要如下:
...
(五)安裝phpMyAdmin


    1. 執行 apt-get install phpmyadmin 開始安裝
    2. 安裝過程第一個問題:Web server to reconfigure automatically:  選 apache2
    3. 安裝過程第二個問題:Configure database for phpmyadmin with dbconfig-common? 選 No 
    4. 安裝完成要重啟服務:執行 service apache2 restart
    5. 使用瀏覽器檢查 http://192.168.2.11/phpmyadmin/
    6. 如果發現無法登入,請重啟mysql 服務,再重新登入
    7. 進入phpmyadmin後,出現了這個問題:phpmyadmin 進階功能未全部設定
    8. 解決方法:執行 vi /usr/share/phpmyadmin/libraries/config.default.php
    9. 改第47行:$cfg['PmaNoRelation_DisableWarning'] = true; 
    10. 重啟服務: service apache2 restart

但無登入晝面
Not Found 
the requested url /phpmyadmin was not found on this server
參考
...To do so, run these two commands in terminal sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.confsudo /etc/init.d/apache2 restart

出現了,如下

安裝成功,更新內容續補上

沒有留言: