Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(): Failed opening '/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24
主機二三事 – 第 4 頁 – unethost無限空間虛擬主機 技術分享部落格

如何安裝trellis help desk

(1) 下載 http://www.accord5.com/trellis/download
選擇 version 1.0.4

(2) 解壓縮之後,會有一個upload資料夾。
把這個upload資料夾的內容,上傳到public_html下

(3) 開啟 http://your-domain-name/install/
Introduction -> 點 Let’s begin
System Check -> 點 Continue
Installation Type -> 點 Continue with Guided

(4) Database Setup
填入必要的資料庫資訊,這個用cpanel來新增

(5) Create Admin Account
填入用戶名/密碼/Email 為…
TimeZone選GMT +8:00
DST Active 選 No ( 不啟用日光節約時間 )
其它不修改

(6) Configure General Settings
設定 Outgoing Email 為 support@your-domain-name

(7) Write Skin Files
按continue即可

(8) Finish Installation
按Complete installation

(9) 基於安全考慮,刪除install這個資料夾。

(10) 設定Email piping
參考
http://docs.accord5.com/Email_Piping
(a) 先設定好需要的email, 以這個case 是support@your-domain-name
(b) 在cpanel點Email Forwarders
點Add Forwarder
(c) Address的地方,填入 support
Destination地方,選 Pipe to a Program
然後填入 public_html/help/sources/pipe.php
(d) 點 Add Forwarder按鈕
// 如此設定之後,寄送到 support@your-domain-name的email會被送到helpdesk去處理。

(11) 設定語言
在 public_html/help/language/ 下,可以找到一個en,這就是它的英文的語言檔。
要翻譯的話,就是把這個檔中文化即可。

(12) 其它說明文件
http://docs.accord5.com/Main_Page

如何安裝drupal 6及中文化

(1) 下載drupal的安裝程式,解壓縮後,ftp上傳至public_html目錄下

(2) 下載中文檔http://drupaltaiwan.org/forum/20080504/2060

選 drupal-6.2-zh-hant-package.zip
下載後,把它解壓縮。可以得到三個資料夾
modules
profiles
themes
把這三個資料夾,上傳到public_html這個資料夾下。

(3) 開啟網頁,開始安裝, 就先英文安裝吧。

(4) 這時候,畫面會冒一些錯誤訊息。
只要在 public_html/sites/default/ 這個資料夾下,
複製 default.settings.php 為 settings.php

錯誤訊息按F5就會消失。

(5) 填入資料庫的訊息。
資料庫可以透過cpanel的功能來新增
然後,save and continue

(6) 最後會要你填入email,及admin的資料。
Default time zone 選 +0800
Clean URLs 選enabled
update notifications 要打勾

(7) 安裝完畢後,先來啟動中文化。
Administer > site configuration > languages 之後,
點選 Add language

然後,Language name:選 「Chinese 繁體中文」
按下 add language之後,就會啟動import

(8) 在 Administer > site configuration > languages
點選中文,為default ,並且save configuration

mysql忘記root password

遇到這種不幸的情況,最簡單的方式,當然是使用WHM的功能,就可以簡單地重新設定。

然而,有時候,因為成本的因素,我們把cpanel/WHM的成本省下來的時候,就得用比較複雜的技巧來處理這個問題:

1  service mysql stop

2 修改 /etc/init.d/mysql
找到 mysqld_safe 這一行,加上 –skip-grant-tables

3 service mysql start

4  現在可以不用密碼登入了。
mysql  -u root
use mysql;
update user set password=password(‘yournewpasswordhere’) where user=’root’;
flush privileges;
exit;

5 service mysql restart

用Madmimi來發電子報

之前就有聽人介紹Madmimi的EDM服務,最近公司也來用一下吧。想收到電子報的請按這邊註冊。

本來以為一切會順利無比,想不到,到了電子報要發出去的前一刻,才收到Madmimi官方的關切信函。一開始的信函內容是這樣子的:

Hi Laurence,

Macdara here 🙂 I see you’re ready to send your promotion off, sweet!

I just need a little info before I can get you verified. Let me know how your contacts signed up and agreed to hear from you when you get the chance. This way we can be sure to get you overall awesome sending!

Cheers,

Macdara

非常客氣地問我,我發電子報的連絡人是從哪裡來的? 於是我回信,這是從官網的whmcs系統中匯出的。想不到,Madmimi的官方還是不讓我過關,又來了一封信問得更詳細了:

Hi Laurence,
Thanks for getting back to us! I’m happy to get you sending shortly. Will you let me know how you gathered the contacts you didn’t collect from http://unethost.com/whmcs? It’s important that all the contacts you’re sending to gave you their permission to send to them.

Also, did the registration or opt-in process on the Unethost.com site specify these contacts were agreeing to hear from you via email?

I’m not trying to give you a hard time – we ask these questions of all our users to make sure you’ll inbox successfully 🙂

Best,

Kate

