Archive for the 'Computer' Category

wordpress-mu sitemap plugin

抓取「Google Sitemap Generator 3 Beta」丟到 plugin 目錄,然後作些 dirty hack:
<blockquote>
<pre style=”text-align: left”>— /home/admin/cookys/work/sitemap.php Thu Nov 16 22:26:58 2006
— /home/admin/cookys/work/sitemap.php Thu Nov 16 22:26:58 2006
+++ sitemap.php Wed Dec 6 20:37:50 2006
@@ -865,6 +865,7 @@

//the get_home_path function in our own...
$home = get_settings('home');
$home_path="";
+/*
if ( $home != '' &amp;&amp; $home != get_settings('siteurl') ) {
$home_path = parse_url($home);
$home_path = $home_path['path'];
@@ -873,8 +874,10 @@
} else {
$home_path = ABSPATH;
}
+*/
$res = $home_path;
}
+               $res =ABSPATH.UPLOADS; //str_replace('/files','',ABSPATH.UPLOADS); // cookys dirty hack for wp-mu
return $res;
}

@@ -1313,7 +1316,7 @@
if(!$forceAuto &amp;&amp; $this->GetOption("b_location_mode")=="manual") {
return $this->GetOption("b_fileurl_manual");
} else {
-                       return trailingslashit(get_bloginfo('siteurl')). $this->GetOption("b_filename");
+                       return trailingslashit(get_bloginfo('siteurl')).'files/'. $this->GetOption("b_filename");
}
}

@@ -2705,4 +2708,4 @@
#endregion
}

-?>
No newline at end of file
+?>

然後把 .htaccess 補上一條
<pre>RewriteRule ^sitemap.xml /wp-content/blogs.php?file=sitemap.xml [L]</pre>
搞定收工。

mu-wordpress 以及 virtual host 的三兩事

上一篇當 中提到剛做完轉換的動作,所以現在想到就會去對那可惡的 css 修修補補(改不好總是很討厭,雖然知道明明就是 ie 的問題)。現在目前遇到的問題跟以前一樣,如果用 ie 開的話,當你的 100% 超過 100% 的時候他並不會自動縮成 100% ,反而是直接繼續加下去(詳細情形可以比較一下用 ie/firefox 去開一下這篇 ,會發現我的 theme 只要解析度比較小的狀況下,ie 會被暴走的圖給撐大,然後把右邊的 sidebar 擠到下面去),色小外說他看到「max-width in Internet Explorer」這篇當中有提到透過 js 去算然後塞 fixed width ,可是我實在很懶惰,不想為了 IE 把事情弄的這麼複雜,以後貼圖的時候注意一下就好了,或是用 lightbox plugin 可能也是一個方法。

在 昨天晚上喀完某篇 42 pages 的 paper 之後就一整個呈現腦死狀態,幾乎完全不能思考,於是早早就去睡,沒想到才睡不到七小時就自然醒過來。本想繼續賴床,卻睡沒十分鐘就又醒了,起來東摸西摸, 沒想到竟然發現並且解決了幾個小問題。現在的 CSS 在 ie 底下應該正常不少了,不過難免還是會有意外,還是推薦大家去用 Firefox,尤其是 Firefox 2.0 RC1 真 的是快到很明顯。另外無意間跳到 screen 正在 tail -f httpd_error.log 的裝,看到不少 redirect error 的問題,才想到其實我可以透過送 301/302 的方式來暫時解決路徑不對的問題,於是去把 blog.cookys.org 的 vhost整個送 302 過來(不用 301 是因為「希望」有一天能夠再改回去)然後寫一行

RedirectMatch 301 ^/wp-content/uploads/(.*) /files/$1

