2011年7月6日 星期三

Ubuntu安裝sfs3

資料來源:http://163.23.86.99/wpmu301/blog/2010/11/13/ubuntu%E5%AE%89%E8%A3%9Dsfs3/

安裝時請選 LAMP server
================================================
[網路校時]
sudo ntpdate time.stdtime.gov.tw

/usr/sbin/ntpdate time.stdtime.gov.tw
/sbin/hwclock -w

================================================
[更新系統]

您可以先將/etc/apt/sources.list
Cd-Rom的那一行先註解掉,免得一直放光碟
不過這樣它會全由網路去下載

sudo apt-get update
sudo apt-get upgrade

================================================
[安裝ssh及tcpd]
sudo apt-get install ssh rcconf portmap tcpd portsentry
sudo /etc/init.d/ssh restart
sudo vi /etc/ssh/sshd.conf
================================================
[設定網路]–(IP異動時)
sudo vi /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254

重新啟動網路
sudo /etc/init.d/networking restart

================================================
[設定連線範圍,必要的安全措施]
/etc/hosts.deny
ALL:ALL

/etc/hosts.allow
ALL:192.168.1. ,163.23. : allow
要增加的IP同上格式,記得用逗號格開

================================================
[設定apache及php]
sudo vi /etc/php5/apache2/php.ini
memory_limit = 32M
(不用太大)

sudo vi /etc/apache2/conf.d/charset
加上註解符號#
#AddDefaultCharset UTF-8

vi /etc/apache2/sites-enabled/000-default

找到 下行的
Options Indexes FollowSymLinks MultiViews
將自動索引拿掉,變成
Options FollowSymLinks MultiViews

sudo /etc/init.d/apache2 restart

================================================
[加入別名,方便管理時使用]
sudo vi /etc/bash.bashrc
alias ll=’ls -l’
================================================
[變更MySQL密碼]
mysqladmin -u root -p舊密碼 password ‘新密碼’
(新安裝者舊密碼為空)
mysqladmin -uroot -p password ‘abc123′
用Ubuntu及Debian或B2d系列裝的都有一個
預設的ebian-sys-maint帳號
可別給它刪掉….否則您就等著重灌MySQL

================================================
[復原sfs3資料庫]
sudo /etc/init.d/mysql stop
cd /var/lib/mysql
sudo tar zxvf sfs3_db.tgz
sduo chown mysql.mysql sfs3 -R
sudo /etc/init.d/mysql start

================================================
[檢查並修復sfs3資料庫]

千萬不要用以的的方式==>穩死的
mysqlcheck -u root -p -r –use-frm sfs3
以前的方式為 -r 和 –use-frm一起用

要採用新的作法==>亮哥測過OK
就是將以前的作法分成兩次
先用-r參數做一次,再用–use-frm參數再做一次
mysqlcheck -uroot -p -r sfs3
mysqlcheck -uroot -p –use-frm sfs3

================================================
[復原sfs3程式庫]
方式1:含原程式
cd /var/www
sudo tar zxvf sfs3.tgz
cd /var/www/sfs3
sudo chown www-data.www-data data -R

方式2:僅含sfs3/data資料目錄
cd /var/www
sudo wget http://sfscvs.tcc.edu.tw/sfs_stable5.tar.gz (For SFS3.1版)
sudo tar zxvf sfs_stable5.tar.gz
sudo mv sfs3_stable sfs3
cd /var/www/sfs3
sudo tar zxvf /在那裡/sfs3_data.tgz(需指出data備份檔位置,或者乾脆直接將備份檔先行下載到sfs3目錄下再解壓縮即可)
sudo chown www-data.www-data data -R

================================================
[修正sfs3設定檔]
1.舊的設定檔
sudo vi /var/www/sfs3/include/config.php

2.沒有舊的設定檔
cd /var/www/sfs3/include/
sudo cp config.dist.php config.php
sudo chmod 644 config.php
sudo vi config.php

**** 修改重點 ****

//程式根目錄 PATH
$SFS_PATH = "/var/www/sfs3″;