像這樣子這麼嚴格的問法,實在讓人心生放棄的念頭。在上頭的信函裡,Madmimi問我,「這些註冊的email,他們有沒有同意我寫信給他們?」 還問我,「在註冊的過程中,有沒有問人家,我可以寄信給你嗎?」

像我這麼含蓄內向的人,我怎麼好意思沒事亂發email給人家呢!所以我最後回信給對方的理由,我就寫得理直氣壯,大意是說『雖然我沒有問過可否發信的事,但是全部都是我的客戶』,  順便附上我從官網匯出的連絡名單原始檔。

I create two list: One name is whmcs, the other is firend. Just as the name
goes, one contact list is from whmcs system, and the other contact consists of my firends. As for the friend contact, I am sure that I have asked them. The registration process on Unethost.com does not ask this kind of email question. This is limited
by software system.

However, I am sure that my clients they permit my sending email to them.
WHMCS is a helpdesk system. If my client has problems, he will submit tickets
to my help desk system. At the meanwhile of submitting ticket, he will receive
his ticket from email too. Therefore, he can then just send and receive
tickets by email. If you take a look of my website, all the articles in
knowledge base, and files in download area, we do not require client login.
Given that anyone can get most of the free resources from our website, why
they choose to login? I believe the answer is obvious, because they are my
clients.

I provide objective information for you to justify my saying. The attachment
is the original file that I exported from WHMCS system.

最後,Madmimi官方回給我的信,還是讓我滿感動的 –> 他們終於相信我不是在亂發垃圾信了!

I really appreciate the detail. Thanks for taking the time to explain it so
well 🙂

It’s all I needed to hear, so I’ve verified your account and have sent your
email on its way now.

淺談hash dos攻擊

身為一個主機商,處理過的攻擊中,最容易得手的攻擊,往往是DoS攻擊。DoS又名denial of service ,這種攻擊的概念不強調去更改網站的內容或是偷取資料,只是讓網站倒站。相對於SQL injection, XSS這一類的攻擊,需要依賴寫程式的不小心。DoS單純又暴力,但是從攻擊者的觀點來說,非常的有效。

以php這種語言為例子,在寫程式的時候,可以利用$_POST[“name”]從用戶端的Post request中存取name這個變數。像這樣子的機制,就是php語言實作的hash tables(哈希表)所提供的。然而hash tables固有的特性之一,就是會有衝突的時候,即Hash Collision。攻擊者可以利用Hash Collision會消耗大量的CPU運算這個特性,發動hash DoS攻擊。

這個攻擊的發動方式是這樣子:攻擊者給予php網頁一個Post request,並且在這個單一的request之中,提交大量的參數,而且這些參數透過php的hash規則都恰好會發生hash collision。這樣子的攻擊方式,在2003年在許多語言(Perl, CRuby)中被發現。

目前,許多語言在其更新的版本中,已經有針對這一點去改善了。以php為例子,從 php的5.3.9版本開始,有一個指令 max_input_var,它可以去限制GET,POST,Cookie這些變數的長度,最長只能到1000。有了這個特性,要hash dos就不太容易了。

對於不幸使用舊版php的人,也可以考慮使用ModSecurity的規則來攔阻這種攻擊。例如下方的rule,就是類似max_input_vars的效果。

SecRule &ARGS|&REQUEST_COOKIES_NAMES|&REQUEST_COOKIES "@gt 1000" "phase:2, \t:none,log,block,severity:2,msg:'Hash DoS Detected'"

php handler — suphp, mod_php, cgi, fastcgi

在虛擬主機的控制台中,效能和安全性都關系重大的一件事,就是php handler的選擇。可以說是每一種handler都各有其特色。

(1) CGI是最古老的handler,因為最古老,也沒有什麼過人的長處。不快也不太安全。
(2) suphp是最慢的handler,但是它在安全性上其長處。如果使用者的檔案或是資料夾的權限設定太過寬鬆,suphp都會丟出error。可以說是超級嚴謹,一絲不苟。
(3) mod_php是最快的handler,因為它直接嵌入apache中,做為apache的module來執行。也因此,mod_php在執行網頁時,使用的是nobody這個user,而並非是php檔案的擁有者。所以mod_php並不太安全。
(4) fastcgi可以說是有各家之所長,速度上不輸給mod_php,又像suphp一樣,可以用php檔案擁有者的身分來執行。唯一的缺點就是fastcgi的設定也比較複雜。

下方是一個圖表,用來說明這四種php handler的特色。

php handler 比較表

Unethost.com 採用的php handler是fastcgi。因為用了fastcgi的關系,客戶們並不需要將自己的程式中,被php寫入資料的資料夾設定成權限777。客戶們在public_html下的網站檔案,也不會被改成擁有者為nobody。

本來以為用了fastcgi這個php handler既有速度又有安全性。然而,真正的考驗是在當我們讓fastcgi上線之後一個月,機器開始瘋狂地當機。經過一番折騰後,才發現,原來php fastcgi內部有輕微的bug。這個bug會造成orphan process,也就是一些php的process,他們的PPID都會變成1。當這樣子的程序愈來愈多時,就會使用大量的記憶体,最後吃光主機的swap,導致當機。 一旦找出問題的根源後,要處理也就不難了。在我們加入了會自動去砍掉php orphan process的cron jobs,php fastcgi就平平順順地運作,再也沒有出過惱人的問題了。

 