暫 時把路徑作處理,才不會看到一堆叉叉。(不過我現在才發現,wordpress 在文中用上傳方式插入的圖片,竟然是直接寫死的用絕對位址,那只要搬家換名稱就一定一整個爆炸阿!應該要把他給改一下。)然後我又發現,在 httpd_access.log 的檔案中,由於我是直接設定成 wildcard virtualhost ,所以大家的 access log 都會在同一個檔案,那樣根本就看不出來是 access 哪個站阿,這樣要作 awstat 也有困難。還好 google 馬上告訴我們答案,在這邊有提到可以透過 LogFormat 來更動格式,當然 awstat 的設定也要一併修改。於是依樣畫葫蘆一下:

CustomLog /home/websites/iecs.us/wildcard.iecs.us/logs/httpd-access.log vhost_wildcard_combined
LogFormat “%{Host}i %h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” vhost_wildcard_combined

就可以看到了。

意 外發現要報告的 paper 竟然長達 42 pages ,然後意外的發現 paper 描述要解決的問題跟我們一樣但是卻用了老王說他需要的方法。意外早起的早上,意外修好了一寫小蟲,意外的在 heather 的 tutorial hour看到正妹,意外的抓阿漂去上西班牙文,意外的收到牛盃背的電腦同時發現原來他女朋友是西班牙系。充滿意外的生活,其實也挺愜意。

pf + smp + nogaint network stack = ?

剛剛看到大神這篇「升級到 6.1-RELEASE」裡面喊說因為腳踏車鎖(Giant lock)太多,所以就把 root server 衝到 6.1 了,真的是勇敢的長輩 XD。不過我是看到 GIANT LOCK 才想到我忘了說我遇到的狀況,所以才趕快來紀錄一下。

話說我家美人機到了之後總是會亂 panic 及亂七八糟的事情,在這一篇有稍微提到我後來換 ipnat 之後改善很多,不過偶爾還是會從網路上消失。後來大概在五月中的時候, 看到 mailing list 有人疑似有類似的情形,環境也是 smp ,後來過了不久某篇裡面談到:

This is very similar to the UID/GID filtering problem. What appears to
be happening is on the inbound path, we pickup the pfil lock and attempt
to pickup the inp info lock, while on the outbound path, we hold the inp
info lock across ip_output which will try to pickup the pfil lock.

This problem is the result of a layering violation, in reality the
firewall should not be picking up layer 4 related locks. Myself and a
few others have been discussing this problem for quite some time now,
and hopefully it won't be long before we can come up with a solution
that will make everyone happy.

For now, you should be able to set debug.mpsafenet to  0 which will
re-enable Giant in the network stack, in theory preventing the deadlock.

debug.mpsafenet=0

in your loader.conf

Let me know if this helps

 於是乎,測試了一下,把腳踏車鎖關掉,開機會看到:「WARNING: MPSAFE network stack disabled, expect reduced performance.」

Copyright (c) 1992-2006 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD 6.1-STABLE #3: Wed May 17 22:41:10 CST 2006
    cookys@ddbeauty.iecs.us:/usr/obj/usr/src/sys/DDBEAUTY
WARNING: MPSAFE network stack disabled, expect reduced performance.
ACPI APIC Table: <GBT    AWRDACPI>
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Pentium(R) D  CPU 2.66GHz (3340.93-MHz K8-class CPU)
  Origin = "GenuineIntel"  Id = 0xf47  Stepping = 7

 然後「感覺上」pf 好像反應比 ipnat 好,不過可能是錯覺 XD。雖然說腳踏車鎖一次就會綁一大堆,不過在會亂 dead lock 的狀況下也只能先打開撐著,看什麼時候他們解決 XD。至少跑到現在,兩個禮拜多都沒消失了,除了前一個禮拜被學校裝笑為把她 halt 等停電以外 :p

這時候該高呼,"捷安特鎖"我愛你嗎?(我沒有打廣告喔 @_@) 

eaccelerator + php5

剛剛在弄 mediawiki 才發現原來我家的 eaccelerator 根本一直都沒跑阿,花了一些時間看到底問題出在哪裡,發現原來是被擺到了。再安裝厚的提示訊息寫著:

*****************************************************************************

