Archive

Archive for the ‘OS/Server’ Category

Centos掛載windows網路芳鄰的錯誤

January 18th, 2010

最近用mount都不是很順利,常常遇到奇怪的問題 (我一直懷疑是win 7的問題)

時好時壞的真的很奇怪,當我執行下面這行指令的時候

 mount -t cifs -o username=xxx,password=xxx,iocharset=utf8,codepage=unicode,unicod //192.168.0.3/living-music /media/Squall-Music/

有時候就會出現下面這行錯誤訊息!

mount error 12 = Cannot allocate memory 

Read more…

Squall Linux, 工作紀錄 , , ,

Apache 啟動SSH

March 5th, 2009

安裝平台:CentOS 5.x + Server version: Apache/2.2.3

(本來是想寫透過PHP使用GMail寄信,不過發現需要啟動SSH的功能)

基本上要先安裝APACHE+OPENSSL

yum install apache
yum install openssl

首先需要產生SSL憑證:

$ openssl genrsa -out yourname.key 1024
Generating RSA private key, 1024 bit long modulus
......++++++
........++++++
e is 65537 (0x10001)

設定憑證的一些資訊:

$ openssl req -new -key yourname.key -out yourname.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:TW
State or Province Name (full name) [Berkshire]:Taipei County
Locality Name (eg, city) [Newbury]:Taipei City
Organization Name (eg, company) [My Company Ltd]:Squall
Organizational Unit Name (eg, section) []:Squall
Common Name (eg, your name or your server's hostname) []:www.l-penguin.idv.tw
Email Address []:steven@ms.ntcb.edu.tw
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

憑證簽署:

$ openssl x509 -req -days 365 -in yourname.csr -signkey

編輯ssl.conf

$ vim /etc/httpd/conf.d/ssl.conf

找到下面兩行,將路徑改成您存放crt及key的地方即可

SSLCertificateFile yourname.crt #112行
SSLCertificateKeyFile yourname.key #119行

重新啟動Apache即可,只要將原本網址http://xxx.xx.xxx 改成 https://xxx.xxx.xxx

Blogged with the Flock Browser

Squall Linux, OS/Server , , ,

Ubuntu 8.04 下安裝 SQLite3

February 18th, 2009

Ubuntu 8.04 的SQLite是2,所以需要靠自己手動下載來編譯囉!

$ wget http://pecl.php.net/get/sqlite3-0.6.tgz
$ tar -zxf sqlite3-0.6.tgz
$ cd sqlite3-0.6/
$ sudo apt-get install php5-dev
$ sudo phpize
$ ./configure
$ make
$ sudo make install
Blogged with the Flock Browser

Squall Linux ,

Web Snapshot for Linux

January 22nd, 2009

上次用到一半失敗,今天又發現另外一個教學網站在 Linux 上架設 Screenshot Service

基本上一樣化葫蘆就可以了,之前失敗的原因我猜是ubuntu-desktop的關係吧(?)

安裝步驟 :

1. (Clean) Ubuntu 8.04 Server
2. sudo apt-get install ubuntu-desktop
3. sudo apt-get install xvfb
4. sudo apt-get install netpbm
5. sudo apt-get install firefox-3.0

設定firefox:

vim ~/.mozilla/firefox/xxxxx.default/prefs.js

加入

user_pref("browser.sessionstore.enabled", false);
user_pref("browser.sessionstore.resume_from_crash", false);
user_pref("browser.startup.page", 0);
user_pref("plugin.default_plugin_disabled", false);
user_pref("privacy.popups.disable_from_plugins", 3);
user_pref("alerts.totalOpenTime", 1);
user_pref("security.enable_ssl2", false);
user_pref("security.enable_ssl3", false);

重新啟動firefox (我是重新開機,才生效)

加入flash player

首先到Adobe下載ubuntu 8.04 firefox專用的flash player (install_flash_player_10_linux.deb)

sudo dpkg -i install_flash_player_10_linux.deb

這樣應該就可以正常截圖囉! :)

截圖方法:

