2009年8月30日 星期日

[電影] 急速醜聞 / 超速醜聞 / Speeding Scandal








今天在第四台看到,第二次看到了。車太鉉主演的電影,記得2002年的「我的野蠻女友/My Sassy Girl」嗎,當時也風迷一陣子。據說這部電影在韓國票房不錯喔!而女主角在韓劇「王與我」飾演少年尹素華/尹素花,當時也吸引不少人了。這部電影還滿搞笑的囉!
















更多敘述請參考:







以上圖片來源:PhotoWant.com http://photowant.com


三週的體驗營

昨天還忙著寫程式,盡可能把包袱弄小一點,總覺得把程式丟給別人還挺不負責的,這樣的缺憾也是人生的一途嗎?隨著 MSN 同學的敲打,發現他對軍旅的不安,或許,這才是正常的現象。


記得剛上大學時,我帶著高中同學送我的"溫一壺月光下酒"和高中成年禮送的檯燈,就這樣在新的環境裡渡過一夜。我記得那時還有傳簡訊給幾位學長姐,
一位是高中 BBS
站的站長,那時他唸完碩班正要畢業,另一位則是繼續唸博班的學長,最後則是在高中碰到的外文學姐,只是一切止於簡訊,可能是自己行動力不佳,不像大學室友
他們,一進大學就往其他寢找高中同學,就這樣人情散。


沒想到一下就要進入新的旅程,並沒什麼好擔心,只是經過這短短三個禮拜後,便正式轉職成社會人士,想啊想,大概有點眷戀現在的環境。


未來啊,似乎資源將越來越豐富,得趕快找好目標,追求與達成。


2009年8月23日 星期日

[PHP] GD with JPEG / imagejpeg @ FreeBSD

前幾天使用 Tarball 方式安裝完 PHP ,沒想到 GD 裡頭一些東西不正常,舉例來說:imagejpeg not found!


仔細看了一下,一直搞不懂為什麼編 PHP 時還需要給定 --with-jpeg-dir 、 --with-png-dir 等位置,於是,我順一遍假想的流程,終於搞定了。



  1. 在 /usr/ports/graphics/jpeg 發現 libjpeg 的蹤影,尾隨 Makefile 找到一些可以下載 source code 的地方

    • http://www.ijg.org/files/

    • ftp://ftp.uu.net/graphics/jpeg/

    • 下載 jpegsrc.v6b.tar.gz 並解壓縮與編譯

      • # tar -xvf jpegsrc.v6b.tar.gz

      • # cd jpeg-6b/ ; make



    • 在 jpeg-6b/.lib 中得到 libjpeg.a 檔



  2. 重編 PHP 並且指定 --with-jpeg-dir 位置,即 libjpeg.a 位置(最好統一拉出來建目錄管理)

  3. 搞定


因此,若有其他相關的,如 png 等,可以順勢到 /usr/ports/graphics 逛逛囉!此為 Tarbll 安裝方式所碰到的問題,使用 /usr/ports 可在 /usr/ports/lang/php5-extensions/ 安裝 GD 得到處理。


[PHP] gdb php.core

沒有想過,原來自己寫的 PHP 也會產生這個檔案。這個原因是出自於我架的 Apache HTTPD 運行 PHP 所產生的,透過 HTTPD 類似執行 shell_exec( "/path/bin/php /tmp/test.php > /dev/null & " );


如果產生 php.core 檔案,可以到官網參考解決方式:



我自己的情況是透過以下方式看訊息的:



  • # gdb /path/bin/php php.core

    • (gdb) bt ;

    • 會蹦出一堆訊息讓你參考

      • #0  0x88b9194d in calloc () from /lib/libc.so.7
        #1  0x88b91b7e in free () from /lib/libc.so.7
        #2  0x082cbf9a in destroy_zend_class (pce=0x88e3e76c) at /path/php-5.2.10/Zend/zend_opcode.c:202
        #3  0x082de386 in zend_hash_destroy (ht=0x10) at /path/php-5.2.10/Zend/zend_hash.c:526
        #4  0x082d48b8 in zend_shutdown () at /path/php-5.2.10/Zend/zend.c:736
        #5  0x08293f3f in php_module_shutdown () at /path/php-5.2.10/main/main.c:1908
        #6  0x083500a0 in main (argc=4, argv=0xbfbfe71c) at /path/php-5.2.10/sapi/cli/php_cli.c:1357





  • # gdb /path/bin/php

    • (gdb) run /tmp/test.php arg1 arg2 arg3;

    • 沒多久看到訊息

      • ...

      • Fatal error: Call to undefined function imagecreatefromstring() in /tmp/test.php on line xxx

      • ...

      • Program received signal SIGSEGV, Segmentation fault

      • 0x88b9194d in calloc () from /lib/libc.so.7






