Showing posts with label Server. Show all posts
Showing posts with label Server. Show all posts

【Note】Use IP Address to Connect Web Server at Fedora Core 9 | IP Address直接訪問網頁伺服器 at Fedora Core 9

The apache web server at Fedora Core 9 has default setting by used mod_security. After we normal install apache web server, we can't use http://ip.address/ to connect and must use http://ip.address:80 or http://hostname.domain/ . It's caused by the apache security setting with mod_security. We can disable it.

#vi /etc/httpd/modsecurity.d/modsecurity_crs_21_protocol_anomalies.conf

and find the line

SecRule REQUEST_HEADERS:Host "^[\d\.]+$" "deny,log,auditlog,status:400,msg:'Host header is a numeric IP address', severity:'2',id:'960017'"

use # to mark(disable) it.

#service httpd restart

then you can use ip address to visit it.

----------------------------------------

裝好Fedora Core 9之後,打開appache server發現無法使用IP直接訪問網站,必須使用http://ip:80 或者是 http://hostname.doamain才行。查了文件才發現原來是新版本的有加上mod_security 的功能,然後在看一下mod_security的設定,發現只要取消某一項規則就可以了。

#vi /etc/httpd/modsecurity.d/modsecurity_crs_21_protocol_anomalies.conf

找到下面這一行敘述

SecRule REQUEST_HEADERS:Host "^[\d\.]+$" "deny,log,auditlog,status:400,msg:'Host header is a numeric IP address', severity:'2',id:'960017'"