killall firefox Xvfb
Xvfb :2 -screen 0 1024x768x24 -fbdir /tmp -nolisten inet6 &
sleep 10
DISPLAY=:2.0 firefox -width 1024 -height 768 http://www.google.com &
sleep 10
xwd -display :2.0 -root -out shot.xwd
xwdtopnm shot.xwd> shot.pnm
pnmscale -xysize 200 150 shot.pnm> shotsmall.pnm
pnmtojpeg shotsmall.pnm> shot_thumb.jpg
pnmtojpeg shot.pnm> shot.jpg

把它寫成Shell Script

sh filename.sh 網址 輸出檔名
ex:sh snapshot.sh http://www.google.com googlepage
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

killall firefox Xvfb  

Xvfb :2 -screen 0 1024x768x24 -fbdir /tmp -nolisten inet6 &

sleep 10

DISPLAY=:2.0 firefox -width 1024 -height 768 $1 &

sleep 10

xwd -display :2.0 -root -out shot.xwd

xwdtopnm shot.xwd> shot.pnm

pnmscale -xysize 200 150 shot.pnm> shotsmall.pnm

pnmtojpeg shotsmall.pnm> $2_small.jpg

pnmtojpeg shot.pnm> $2.jpg

其他參考網址:

http://blog.whirix.com/2007/05/screenshots-of-web-pages.html

http://www.ubuntugeek.com/how-to-install-adobe-flash-player-10-in-ubuntu-804-hardy-heron.html

Squall Linux ,

[教學] 自動校正時間

May 2nd, 2008

常常會有自己系統時間不準的問題嗎? 如何讓自己的系統自動對時間?

這邊簡單說明一下在Linux是要如何設定的:

只要輸入
ntpdate time.stdtime.gov.tw
hwclock -w (將時間寫入bios)

不過為了方便,我們還是寫到crontab裡面吧! 讓他定時校正 (因為我用VMWARE,時間常常無法同步)

開啟crontab

vi /etc/crontab

輸入並儲存

10 5 * * * root /usr/sbin/ntpdate time.stdtime.gov.tw && /sbin/hwclock -w

這樣就完成囉! 不過有幾個注意事項要注意~不然還是有可能無法更新喔!

※ 注意事項
1. 遇到ntpd無法更新,或是顯示NTP socket use
ntpdate[18121]: the NTP socket is in use, exiting
只要將ntpd關閉就可以了! (最好是到setup中設定,把ntpd服務關閉)
/etc/init.d/ntpd stop

2. 設定完crontab,需要啟動此服務 (一樣到setup中開啟crond的服務)
/etc/init.d/crond start

以上只是介紹Linux的對時方法,更多教學可以在國家時間與頻率標準實驗室找到喔!

Squall OS/Server , ,

Samba mount

January 22nd, 2007

由於我的centos預設是big5編碼,所以在用smbmount的時候,要稍微注意一下編碼

不過首先要先修改 /etc/samba/smb.conf 預設沒有下面這三個選項,需自行加入


display charset = cp950
dos charset = cp950
unix charset = cp950


然後在輸入smbmount //IP Address/squall /home/squall/ -o username=
squall,password=1234,codepage=cp950

就可以順利在linux上掛windows的網芳囉! ^^

Squall Linux

關於samba server

January 20th, 2007

花了好久的時間在研究samba server

可是一直都沒成功,後來發現只要打/etc/init.d/iptables stop就可以了!

所以應該是出在防火牆的關係! 不過目前還沒有找到正確的設法

暫時的解決辦法是把防火牆關了,然後改 /etc/samba/smb.confhost allow

不知道防火牆關閉會有什麼問題發生?

至少目前是正常的啦! 繼續觀察囉!

Squall Linux

centos 4.0 中文亂碼

January 19th, 2007

昨天裝了CentOS~~安裝上非常的順利,可是卻發現中文顯示是亂碼>"<

後來上了google查了一下,發現其實是 /etc/sysconfig/i18n 設定的問題

修改/etc/sysconfig/i18n
把UTF改成Big5

[root@localhost ~]# vi /etc/sysconfig/i18n
LANG="zh_TW.Big5"
SUPPORTED="zh_TW.Big5:zh_TW:zh"

這樣中文字就會正常出現了^^

參考網站:http://heartshare2u.com/boblog/read.php?45 

Squall Linux