因此,至少知道點方向了 :-) 但這主因並不是缺少 library 啦,經多次測試後,發現用 5.2.10 使用 imap_search 後產生的問題,改用 5.2.9 就不會出現 Segmentation fault 啦。


# [ @ php-5.2.10 ] ./configure --with-apxs2=/path/httpd/bin/apxs --prefix=/path/php --without-pear --with-openssl --with-imap --with-imap-ssl


使用 imap_open -> imap_search -> imap_close 則會出現 Segmentation fault ,但改用 php-5.2.9 就不會發生。


另外一聊,在開發移植的環境上,最好先弄個 lib_test.php 的檔案,用來測試必要的 function 是否存在:



  • <?php
    $test_func = array(
            'imagecreatefromstring' ,
            'imagesx' ,
            'imagesy' ,
            'imagecopyresized' ,
            'imagejpeg' ,
            'imagedestroy'
    );
    foreach( $test_func as $v )
            if( !function_exists( $v ) )
                    echo "'$v' not found!\n";
    ?>

  • # /path/bin/php lib_test.php


2009年8月21日 星期五

[Unix] 使用 Tarball 安裝 Apache + PHP @ FreeBSD

由於 lab 電腦得還回去,使得程式的開發無法在用 VMWare 了,因此,又回歸到在工作站架設自己需要的環境啦!順便要把自己降級,用用 Tarball 吧!說真的,這也是我覺得工作站好用之處。寫個筆記給自己。


安裝 Apache HTTPD



  1. 下載 HTTPD - http://httpd.apache.org/


  2. 解壓縮 # tar -xvf httpd-2.2.13.tar.gz ,之後就會在所在目錄蹦出 httpd-2.2.13/ 目錄

  3. 設定編譯等環境

    • # ./configure --prefix=/home/user/tmp_for_httpd --enable-so --enable-ssl

    • 如加入 https 的需求等



  4. 編譯和安裝

    • # make && make install



  5. 設定 httpd.conf

    • User / Group

    • Listen Port_Number

    • Include conf/extra/httpd-ssl.conf

    • 家目錄 DocumentRoot 等



  6. 產生憑證

    • # cd /home/user/tmp_for_httpd/conf

    • # openssl genrsa -des3 -out server.key 4096
      # openssl req -new -key server.key -out server.csr
      # openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
      # openssl rsa -in server.key -out server.key

    • 記得在 chmod 600 server.key 吧

    • 另外,要跑的 https port 也要記得在 conf/extra/httpd-ssl.conf 修改

      • <VirtualHost _default_:HTTPS_Port>

      • ServerName www.example.com:HTTPS_Port

      • 家目錄 DocumentRoot 等





  7. 運行與測試

    • # /home/user/tmp_for_httpd/bin/apachectl start

    • # telnet localhost Port_Number

      • 連得上後,請打 GET / 即可,算是簡單的測試



    • 有任何問題,請留意 logs/error_log 訊息




安裝 PHP



  1. 下載 PHP - http://www.php.net/


  2. 解壓縮 # tar -xvf php-5.2.9.tar.bz2 ,之後就會在所在目錄蹦出 php-5.2.9/ 目錄

  3. 設定編譯等環境

    • # ./configure --with-apxs2=/home/user/tmp_for_httpd/bin/apxs --prefix=/home/user/tmp_for_php --without-pear --with-openssl --enable-mbstring --with-curl --with-imap --with-mcrypt --with-imap-ssl --with-gd

    • 此例為啟用 Curl 、OpenSSL、IMAP、mbstring、Mcrypt、GD 等函式庫,詳請請試著到 PHP 官網查尋,上頭都會敘述函式庫在編譯時要下什麼關鍵字。



  4. 編譯和安裝

    • # make && make install



  5. 修改 httpd.conf

    • AddType application/x-httpd-php .php

    • <IfModule dir_module>
          DirectoryIndex index.php index.html
      </IfModule>




以上就完成兩者的結合了,記得安裝完 PHP 或設定 PHP 完後,都要重新啟動 HTTPD 啦