//學務管理首頁程式 URL (設定時,保留最後的 "/" )
$SFS_PATH_HTML ="/sfs3/";

//學校首頁 URL
$HOME_URL ="http://163.23.xx.xx/";

$mysql_host ="localhost";

// mysql 使用者
$mysql_user ="root";

// mysql 密碼
$mysql_pass ="abc123″;

// 資料庫名稱
$mysql_db ="sfs3″;

//上載檔案放置位置,上載目錄權限需設為 777
//上載檔案放置位置,上載目錄擁有者User以及Group需設為www-data
$UPLOAD_PATH = "/var/www/sfs3/data/";

//別名 (alias) apache 在設定檔 httpd.conf 中加入 WIN32 在IIS管理員中設定
//新增上傳檔案路徑別名
$UPLOAD_URL = "/sfs3/data/";

// 國中 設 6 ,國小設 0
$IS_JHORES=6;

另外國中部分還要修改
// 年段(國小用)
$class_year = array("1″=>"一年","2″=>"二年","3″=>"三年","4″=>"四年","5″=>"五 年","6″=>"六年","a"=>"幼稚園","b"=>"特教班","c"=>"資源班");
// 年段(國中用)
$class_year = array("7″=>"一年","8″=>"二年","9″=>"三年","a"=>"幼稚園","b"=>"特教班","c"=>"資源班");

================================================
[將資料庫及網站目錄搬家]

這樣才方便管理!

sudo mv /var/www /home/自己的帳號/ (eg./home/webadmin)

sudo ln -s /home/自己的帳號/www /var/www

sudo /etc/init.d/mysql stop

sudo mv /var/lib/mysql /home/

sudo ln -s /home/mysql /var/lib/mysql

sudo /etc/init.d/mysql start

PS:將這些東東搬到/home有什麼用意

如果你的HD只切3塊:根目錄、 swap、 /home

若那天要重灌 , 就把根目錄 Format掉,但資料庫網頁等就都還在!

Good idea!

2011年6月26日 星期日

BIND9 SETTING

/etc/bind

(db.bdsps.chc.edu.tw)
;
; BIND data file for local loopback interface
;
$TTL 604800
$ORIGIN bdsps.chc.edu.tw.

@ IN SOA bdsps.chc.edu.tw. root.bdsps.chc.edu.tw. (
20110516 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS bdsps.chc.edu.tw.
@ IN A 163.23.103.1
@ IN MX 10 bdsps.chc.edu.tw.

dnsvr IN A 163.23.103.1
dnsvr IN MX 20 bdsps.chc.edu.tw.
;
www IN CNAME dnsvr
ftp IN CNAME dnsvr
mail IN CNAME dnsvr

*******************************************************************************
/etc/bind
(db.163.23.103)

;
;BIND reverse data file for local loopback interface
;
$TTL 604800
@ IN SOA bdsps.chc.edu.tw. root.bdsps.chc.edu.tw. (
20110516 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS bdsps.chc.edu.tw.
52 IN PTR bdsps.chc.edu.tw.
52 IN PTR dnsvr.bdsps.chc.edu.tw.
52 IN PTR www.bdsps.chc.edu.tw.
52 IN PTR mail.bdsps.chc.edu.tw.
52 IN PTR ftp.bdsps.chc.edu.tw.


*************************************************************************************
/etc/bind
(named.conf.local)
//
// Do any local configuration here
//

zone "bdsps.chc.edu.tw" {
type master;
file "/etc/bind/db.bdsps.chc.edu.tw";
};

zone "103.23.163.in-addr.arpa" {
type master;
file "/etc/bind/db.163.23.103";
};

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

**************************************************************************************
/etc/bind
(named.conf)

// This is the primary configuration file for the BIND DNS server named.
//
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
//
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";


***********************************************************************************
/etc/bind
(named.conf.options)
options {
directory "/var/cache/bind";
// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0's placeholder.

forwarders {
168.95.1.1;
163.23.200.1;
163.23.200.6;
};
allow-query { any; };
allow-transfer { none; };
auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};

***********************************************************************************
/etc
(resolv.conf)
# Generated by NetworkManager
domain bdsps.chc.edu.tw
search bdsps.chc.edu.tw
nameserver 163.23.103.1
nameserver 163.23.200.6
nameserver 163.23.200.1
nameserver 168.95.1.1

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

/etc/default/bind9
(bind9)

# run resolvconf?
RESOLVCONF=yes

# startup options for the server
OPTIONS="-u bind"

2011年5月19日 星期四

ie無法瀏覽某內部網頁 firefox卻可以??!

1.網頁上方的選項---->工具---->網際網路選項---->刪除瀏覽歷程記錄(cookie)---->確定。
2.試試看把網際網路選項
進階中的 永遠將url傳送成.....取消打勾
進階中的 國際 傳送UTF-8 URL......打勾
SSL 2.0、SSL 3.0、TLS 1.0、PCT 1.0 的設定......打勾
3.補充說明:製作網頁時避免用中文檔名應該會減少這問題發生機率

在XP下,安裝UBUNTU雙系統的條件

1.C碟必須是NTFS格式
2.XP-SP3版本

ACFS10.04-BIND9-DNS設定

---安裝篇----
1.安裝ACFS10.04(Ubuntu10.04架構)

依照 彰化縣99年度學籍系統安裝機資料庫備份手冊 安裝

2.安裝BIND9

root權限下

安裝 Bind9 的指令如下:

apt-get install bind9

建議安裝測試及除錯 DNS 的工具 dnsutils,指令如下:

apt-get install dnsutils

3.DNS設定

有關整個 DNS 的架構與設定方法參考 StudyArea;範例網域為 ...bdsps.chc.edu.tw,dns 主機 ip 163.23.103.1,主機名稱 dnsvr。另外考量到安全性因素,建議讓 bind 執行於 chroot 環境,以保護系統免被入侵。

在一般 Linux distro. 上面 bind 主要設定檔為 /etc/bind/named.conf,但 Debian 上略有不同;Debian 上面主要設定檔為 /etc/bind/named.conf.local。除了設定檔的檔名不同外其餘設定皆大同小異。

首先看看 /etc/bind/named.conf.local 的內容:

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

zone "bdsps.chc.edu.tw" in {
type master;
file "/etc/bind/db.bdsps.chc.edu.tw";
};

zone "103.23.163.in-addr.arpa" in {
type master;
file "/etc/bind/db.163.23.103";
};


上面第一個 zone 定義了 bdsps.chc.edu.tw 這個網域的正解部份,並設定類型為 master,設定檔為 /etc/bind/db.bdsps.chc.edu.tw;103.23.163.in-addr.arpa 的部份則是反解的部份且設定檔為 /etc/bind/db.163.23.103。

接著來看看正解設定檔 db.bdsps.chc.edu.tw的內容:

$TTL 86400
$ORIGIN x9.idv.tw.
@ IN SOA bdsps.chc.edu.tw. root.bdsps.chc.edu.tw. (
20110520 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL

; 主要 NS、MX 與主要主機
@ IN NS bdsps.chc.edu.tw.
@ IN A 163.23.103.1
@ IN MX 10 bdsps.chc.edu.tw.
dnsvr IN A 163.23.103.1
dnsvr IN MX 20 bdsps.chc.edu.tw.

; 別名紀錄,直接指向主機 dnsvr
www IN CNAME dnsvr
ftp IN CNAME dnsvr
mail IN CNAME dnsvr


正解設定檔內除了設定兩筆 mailserver MX 紀錄外,另外還設定了 www、ftp、mail 三個 CNAME 指向 bdsps.chc.edu.tw;特別注意到上面 "bdsps.chc.edu.tw.",最後的 "." 意思為代表這是 FQDN。

最後來看反解設定檔 db.163.23.103:

$TTL 86400
@ IN SOA bdsps.chc.edu.tw. root.bdsps.chc.edu.tw. (
20110520 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
86400 ) ; Negative Cache TTL
;


@ IN NS bdsps.chc.edu.tw.
52 IN PTR bdsps.chc.edu.tw.
52 IN PTR dnsvr.bdsps.chc.edu.tw.
52 IN PTR http://www.bdsps.chc.edu.tw/.
52 IN PTR mail.bdsps.chc.edu.tw.
52 IN PTR ftp://ftp.bdsps.chc.edu.tw/.


完成網域的正反解設定後,最後修改幾個 bind9 的執行相關參數設定檔:

/etc/default/bind9:

OPTIONS="-u bind"
# Set RESOLVCONF=no to not run resolvconf
RESOLVCONF=yes

/etc/bind/named.conf.options:

forwarders {
168.95.1.1;
163.23.200.1;
163.23.200.6;
};

auth-nxdomain yes; # conform to RFC1035 default is no. edit by neio
listen-on-v6 { none; }; # listen ipv6 default is any



編輯 /etc/resolv.conf,內容如下:


search bdsps.chc.edu.tw
nameserver 163.23.103.1
nameserver 163.23.200.1
nameserver 163.23.200.6
nameserver 168.95.1.1

接著重新啟動 bind9 後,一個簡易的小型 DNS 伺服器便已架設完畢。

4.測試(轉自另一篇文章)



dig

驗證 port 53 是否正在傾聽,指令如下:


dig -x 127.0.0.1

回應結果節錄如下:

第 2行說明 163.23.103.1 port 53。

;; Query time: 1 msec;; SERVER: 163.23.103.1#53(163.23.103.1)

驗證 Bind9 是 Caching nameserver,dig 外部的域名 (Domain name)。指令如下:


sudo dig ubuntu.com

回應結果節錄如下:


;; Query time: 489 msec

第二次 dig ubuntu.com,回應結果節錄如下:


;; Query time: 1 msec

第二次的 dig ubuntu.com 的 query time 會比第一次短。

dig 自己的域名 (Domain name)。指令如下:


sudo dig bdsps.chc.edu.tw

回應結果如下:

第 4行顯示 status: NOERROR


加一個參數 mx,再試一次。


sudo dig mx bdsps.chc.edu.tw

回應結果如下:

第 4行顯示 status: NOERROR


你可以試試 dig google.com 和 dig mx google.com。

ping

最後,你可以 ping 一下 bdsps.chc.edu.tw,看看回應如何。





5.Chrooting Bind9(非必要但較安全)



倘若 bind9 架設完畢且一切都測試無誤後,以下的設定可以把 bind9 運行於 chroot 模式。

建立 bind9 的 chroot 執行目錄與設定相關權限:

停止 bind9

$ sudo /etc/init.d/bind9 stop
建立 chroot 環境中必要的目錄

$ sudo mkdir -p /var/lib/bind9/etc
$ sudo mkdir -p /var/lib/bind9/dev
$ sudo mkdir -p /var/lib/bind9/var/cache/bind
$ sudo mkdir -p /var/lib/bind9/var/run/bind/run
搬移原 bind9 設定檔與建立鏈結

$ sudo mv /etc/bind /var/lib/bind9/etc/bind
$ sudo ln -s /var/lib/bind9/etc/bind /etc/bind
建立執行所需裝置檔

$ sudo mknod /var/lib/bind9/dev/null c 1 3
$ sudo mknod /var/lib/bind9/dev/random c 1 8
設定相關權限

$ sudo chmod 666 /var/lib/bind9/dev/null /var/lib/bind9/dev/random
$ sudo chown -R bind:bind /var/lib/bind9/var/*
$ sudo chown -R bind:bind /var/lib/bind9/etc/bind
修改 bind9 設定檔,指定啟動方式

$ sudo vim /etc/default/bind9
修改 OPTIONS 選項如下

OPTIONS="-u bind -t /var/lib/bind9"
重新啟動 bind9

$ sudo /etc/init.d/bind9 start

資料出處:
1.bind9 - DebianWiki
http://www.debian.org.tw/index.php/bind9



2.使用 Ubuntu 安裝 Bind9: Domain Name Service (DNS) 林瑞珠記帳士事務所
http://www.nowtaxes.com.tw/node/1114


2011年4月6日 星期三