把它mark起來(在最前頭加個#)

#service httpd restart

重新啟動httpd之後,就可以直接使用IP瀏覽網站了。

P.S.:有關ModSecurity的文件,可至ModSecurity® Reference Manual

[備忘]尋找一堆檔案裡的字串(Unix like) find & grep合用

用途:尋找未知檔案裡的字串

find 資料夾 搜尋檔案型態或名字 \檔名.副檔名 -exec grep -l "字串名稱" {} \;

例如,在當前資料夾裡尋找副檔名為php的檔案,並且其檔案內容包含home-big.png這個字串

#find ./ -name \*.php -exec grep -l "home-big.png" {} \;

WAM使用規劃

過去,學校都會以WAM來建置學生當年電腦課所需的帳號密碼,學生都得背一組新的帳號密碼以便在新的學年裡上課及繳交電腦作業或其他課程作業使用,而一年之後,就得重新來過,包括當年所完成的作業也是一併刪除,最後,當孩子到六年級的時候他們所能帶走的就只有六年級的電腦作品(如果學生每年沒有自己備份的話)。
為了改變此種情形,我們規劃新的方式:
1、學生在校期間只有一組帳號密碼。
2、每年作業不刪除,直至學生畢業,作為畢業光碟的一部分。
3、老師檢視學生作業方便。
4、每年不管學生是否在原班或是升級,都可以以最簡單最快的方式來update。

最後想的方法是以學生入學時的學號當作帳號,密碼以身分證字號為主,每個學生的配額為100MB,作業以學生自己建置之資料夾來區分年級及作業別。
建立帳號之時先建立學生群組,學生之家目錄建置於學生群組的資料夾之下;
建立一資料夾,只有老師與管理者才讀寫,學生唯獨,作為老師欲分享給學生之區域;
老師可瀏覽及修改學生群組之目錄底下的所有資料夾(資料夾下包含所有學生之家目錄)。

Samba之smb.conf部分內容如下:

[www]
comment = 學生個人空間
browseable = yes
path = %H/www
writeable = yes
create mode = 0711
directory mode = 0755
veto files = /*.exe/*.eml/*.bat/*.nws/*.vbs/*.com/*.dll/*.msi//*.zip/*.rar/*.reg/*.sh
;預防學生存入不允許之多餘檔案,佔掉空間,譬如:遊戲
delete veto files = yes

[works]
browseable = yes
writeable = yes
printable = no
path = /home/students
write list = @teachers,@admins,
comment = 學生作品(老師專用)
valid users = @admins,@teachers
admin users= @admins,@teachers

[share]
browseable = yes
read list = @students
writeable = yes
printable = no
write list = @teachers,@admins
path = /share/share
comment = 共享區

另外,自己寫了一支小程式應付每年因升級或編班而有變動之網頁,用以方便瀏覽學生作業。
下載http://cid-9383760834731968.skydrive.live.com/self.aspx/Public/createform.zip
(倉促之下寫成,版面處理很差,如有先進幫忙修正,感激不盡)
^^

LDAP 的suffix問題

從開始學LDAP到現在已經不知道看過多少書跟多少文章與document,可是到最後總是有問題,不能建帳號或是搜尋之類的,到最近我才發現我的問題所在,媽呀!為什麼沒有一篇有說清楚的,還是我太笨了?!

在slapd.conf裡,最重要的就是設定suffix與rootdn,假設你所可以管理的最base的domain是domain.tp.edu.tw,那麼suffix及root裡的dc.....就得是dc=,domain,dc=tp,dc=edu,dc=tw。一開始我一直覺得自己很聰明,我都設成dc=localhost,dc=,domain,dc=tp,dc=edu,dc=tw。所以一直會有問題,而且更無法與Samba網域結合,直到我改成dc=,domain,dc=tp,dc=edu,dc=tw之後才行。不過至少學到了很多,哈!

LDAP Error: Warning - No DB_CONFIG file found in directory

#service ldap restart
之後顯示如下訊息:

正在停止 slapd: [ 確定 ]
正在為 slapd 檢查設定檔案: bdb_db_open: Warning - No DB_CONFIG file found in directory /var/lib/ldap: (2)
Expect poor performance for suffix dc=taes,dc=tp,dc=edu,dc=tw. config file testing [ 確定 ]
正在啟動 slapd: [ 確定 ]

上面的所顯示的錯誤訊息裡的DB_CONFIG file 在/etc/openldap/DB_CONFIG.example,複製到/var/lib/ldap裡,改成DB_CONFIG,然後重新啟動LDAP即可。

LDAP: smbldap-populate error

初始資料庫時,下了
# smbldap-populate
結果出現以下的錯誤訊息,找了很久,在網路上搜尋了很久也沒有結果,雖然知道是驗證方面出了問題,但是不知道哪裡錯了?因為每個相關檔案都檢查無誤。最後,發現的原因真是令人噴飯。解決方法在文章最底部!

Use of uninitialized value in substitution (s///) at /usr/lib/perl5/vendor_perl/5.8.8/smbldap_tools.pm line 135, line 73.
Populating LDAP directory for domain taes (S-1-5-21-947298777-4161204931-40633681)
(using builtin directory structure)

adding new entry: dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 2.
adding new entry: ou=Users,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 3.
adding new entry: ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 4.
adding new entry: ou=Computers,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 5.
adding new entry: ou=Idmap,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 6.
adding new entry: uid=root,ou=Users,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 7.
adding new entry: uid=nobody,ou=Users,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 8.
adding new entry: cn=Domain Admins,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 9.
adding new entry: cn=Domain Users,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 10.
adding new entry: cn=Domain Guests,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 11.
adding new entry: cn=Domain Computers,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 12.
adding new entry: cn=Administrators,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 16.
adding new entry: cn=Account Operators,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 18.
adding new entry: cn=Print Operators,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 19.
adding new entry: cn=Backup Operators,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 20.
adding new entry: cn=Replicators,ou=Groups,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 21.
adding new entry: sambaDomainName=taes,dc=taes,dc=tp,dc=edu,dc=tw
failed to add entry: modifications require authentication at /usr/sbin/smbldap-populate line 499, line 21
Please provide a password for the domain root:
Use of uninitialized value in substitution (s///) at /usr/lib/perl5/vendor_perl/5.8.8/smbldap_tools.pm line 135, line 73.
No such object at /usr/lib/perl5/vendor_perl/5.8.8/smbldap_tools.pm line 353.

解決的方法很簡單,修改/etc/openldap/slapd.conf這個檔案裡的rootpw位置,rootpw前面不能有空格,有的話就會出現以上的錯誤訊息,拿掉就好了!

Set Powers for One Document of One Person | 設定網域單一資料夾給某人權限

A teacher said he did not enter his own folder, the folder when the double click will show "You do not have this folder competence." Checked it, the original folder authority is being replaced by others, and as long as add his account with write, read, execute can be.

1, Sign in by Domain\Admins.
2, On the folder, right-click and select "Content."
3, "Safety "-->"Add New."
4, "Advanced "-->" Immediately Find "-->" join the domain account "-->"OK."
5, Granting authority, please note that do not check "Full Control". Full Control may cause Domain\Admins can not manage the folder, if the people leave, they must use other methods to loot the authority.
--------
某個老師說他不能進他的資料夾,當雙鍵該資料夾時,會出現"您沒有此資料夾權限"。查了一下,原來是資料夾權限被換成其他人了,只要加他的帳號及修改、讀取、執行權限即可。

1、以Domain\Admins的身分登入。
2、在該資料夾上點擊滑鼠右鍵,選擇"內容"。
3、"安全性"-->"新增"。
4、"進階"-->"立即尋找"-->"欲加入權限之帳號"-->"確定"。
5、給予權限,請注意,請勿在"完全控制"上打勾。完全控制有可能造成Domain\Admins未來無法管理該資料夾,如果該人離職,就必須另外用方法取回權限。

Domain can't be found or sign failure | 網域找不到或登入失敗

The past two days have received a case: user log on network domain there will be no domain found; Or at the same computer, only one user can login the network domain successfully, when logout, other people will not be able to re-sign and get the error messenge "domain XXXX not be able to use ..." and so on the message. But ask the user who can sign before to sign again, it can be used.
Why?
Unknown at present. After work, chat with afore manager, he mentioned that probable the second AD problems of backup. AD Account with no major changes simultaneously, and make conflict or domain authentication failure. " Today, dealt with a Client PC that previous two days unable to add or remove domain, but now can be added or removed, speculate the tow ADs two days ago were not synchronous changes Client-account, now handled when they are finished backup and can add to network domain. This problem must be maintained at work until next week.
-------------
這兩天紛紛接到一種案例:使用者在登入網域時會有找不到網域的現象;或者同一台電腦只有一個人可以登入網域,當登出後,其他人再行登入時便會出現"網域XXXX無法使用..."等等的訊息,但是再請可以登入之使用者登入時卻又可以使用網域。
為什麼?目前還未知,在下班後與之前的資訊組找聊天,他提到:"有可能是第二台備份AD出了問題。與主要AD的帳號沒有同步更改,以致產生網域衝突或認證失敗的原因。" 因今天處理一台Client PC在前兩天無法加入或移除網域,但現在卻可以,推測是兩台AD在兩天前處理時並未同步更改Client端帳號,現在處理時卻已備份完畢而可以加入網域。此番現象須待下星期上班時再做查修。

Install FckEditor for Drupal

又重新架了CMS管理系統,使用的還是我最喜歡的Drupal。這是選擇的是drupal-5.3版的,要作為學校的數位教材管理系統,也一併整併校內重複的兩、三個教材網站,未來只使用同一個即可。
在安裝時,想安裝一個WYGIWYS編輯器,比較了TinyMCE與FckEditor之後,我比較中意的是FckEditor,但在安裝時卻遇到了問題(FCKeditor_2.5b.tar.gz):
FckEditoer有個上傳檔案及瀏覽伺服器端的工具,使用時卻出現如圖中的錯誤訊息


重點在
/drupalroot/modules/fckeditor/fckeditor/editoer/filemanager/browser/default/connectors/php/connector.php was not found on this server
這一句話,就是在fckediort裡的一個工具沒找到
查看的一下fckeditor目錄的內容才現,原來在FCKeditor_2.5b這一版裡,connectors放錯目錄了,它原本放在fckeditor/filemanager下,只要複製一份connectors至/fckeditor/browser/default/底下即可解決。

另外,可以修改fckeditor上傳檔案的位置,譬如我將位置改放到drupal/files裡面。
修改/fckeditor/browser/default/connectors/php/config.php

1.
$Config['Enabled'] = false ;
改成
$Config['Enabled'] = true ;
2.

$Config['UserFilesPath'] = '/userfiles/' ;
改成
$Config['UserFilesPath'] = '/drupalroot/files/userfiles/' ;

這樣就成了!

另外,也開啟調整了所有個工具,將它放整齊一點
修改/fckeditor/fckconfig.js
找到
FCKConfig.ToolbarSets["Default"] = [
.....(略)
];

將這一段改成

FCKConfig.ToolbarSets["Default"] = [
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],['TextColor','BGColor'],
'/',

['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote'],['FitWindow','ShowBlocks','-'],
'/',
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],['FitWindow','ShowBlocks','-','About']
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
['Style','FontFormat','FontName','FontSize'] // No comma for the last row.

] ;
即可!

Install MediaWiki | 安裝MediaWiki

昨天在玩幾個Wiki套件,其中MediaWiki算是比較完整而且容易裝的,我裝的是mediawiki-1.11.0版

安裝的方法也不難,我在自己的主機(Fedora Core 6)及之前申請的Byethost上各裝了一次,差別在於在自己的主機上可以修改部分比較多,譬如php.ini及httpd的設定及安裝 Turck MMCacheeAcceleratorAPC or XCache,MySQL則無差別。

以下是我在免費的虛擬主機Byethost上安裝的樣子(在自己的主機更好裝,方法都一樣)。

1.、上傳整個Mediawiki到網頁根目錄裡。

2、用web安裝,連上http://your.domain/mediawiki就會進入
http://your.domain/mediawiki/config/index.php安裝畫面。

安裝畫面裡會顯示你有沒有達到最低的安裝需求,沒有的話就得去修改。譬如我在Byethost上只能修改PHP Flags,enable或disable某些選項才能安裝;或者顯示錯誤訊息,找不到某些套件之類的。不過最後只要看到 Environment checked. You can install MediaWiki. 這代表你至少可以安裝MediaWiki,不過不一定會成功就是了。

3、不囉唆!現在就來試試吧!
Site Config:
Wiki name: 站台名稱(一定要)
Contact e-mail:連絡信箱(可選)
Language: 站台語言。建議安裝時選擇en-English,安裝後再換回正體中文,以免首頁 變成 中文連結,導致某些瀏覽器無法讀取。
Copyright/license:宣告智慧財產權的Logo,授權方式等。
Admin username:站台管理者帳號
Password:管理者密碼
Password confirm:再打一次管理者密碼
Shared memory caching:設定Memcached servers,有就設定,沒有就選No caching。

E-mail, e-mail notification and authentication setup
E-mail features (global): 以E-mail來傳送密碼或是認證或是連絡使用者,要啟用就選 Enabled。
User-to-user e-mail:是否同意使用者之間的連絡。
E-mail notification about changes:E-mail通知,Disable或是只用於討論頁面 (Enabled for changes to user discussion pages only)或是選擇
"更改用 戶討論頁,並以網頁監視(不推薦用於大型wikis)
(Enabled for changes to user discussion pages, and to pages on
watchlists (not recommended for large wikis))。
E-mail address authentication:E-mail認證。

Database config
Database type:資料庫類型MySQL
Database host:資料庫位置,不是本機(LocalHost),也可以打上主機位IP或是domain。
Database name:資料庫名稱。
DB username:對資料庫有權限的使用者名稱。
DB password:資料庫使用者的密碼。(不可空白)
DB password confirm:上面的密碼再打一次。

Superuser account:也可以使用資料庫的最高權限管理者
Superuser name:資料庫最高管理者帳號。
Superuser password:資料庫最高管理者密碼。

Database table prefix:資料庫的前置字元,可以自己設定或不加,我是打上mw_
Storage Engine:儲存的引擎,通常選預設的InnoDB即可
Database character set:資料庫字元編碼,看自己的喜好吧!

再來,Install MediaWiki!

最後將config/LocalSettings.php往上一一層,跟config平行的層次,再選 this link就OK啦!

Enjoy!

在Byethost上架設Joomla1.0.13

第一次使用byethost,我先玩玩joomla,我不想用它內建的Package去安裝,(我不要廣告),所以我去Joomla的非官方中文網站TaiwanJoomla去下載1.0.13_full language版本(含中文版),然後利用byethost所提供的FTP Server來Upload joomla的package,上傳的速度有點慢,可能主機是在國外吧!對了,Joomla-1.5RC3版本,上傳之後無法出現安裝畫面,我們也無法去修改apache及php的設定,所以我是選1.0.13的版本來安裝就好了。
上傳的方式除了用ftp軟體之外,也可以使用主控台裏的FileManager
FTP Accounts
FTP Overview
File Manager
來上傳檔案(如果是壓縮檔也可以,有直接幫你解壓縮的上傳機制,可以省不少時間)。
上傳的時間真的有點久,所以趁這個時候去試試其他的功能吧!尤其是到
Manage MySQL
MySQL Overview
MySQL Manager
PHP MyAdmin
MySQL Manager 裡去新增一個資料庫給joomla使用(等一下要用到),像我是開一個名稱為joomla1013的資料庫準備給joomla使用!
............
.......
...
終於傳好了,連上去試試看吧!
在網址列打上你的http://domain/上傳時joomla資料夾名稱/
第一次安裝會直接導到http://domain/上傳時joomla資料夾名稱/installation/index.php
我的網址就是http://acmevil.byethost13.com/joomla1013/installation/index.php

進入joomla的安裝畫面
在這裡我遇到了一個情況:


第一: Session save path Unwriteable
/tmp

第二: Display Errors: ON: OFF

這兩個問題我試過許多方法,也請教Google大神,可是都沒有人可以讓我在一開始就讓/tmp顯示writeable,所以就先不理,先給按左上方的再說吧!
接著是License,要看也可以啦!下去。
再來就是database的設定了!


這裡的Host Name不是LocalHost而是MySQL Manager裡的Host Name,在Manager那一頁最下方會顯示:
MySQL Host Name sql3.byethost13.com
MySQL User Name
xxxxxxxxxxxxxxx(自動隱藏)
MySQL Password
(Same as your FTP & VistaPanel password)
MySQL DB Name
(See above: You need to make a database)

sql3.byethost13.com就是Host Name,DataBase Name要注意,不是你在Create打的名字,真正產生的會是加了Username的名字,MySQL Manager頁面會顯示,其他的照自己的設定填入即可。
接下來設定Site Name。
Step3設定網址跟E-mail及管理者密碼。
最後,把joomla的安裝資料夾(installation)給刪除或改成其他名稱即可(改名稱不成,就刪掉吧!)
ViewSite或Administrator

這樣大致上就安裝完成了,至於Joomla怎麼玩,可以參閱Joomla的官方網站Joomla! 或是非官方的中文正體網站TaiwanJoomla的教學手冊。

問題發現與處理:
1、 安裝時Session save path /tmp unwritable的問題。
A:一開始我們是採取冷處理,先不理它,在安裝之後似乎也沒有出現錯誤訊息(我是沒有),不過為了預防萬一,還是得修改一個地方讓Session save有個棲所;我先用File Manager在joomla1013的安裝資料夾裡建一個空的資料夾,叫做tmp,然後修改其屬性為777,之後編輯在joomla1013的資料夾裏 的configuration.php這個檔案,加入一行
ini_set(‘session.save_path‘,"/home/vol1/byethost13.com/使用者帳號/次網域名稱.byethost13.com/htdocs/joomla1013/tmp");

有些部分需因個人的不同稍作修改,這樣就OK了!

2、我曾遇到在剛安裝完成時,選擇ViewStie或是Administrator之後,會出現可能兩種不同的錯誤訊息,像是Class 'JCache_Lite_Function' not found in .......(略) 或是 Class 'Cache_Lite_Function' not found in ......(略) 。
A:這兩個錯誤訊息,我發現是因為在上傳檔案時,某些檔案傳輸不正確,譬如我joomla1013/includes/joomla.cache.php 這個檔案傳可能在上傳時出了問題,造成檔案大小只有0KB,但事實上它是2.46KB,重新上傳之後同常可以解決(結果我把整個網站上傳了一次就OK了 = =!!!)。

3、在操作Joomla後台時,一開始發現FireFox上不能夠"確認"選項,但是用IE 7卻可以;不過再裝一次時這個問題就沒有發生了。

玩玩免費虛擬主機--ByetHost Free Web Hosting

忘記怎麼發現這個網站了,反正看起來免費的,就給他玩看看。

這個免費空間支援的PHP、MySQL、Apache的,查了一下他的版本
PHP-5.2.4
MySQL-5.0.45
Apache-2.X

echo phpinfo();出來就是-->按我

免費的account支援不是無限的如下圖

申請的步驟也很簡單
他的-->首頁
廣告一堆,要繞幾圈才找得到註冊的地方!
要直接註冊就按-->

註冊表就像下面這樣,要注意的是Username會成為Hostname,也就是次網域名稱

註冊完會寄給你一封信,裡面會有帳號密碼的訊息,帳號並不是註冊時使用的Username

裡面有個Cpanel URL,就是後端主控台的URL,用Cpanel Username及Cpanel Password來登入。

主控台長的像這樣


至此,應該都OK了,接下來要做什麼呢?

當然是架個站來玩玩囉!


選上面這個選項的Automatic Installer,進去後會看到下面的

Select the destination domain for the installaton:





選好你的domain之後就給它Proceed下去啦!
裡面有很多的Packages,喜歡哪一個就按它右邊的
Click Here »就對了。
再把你的網站取個資料夾名稱就好了。

Go! Go! Go!

P.S:如果是以它內建的Packages去架設網站,那麼那個網站通常會被放上Byethost的廣告,如果是自己上傳的則不會有!

電子郵件轉移 ( Email Migration ) on Google Apps

轉移學校所有教職員的信件之前,我在想如何能夠順利轉移,因為移轉需要原Mail Server上所有老師的帳號密碼,有考慮兩種思考:第一種方式:轉移必須知道所有人員的帳號跟密碼,要一一取得所有老師的密碼是件很困難又根本不會達成 的事,而Linux的shadow裡的密碼都是加密過的,用破解的是非常不道德且不允許的,只能用問的,但老師又不見得會告訴你;第二種是在原來的 Mail Server上把所有Mail User的密碼重設,等轉移過後,請使用者們自己在第一次登入時修改密碼。想當然爾,選擇第二種是簡單又迅速的的方法。
經資訊小組討論過後,決定找一個時間移轉,事前當然需要先公告Mail Server要移轉的緣由跟時間,給User準備跟期待。
移轉的步驟:

1、在原本的Mail Server主機上重設所有User的密碼。(我是在Webmin上把所有的User的帳號移出來,用Excel編輯成需求的格式,像這樣

A B C
1 username source username source password
2 picasso picasso 12345
3 claude.monet claude.monet 12345
4 lilies lilies 12345
)

2、匯回修改後的CSV檔,批次修改所有User的資料。

3、到Google Apps的電子郵件移轉(Email Migration)設定:此次轉移任務的名稱(不拘). (2)伺服器軟體、主機位置(IP或host.domain都可以)、安全性(看原本的Mail Server是不是採用SSL或STARTTLS模式,如果都沒有則選"無"). (3)通訊埠(安全性選"無"及"STARTTLS"為143,選"SSL"為993,不過要看原Mail Server所採用的協定). (4)IMAP路徑前置字串(Linux上通常為/var/spool/mail或是/var/mail/)

目前電子郵件轉移(Email Migration)所支援的伺服器軟體

設定完之後,按"繼續"
接著是要選擇移轉使用者帳戶的方式:一些或是大量

決定之後就選擇"繼續"。(我當然是選大量的囉!有幾百人呢!)
接下來就把之前做的CSV檔給傳上去,按個"上載並測試連線"

如果成功了,就會顯示所找到的信件匣(通常叫做Inbox)。

最後就可以開始快樂的轉移(Migration)了。

後記:
本來預估半天就可以搞定,但是一直顯示連線失敗,看了Google Apps所提供的錯誤訊息文件也 沒辦法解決,最後打算用最簡單的方式:"砍掉重練"。我把Mail Server(Postfix)相關套件移除(反正移轉後也要移除了),包含MailScanner、Spamassassin、Sasl2、F- prot、Devocet等等移除,只裝SendMail跟Devocet,結果居然伺服器驗證失敗,是帳號驗證失敗,不是伺服器連線測試失敗。後來才發 現我在耍笨,是我在重設老師的密碼,在批次modify時,少了一個欄位(原本webmin匯出的格是一個帳號是13個欄位,要modify時要增加一 個"被修改的帳號"的欄位),難怪伺服器OK,帳號驗證不OK;修正之後就一切正常了,也順利轉移,不過也搞到當天晚上十一點多才睡覺。@@!!!

終於把Mail Serivce丟給Google Apps了^^Y

幾個星期來,經過反覆的測試、宣導及半強迫,終於把學校的Mail Service丟給Google Apps了,這樣一來,伺服器的工作就少了一個負擔了。
之前遲遲不換到Google Apps的原因是因為學校本身的Mail Server上有老師留下來的信件,如果貿然換郵件系統而要求老師自行備份郵件的話,必定會招致許多的抨擊及抱怨,所以一直沒有轉換。直到近來Google Apps在教育版(Education Edition)上公告一項新的功能,寫著"
最新! 電子郵件移轉 - 將您現有的電子郵件封存檔移轉至「Google 應用服務」 - 開始使用(
New! Email Migration - Move your existing email archives into Google Apps - Get started)。一開始還不懂是什麼意思,抱著好奇的心態去測試這個功能,拿著自己的帳號來測試什麼叫做"Migration",結果,居然成功了!這一刻,有一種心中大石放下一塊的感覺,很想大聲的叫:"我終於要擺脫Mail Server的禁錮了!哈!哈!哈!",我分析,如果完全把所有教職員的Mail轉移到Google Apps的話有幾個優點也有缺點:
優點:
1、主機房可以騰出一台Server來做別的Service,譬如Web Server或是Samba Server或是NFS、Backup Server、Update Server等等。
2、Gmail優越的防堵垃圾信件及防毒機制(至少比我自己架設的Mail Server好很多)會避免校內使用OutLook收信或其他使用POP3收信的應用軟體在收取信件時容易中毒的情形,甚至蔓延到全校的區域網路當中;之前因為病毒郵件造成的PC中毒已經太多樁了,甚至教師用的PC被植入木馬程式而不自知。
3、郵件信箱的容量由原本的(自己架的)100MB提升為2GB。
4、其他功能:譬如Chat、Calender、Docs、Web Pages、Star Page等等。
缺點:
1、自己的技術不會進步,哈!

Mail Server 移機--後記

Mail Server in the machine after a shift and start to test ok, but over the past few days has occurred several problems. DNS aspects aside for the moment and the local server has some problems.

First : When sign openwebmail and it displayed "can not read lock /var/spool/mail/user! " or " Unknown error at user write lock error ) : " After an investigation and discovered that the original mail owner was lost, mail owner became root. I do not know all of accounts the passwords and were unable to test how many lost, so change one by one. However, my good friend Pcpark provide a batch file to modify quickly and saved a lot of time. Create a text file that contains all the mail users account and create a batch file to execute. For example :

#vi chownuser

may

john

apple

joe

mary

arthur

stacy

lee

jack

Save it.

#vi chownuser.sh

#!/bin/sh

for name in `cat chownuser`
do
chown $name.mail $name
done

Save it.

These two files on the mail directory and then execute.

#sh chownuser.sh

This will help you change all of mail owners! ^ ^

2nd : Some people sign will be displayed at the bottom bunch .

Software error:

Undefined subroutine &ow::htmltext::str2html called at /var/www/cgi-bin/openwebmail/shares/ow-shared.pl line 1283.

For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.

The problem is user's home directory mistakes, as long as back into their original position.

Third : This is a big problem, the PC is not to be mail server originally. So the partition for /var in the first place is not allocated greater capacity, so the mail will fill /var partition. Don't re-install........ Finally I think solution in the bath:

#cd /var/spool/

#mkdir /home/mail

#mv /var/spool/mail/* /home/mail

#chown root.mail /home/mail

#mv mail mail_old

#ln -s /home/maol /var/spool/mail

As a result, all letters moved to /home/mail underground. If there is the question of mail owner occurred, you want to change mail owner again.

#cd /home/mail

#sh chownuser.sh

Done!^^


Mail Server在移機之後一開始試OK的,可是過幾天卻遇到許多的問題,DNS方面暫且不談,本機就有一些問題了。

第一:登入openwebmail時顯示"讀取無法鎖定 /var/spool/mail/user!

"或是"Unknown error at user write lock error):"經查證之後才發現,原來有些mail的權限已經跑掉了,擁有者變成root而不昰user本身,因我無所有user的帳號密碼,不能一一 測試到底有哪些權限跑掉了,於是就一個一個改權限。不過,我的好朋友pcpark提供一個batch改權限的方式,讓我省了不少時間:

先做一個文字檔,裡頭包含所有mail使用者的帳號,再寫一個sh檔來batch。範例如下:

#vi chownuser

may

john

apple

joe

mary

arthur

stacy

lee

jack

存檔.

#vi chownuser.sh

#!/bin/sh

for name in `cat chownuser`
do
chown $name.mail $name
done

存檔.

這兩個檔案一同放在mail目錄裡,然後執行。

#sh chownuser.sh

這樣就會幫你全部改好mail的擁有者了!^^

第二:有人登入時會顯示下面這一串

Software error:

Undefined subroutine &ow::htmltext::str2html called at /var/www/cgi-bin/openwebmail/shares/ow-shared.pl line 1283.

For help, please send mail to the webmaster (root@localhost), giving this error message and the time and date of the error.

這個問題昰user的家目錄位置錯誤了,只要放回原來的位置就可以了,哈!

第三:這是一個大問題,原本此PC不是要用來當作mail server的,所以當初在partition時倂沒有給/var很大的容量,所以移過來的/var/mail一下子就會把該partition塞爆,不想重灌.......。終於在洗澡時想到解決的方式:

把/var/spool/mail裡的信件移到/home底下去

#cd /var/spool/

#mkdir /home/mail

#mv /var/spool/mail/* /home/mail

#chown root.mail /home/mail

#mv mail mail_old

#ln -s /home/maol /var/spool/mail

這樣一來,信件就全部轉移到/home/mail底下了。

如果還有發生權限的問題,就再去修改各個權限。

#cd /home/mail

#sh chownuser.sh

完畢!^^

Mail Server 移機完畢

Because of the recent mail server was hacked and I also FreeBSD wake unable to make the best management, therefore take this opportunity to move Mail Server to Fedora Core 6. Previously prepared to put the work in advance is create all of the user accounts of FreeBSD in FC6. But no one should create account one by one! After all, the units have nearly 200 people Account. Therefore, due to this Webmin installed a suite, so we can export substantial account:

Login the FreeBSD system which own webmin service --->System---> Users and Groups --->Export users to select batch file--->Select the users and their options --->Export NOW

Login Fedora Core 6's webmin--->System --->Users and Groups--->Create, modify and delete users from batch file --->Browse you file---> select the set options --->Execute batch

Waitting implementation of the batch file .... . Done! ^ ^

This preparatory work is finish! Finish a "major event"!

Next, should the FreeBSD mail and mail folders of user home directory (because it was installed the openwebmail) transfer to FC6 (I use is that I want, is probably the most stupid way. .)

In FreeBSD :

#cd var * FreeBSD because my mail is under the /var

#tar zcvf mail.tar.gz mail/

*Entire mail folder compressed into one of tarball

# mv mail.tar.gz /var/www/html/ *moved to the web underground

# cd / * under /

#tar zcvf home.tar.gz home/ *all user home folders under /home

#mv home.tar.gz /var/www/html/ *moved to the web underground

Fedora Core 6 :

#cd /

#wget http : //freebsd.domain/home.tar.gz

*Catch FreeBSD's home directory file backup

#tar zxvf home.tar.gz

*decompress home.ta r.gz. This will directly cover the original home
directory file name all the same file or folder

#rm -rf home.tar. gz * Remove have already decompress off tarball

#cd /var/spool *to mail stored in the folder on the floor

#wget http://freebsd.domain/mail.tar.gz *FreeBSD's mail backup file.

#tar zxvf mail.tar.gz *decompress mail backup file

#rm -rf mail.tar.gz *delete the mail.tar.gz has been used.

Don't forget to back to FreeBSD to delete the files that are homr.tar.gz and mail.tar.gz under the website root directory! Otherwise, people can download arbitrary your backup file is, of course, your web servers are the starting. Now almost completed. YA!



最近因為Mail Server常被入侵,而且FreeBSD我也不熟,無法作最好的管理,於是趁此機會要將Mail Server移到Fedora Core 6上。

先前要準備的工作事先把FreeBSD上的使用者帳號在FC6上在重建一次,但應該沒有人會一個一個來重建吧!畢竟我們的單位也有將近兩百人的帳號。於是,因本身有安裝Webmin此一套件,所以我們可以把帳號大量匯出:

登入 FreeBSD的webmin--->系統--->使用者與群組--->Export users to batch file--->選好要匯出的使用者及其選項--->Export NOW

登入 Fedora Core 6的webmin--->系統--->使用者與群組--->使用批次檔一次過建立/修改/刪除使用者--->Browse你會出的檔案--->--->選好要設定的選項--->執行批次檔

Waitting.....Done! ^^

這樣先前的準備工作就做完了!做完一件”大事”了!

接下來要把FreeBSD上的mail及家目錄裡的mail資料夾(因為有裝openwenmail)轉移到FC6上(我用的是我想得到的方法,可能是最笨的方法。@.@)

在FreeBSD端

#cd /var *因我的bsd的mail是放在/var/mail底下

#tar zcvf mail.tar.gz mail/ *把整個mail資料夾壓縮成一個tar.gz的壓縮檔

# mv mail.tar.gz /var/www/html/ *移到網頁目錄底下

# cd / *到 / 底下

#tar zcvf home.tar.gz home/ *所有人的家目錄在home底下

#mv home.tar.gz /var/www/html/ *一樣移到網頁目錄底下

Fedora Core 6上

#cd /

#wget http://freebsd.domain/home.tar.gz

*把FreeBSD上所有人的家目錄備份檔抓過來

#tar zxvf home.tar.gz

*解開home.tar.gz,此會直接覆蓋原來家目錄裡所有檔名相同的檔案或資料夾

#rm -rf home.tar.gz *刪除已經解開過的壓縮檔(不解開就是暫空間而已)

#cd /var/spool *到FC6上存放mail的資料夾的上一層

#wget http://freebsd.domain/mail.tar.gz

*把FreeBSD上的mail備份檔抓過來
#tar zxvf mail.tar.gz *解開mail備份檔

#rm -rf mail.tar.gz *刪除已經用過的mail備份檔

記得回到FreeBSD上把網頁根目錄下的home.tar.g及mail.tar.gz都刪掉喔!不然別人是可以任意下載您的備份檔的,當然是您的網頁伺服器有開的情況下。

至此差不多就完成了!。

2007年5月9號 丁亥年三月二十三日 晴(熱啊!)

1.與韻潔及保全公司人員抽測校園單槍包全設備是否正常。--->非常正常@@

2.設定172.16.14.21的DNS及Firewall和NAT,我要從外部測試未來的Mail Server。

Postfix+Cyrus-sasl(saslauthd)+F-prot+MailScanner+Spamassassin

在Fedora Core6上重裝Mail Server

參考文章:http://ftp.tn.edu.tw/Study/student_server/mail2.htm

基本上我都是照著這個網頁上的步驟做的,不過也遇到了幾個問題。文章我就不引用了,只列出我遇到的問題:

Q1:saslauthd認證失敗:

#/usr/sbin/testsaslauthd -u username -p 'password'

0: NO "authentication failed"

A1:本來是以為cyrus-sasl少裝了什麼套件,因為cyrus-sasl一共有九種套件(cyrus-sasl-devel、cyrus- sasl-lib、cyrus-sasl、cyrus-sasl-sql、cyrus-sasl-plain、cyrus-sasl-ntlm、 cyrus-sasl-ldap、cyrus-sasl-md5、cyrus-sasl-gssapi)。找不出原因之下,查了以前裝的mail server有哪些套件,才發現我是imap沒裝,於是我裝了uw-imap-utils-2006guw-imap-2006g就OK了。 真是=.=!!!

Q2:F-prot更新時(check-updates)失敗了,顯示:

Error: Unable to include perl module: 'HTTP::Request'.
Please install this module and try re-running this script.
(Hint: man CPAN)

Fatal error. Exiting...

A2:這個問題是HTTP::Request模組沒有安裝,只要安裝perl-libwww-perl這個相關版本的套件即可。

Q3:在maillog裡出現

fatal: open database /etc/postfix/access.db: No such file or directory

A3:這是沒有access.db檔,只要下

#postmap hash:/etc/postfix/access

即可!

user warning: Table './xxxxx/watchdog' is marked as crashed and should be repaired.....

End Drupal upgrade to 5.1.X version of the time, after a time log management interface that would arise this warning message :

user warning: Table './xxxxx/watchdog' is marked as crashed and should be repaired query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (1, 'user', '.......

That's a message make me a bit confused? I do not have revised the Drupal table, how would mistake? But this is easy to deal. To truncate table "watchdog" and the message will not be there, But I don't know that it will not happen again ?


剛升級完Drupal到5.1.X版的時候,過一陣子登入管理介面時會出現此警告訊息:

user warning: Table './xxxxx/watchdog' is marked as crashed and should be repaired query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (1, 'user', '.......

這一個訊息的出現我有點納悶?我又沒去修改過資料表,怎麼會有錯誤呢?

不過這個好解決,只要到資料庫去清空watchdog這個資料表就不會出現了,不過以後不知道會不會再出現就是了?

搬移主機:二合一

原來的兩台主機的OS都是Fedora Core 6,所以要合併並不困難。我最單是把其中一台的硬碟拔起來換到新的主機上就可以了,雖然其他硬體並不相同,但是開機之後會重新catch周邊的硬體設備,真是方便!

在移植另外一台的資料時,遇到的問題也不是很大,只要把網頁資料備份都掉另外一台就可以了;資料庫的部份也是備份出來再倒回去新的主機上,設一下權限就搞 定了。但是在移植LifeType這個Blog系統時卻發現,資料庫匯入時會出現錯誤訊息。這個問題困擾了我兩天。後來才發現是資料庫編碼的問題:備份出 來的資料是Big5的格式,一般的MySQL預設都是UTF-8的格式,所以匯入時會出現無法解晰的亂碼,以致匯入不能成功,或者是網頁畫面變成空白。最 後的解決方式是找出舊版的(支援Big5)版本,安裝再升級到最新版的,然後再把資料匯入即可!

於是就完成了二合一的動作了,也可以把電腦還給英語老師了!耶!