延伸閱讀: 如何透過排程,解決fastcgi崩潰問題?

 

(本篇教學由unethost.com客服撰寫)

延伸閱讀:如何備份Cpanel後台安裝的套裝程式?

安裝上述的軟體,我們提供虛擬主機試用,七天滿意保證,
功能完整使用不受限制,歡迎點我申請。

webftp

虛擬主機因為是多人共用一台實體主機,當主機遭受DDoS攻擊,或是剛好執行一些備分的工作時,機器的負載總是難免會偶爾有上昇的時候。當機器的負載上昇時,除了網頁伺服器的反映速度會變慢一些之外,有時候比較嚴重的問題是,ftp會不停地斷線。

在一次偶然的情形下,我用filezilla會不停地斷線時,用webftp卻可以順利地上傳檔案!

這樣的一件事,讓我不由得開始重新檢視webftp和ftp不同之處。unethost.com的webftp是安裝在美國的主機上的。當使用者使用webftp時,其實檔案的傳輸是先從客戶端,走http的傳輸協定到webftp所在的機器,再透過ftp傳輸協定到真實的目標機器上。所以是兩階段式的。前面這一段往往是最容易逾時(timeout),最容易有掉封包(packet loss)的。原因是前面的這一段是從台灣連線到美國,所以延遲(delay)會比較長。考慮到前面這一段的傳輸有這種特性之後,就不難理解,為何webftp在這種條件下可以有較佳的表現了。http這個傳輸協定由於有較多的超文件標記(meta tag)本身對於這種延遲長、容易掉封包的連線,本來就有較佳的表現。而webftp很巧妙地剛好可以利用http這個傳輸協定來處理前一段的連線,所以就可以在filezilla動彈不得的時候,依然順利地達成上傳檔案的任務。

利用VPN及Host Access Control來避免scan password攻擊

VPS客戶和獨立主機客戶最頭痛的問題之一,莫過於admin的帳號/密碼外流了。舉個例子,如果ssh port設成22,那主機必定不停地回報被大量地敲門–因為網路上總是不停地有大量的攻擊者試圖透過暴力法來猜測ssh的密碼。同樣的原理,由於cpanel登入的port是2083或是2087,這兩個port也是會不停地被攻擊者試探。

有沒有什麼比較簡單的方法可以解決這個被攻擊者試探的問題呢?畢竟,並不是每一種服務的port都可以輕易地修改的。

單純又暴力的解法,就是設定白名單(white list),限定只有從某些特定IP address來的連線,才會被接受。這個功能要透過cpanel的Home >> Security Center >> Host Access Control 來設定。下圖的範例是設定一台主機的sshd服務,只容許由140.112.18.71這個IP address來登入,即設定sshd 的白名單。

Cpanel Host Access Control

然而,這樣子的設定,有一個難題,以台灣的用戶,很多人是沒有固定IP的,此外,一旦用筆電在外頭上網時,就是使用動態IP了。這種時候,如果搭配 VPN使用,就可以輕易地在任何時間/地點取得固定的同一IP Address。如此一來,只要把Host Access Control中容許的IP address設定成為VPN的IP address即可。

如何在centOS上,透過yum安裝基本的web server

有的客戶因為要跑相對比較吃硬碟I/O數的遊戲,喜歡不裝cpanel。但是不裝cpanel的話,剛拿到的centOS是連完整的web server環境都沒有的。本文就是來講解,如何在一台乾淨的centOS上,透過yum安裝基本的web server

(*) 安裝web server
1 for php
yum install php

2 for ioncube loader ( ioncube loader是一個跟加密的php source code有關的模組,不灌這個的話,如果要執行的插件是有加密的php source code,就跑不動了。)
wget -q -O – http://www.atomicorp.com/installers/atomic |sh
yum install php-ioncube-loader

3 for mysql
yum install mysql mysql-server php-mysql
chkconfig –levels 235 mysqld on
/etc/init.d/mysqld start
修改mysql的 password
/usr/bin/mysqladmin -u root password ‘你要設定給mysql root的密碼

4 for httpd
yum install httpd
service httpd restart

如何透過shell script來做domain name的篩選

如果從cpanel WHM抓出所有主機的域名(domain name)時,往往會發現,子域名(sub domain) 和頂層域名(top level domain) 是混雜的。

這時候,可以用基本的sed來做篩選。做法如下:
在一個文字檔 list 裡放所有的域名,例如:

aa.bb.com
cc.net
1123.org
1aa.bbcd.com

下指令:
cat list | sed -e “/[^\.]*\.[^\.]*\.[^\.]*/d” | sort

即可抓出所有想要的top level domain。( 這個指令的功能就是把所有的sub domain刪去而已。)