php5.3.3的php.ini放置位址
/usr/local/etc/php.ini
2010年11月26日 星期五
2010年11月25日 星期四
安裝 vim
cd /usr/ports/editor/vim
make install clean
參數設定:
/usr/local/share/vim/vim73/vimrc
set nocompatible
syntax on
set sw=2
set hls
set cindent
set backspace=2
或
/home/usr/.vimrc
set nocompatible
syntax on
set sw=2
set hls
set cindent
set backspace=2
2010年11月5日 星期五
freebsd apache + php + mysql
1.mysql 5.5
#安裝
cd /usr/ports/database/mysql55-server/
make install clean
#加入開機啟動
/etc/rc.conf
+ mysql_enable="YES"
#啟動mysql (直接reboot也可以)
/usr/local/etc/rc.d/mysql-server start
#設定root密碼
mysqladmin -u root password 新密碼
mysql -u root -p
2.apache22
#安裝
cd /usr/ports/www/apache22/
make install clean
config 選擇 mod_mysql
#設定/etc/hosts
127.0.0.1 localhost MyFreeBSD
#設定/etc/rc.conf
hostname="MyFreeBSD"
apache22_enable="YES"
apachectl start
3.php
#安裝
cd /usr/ports/lang/php5
make install clean
#安裝 php-extensions
cd /usr/ports/lang/php5-extensions
make install clean
#修改/usr/local/etc/apache22/httpd.conf
#拿掉開頭的"#"
Include etc/apache22/extra/httpd-userdir.conf
#安裝mod_php56
cd /usr/ports/www/mod_php56
make install clean
#增加index.php
DirectoryIndex index.htm index.php
#增加下面幾行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
#修改/usr/local/etc/apache22/extra/httpd-userdir.confAddType application/x-httpd-php-source .phps
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
UserDir public_html
兩個public_html都改成www
2010年11月4日 星期四
port更新
方法一:cvsup
#從 /usr/ports/net/cvsup-without-gui 安裝
#複製config檔案
#更改 default host
#更新ports
方法二:csup
#複製config檔案
#更改 default host
#更新ports
方法三:portsnap
#修改config檔 /etc/portsnap.conf
#第一次執行更新
#之後更新
cvsup 及 csup 使用 port 5999 容易被防火牆擋下來
portsnap 使用 http protocol 是被防火牆擋下來時的好選擇
實測結果 portsnap.tw.freebsd.org 下載速度緩慢(6-8k),直接從portsnap.freebsd.org下載也僅100k上下,第一次更新的話需要較久的時間。
20111227 更新
目前實測portsnap.tw.freebsd.org有500kBps ~ 1MBps,速度快了很多。
#從 /usr/ports/net/cvsup-without-gui 安裝
cd /usr/ports/net/cvsup-without-gui
make install clean
#複製config檔案
cp /usr/share/examples/cvsup/ports-supfile /usr/ports-supfile
#更改 default host
*default host=freebsd.csie.ncu.edu.tw
#更新ports
cvsup -g -L 2 /usr/ports-supfile
方法二:csup
#複製config檔案
cp /usr/share/examples/cvsup/ports-supfile /usr/ports-supfile
#更改 default host
*default host=freebsd.csie.ncu.edu.tw
#更新ports
csup -g -L 2 /usr/ports-supfile
方法三:portsnap
#修改config檔 /etc/portsnap.conf
SERVERNAME=portsnap.tw.FreeBSD.org
#第一次執行更新
portsnap fetch extract
#之後更新
portsnap fetch update
cvsup 及 csup 使用 port 5999 容易被防火牆擋下來
portsnap 使用 http protocol 是被防火牆擋下來時的好選擇
實測結果 portsnap.tw.freebsd.org 下載速度緩慢(6-8k),直接從portsnap.freebsd.org下載也僅100k上下,第一次更新的話需要較久的時間。
20111227 更新
目前實測portsnap.tw.freebsd.org有500kBps ~ 1MBps,速度快了很多。
2010年11月3日 星期三
使用http通訊協定抓取遠端檔案
來源檔案位址 超連結
ex: "http://tw.yahoo.com/index.htm"
儲存檔案位址 本機儲存位址
ex: "c:\download\index.htm"
ex: "http://tw.yahoo.com/index.htm"
儲存檔案位址 本機儲存位址
ex: "c:\download\index.htm"
using System;
using System.IO;
using System.Text;
using System.Net;
static void get_file(string[] args)
{
try
{
string fn = "超連結";
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(fn);
HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse();
Console.WriteLine("File size = " + httpResponse.ContentLength);
System.IO.Stream datastream = httpResponse.GetResponseStream();
byte[] buffer = new byte[8192];
FileStream fs = new FileStream("本機儲存位址", FileMode.Create, FileAccess.Write);
int size = 0;
do
{
size = datastream.Read(buffer, 0, buffer.Length);
if (size > 0)
fs.Write(buffer, 0, size);
} while (size > 0);
Console.WriteLine(fn + " download Done!!");
fs.Close();
httpResponse.Close();
}
catch(Exception)
{
Console.WriteLine("Url not exists!");
}
Console.ReadKey();
}
訂閱:
意見 (Atom)