You have installed the eaccelerator package.

Edit %%LOCALBASE%%/etc/php.ini and add:

zend_extension="%%PREFIX%%/lib/php/%%PHP_EXT_DIR%%/eaccelerator.so"

Then create the cache directory:

mkdir /tmp/eaccelerator
chown www /tmp/eaccelerator
chmod 0700 /tmp/eaccelerator

*****************************************************************************

但是實際上如果去 /usr/local/etc/php.ini 設 zend_extension 事實上他會不理你。所以還是得設到 /usr/local/etc/php/extensions.ini 裡面去:

extension=eaccelerator.so 

本來是直接 copy/paste 他的路徑,結果 php -v 下去就又被 ooxx 。所以現在看起來,是真的有跑了:

PHP 5.1.4 (cli) (built: May  9 2006 10:48:26)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with eAccelerator v0.9.5-beta2, Copyright (c) 2004-2006 eAccelerator, by eAccelerator

被 ports 的 hint message 擺道,很無言的阿!

PS. 前幾天  FreeBSD 的 php 好像地震了一下:

20060506:
  AFFECTS: users of PHP
  AUTHOR: ale@FreeBSD.org

  The old PHP slave ports (phpN-cli, phpN-cgi and mod_phpN) were removed
  in favour of unified PHP ports that allow building any combination of
  PHP SAPIs (cli, cgi and apache module).
  The PHP CGI binary was renamed to php-cgi, so you should update
  the path in your script. To simplify the update process, *only* for
  this release a 'php' compatibility symlink to php-cgi will be created
  if you don't select the CLI SAPI.
  Before the upgrade you *should* run 'make config' in lang/php4 or
  lang/php5 to configure the SAPIs you want to install.
  As a consequence the default binary packages include the CLI and the
  FastCGI SAPIs.
 

所以順手把他重新 make 了一次,進 php 打 make config 勾一勾然後 portupgrade -f 'php*' 下去就搞定了 :p

mediawiki + mysql5.1 beta

剛剛在裝 mediawiki ,本來理論上 make install clean 就能搞定的東西裝了好久。我還笑著跟把妹揚說,搞不好他那裡下去打 make install clean 會直接 ok 也說不定。(把妹楊最近被惡魔化了,雖然他本來就是壞人,不過被惡魔化倒應該是頭一遭。他lab裡的機器現在是 FreeBSD 6 喔!嘿嘿)。原因是因為之前手賤然後現在就遇到很多神秘的問題。

這篇有 提過因為 mysql5.1.7 beta吃了一點小苦頭,而這個問題也同樣發生在 mediawiki 的 CREATE TABLE 的 sql 檔上面。一開始是一度懷疑是不是因為我自己白目去抓 mediawiki 的 svn (自以為以後升級比較方便,可是從 FCU 抓那邊真的是他 X 的慢…)所以爛掉,後來從 ports 裝也是相同的情形,可是現在 mysql 上面又跑幾個東西再上面了,要再 downgrade 其實也可說是頗麻煩,於是就很任命的開始找。一開始看到 Syntax error 大概有個底,照上次經驗把 TYPE 清光光大概就會動。不過後來就很莫名其妙了。

一開始發生 index key 不能 > 1000 bytes 的情形,可是怎麼看都莫名其妙,後來 google 到說原來 utf8 會比較機車,於是就開始 try and error 慢慢調整。之後遇到

A database error has occurred Query: SET NAMES utf8

然後卡關卡好久後才發現原來是因為我一開始就在 my.cnf 設了

init_connect = 'SET NAMES UTF8;'

然後 mediawiki 又自己做了一次,所以不知道該算是誰的錯?解法是把 include/Database.php Line 310 那附近的 $this->query( 'SET NAMES utf8' ); 給幹掉,然後就天下大平了。

如果有需要的可以拿我亂改的 sql 檔蓋到 /maintenance/mysql5/ 底下的 tables.sql,不過爆炸不負責就是。這裡下載