顯示具有 實用套件 標籤的文章。 顯示所有文章
顯示具有 實用套件 標籤的文章。 顯示所有文章

2014年9月12日 星期五

「轉」WinMTR 免費好用網路伺服器 Ping 與 Tracert 圖形化測試軟體

http://download.sofun.tw/winmtr/?PageSpeed=noscript

軟體名稱:WinMTR – 網路伺服器 Ping 與 Tracert 測試軟體
官方網站:http://winmtr.net/
軟體介紹:
WinMTR – 它是一套圖形化界面「Tracert」與「Ping」指令小工具,有了它使用者就不需要打開 Windows 命令列視窗輸入指令,你只要輸入網指就可以在軟體式窗內同時看到 tracert 與 ping 的結果,讓電腦使用者清楚知道網路連線品質與伺服器狀態,特別是當網站連線速度過慢時,有了這套軟體真的是還蠻方便的!!! 軟體還是免安裝版本,需要的朋友可以下載來使用看看 ~

軟體基本說明與介紹:
「Host」欄位輸入欲查詢的主機,然後按下【Start】。隨即會在下面顯示查詢的結果。每個欄位所代表的意思是如下
Hostname:主機名稱
Nr:節點的數量。
Loss%: ping 封包回傳失敗的百分比。
Sent:已經傳送的封包數。
Recv:成功接收的封包數。
Best:回應時間的最小值。
Avrg:平均回應時間。
Worst:回應時間的最大值。
Last:最後一個封包的回應時間。

2013年3月20日 星期三

可調整linux分割區的工具

 以下介紹取自 ubuntu 官方網站介紹

介紹

GParted 是 GNOME 的硬碟分割軟體。是個能取代 Partition Magic 的工具,目前它甚至已經能處理 Windows 上的 NTFS。GParted 也有 GParted LiveCDGParted LiveUSB 可以讓您用一片光碟片或 USB隨身碟 就能處理硬碟分割。


使用方式很簡單,先從官方網站抓取 GParted Live CD/USB/HD/PXE Bootable Image。
將下載下來的 iso燒成光碟,用光碟開機時會看到以下畫面

直接選第一個選項即可進入光碟預載的系統


使用預設選項
選擇語系打入「30」台灣地區-繁體中文

直接使用預設「ENTER」

第一眼看到的畫面,右下角的 logo 感到特別熟悉!!
這個畫面大約會停留1秒後會自動跳到下個畫面


介面很簡單、清楚、直覺

選擇不同硬碟的方式

調整分割區大小
最後按下 apply 結束編輯。
按下後會有提示要作備份,由於備份是事前工作,這邊忽略他
至於怎麼備份,這應該不用介紹了  @@


2013年2月5日 星期二

Tripwire - 即時發現特定檔案異動

會認識這個套件,是因為某台不重要的主機被入侵,檔案被寫入不該有的文字,雖然對網站影響不大,但這是一個警訊。

Tripwire 主要功能是將檔案製作指紋資料庫,當發現某檔案的指紋被變更時才有辦法即時知道。

環境:
  • CentOS release 5.8  i386 (Final) 
安裝方式:
目前網路上查到的方式都是要自行 make file,但是新版的已經有rpm可以用。


目錄架構:
  • 主目錄:/etc/tripwire
  • twcfg.txt:可用來設定 tripwire 的工作環境,可依照你的習慣來調整。
  • twpol.txt:指定 tripwire 對哪些檔案的哪些項目進行監控。
說明:
  • twcfg.txt
    ROOT                      =/usr/sbin
    POLFILE                 =/etc/tripwire/tw.pol
    DBFILE                   =/var/lib/tripwire/$(HOSTNAME).twd
    REPORTFILE         =/var/lib/tripwire/report/$(HOSTNAME)-$(DATE).twr
    SITEKEYFILE         =/etc/tripwire/site.key
    LOCALKEYFILE    =/etc/tripwire/$(HOSTNAME)-local.key
    EDITOR                   =/bin/vi
    LATEPROMPTING          =false
    LOOSEDIRECTORYCHECKING   =false
    MAILNOVIOLATIONS                      =true
    EMAILREPORTLEVEL                   =3
    REPORTLEVEL                               =3
    MAILMETHOD                                  =SENDMAIL
    SYSLOGREPORTING                     =false
    MAILPROGRAM                               =/usr/sbin/sendmail -oi -tGLOBALEMAIL                                ="root@localhost,root@192.168.1.25"
    • DBFILE 為指紋資料庫之檔名
    • REPORTFILE 為檢測報告檔之檔名。

  • twpol.txt
    內容太多了,省略....
    重點在於 rulename、severity 群組內的設定。
    (
      rulename = "Invariant Directories",
      severity = $(SIG_MED)
    )
    {
      /                                    -> $(SEC_INVARIANT) (recurse = 0) ;
      /home                                -> $(SEC_INVARIANT) (recurse = 0) ;
      /etc                                 -> $(SEC_INVARIANT) (recurse = 0) ;
    }
    • 基本上可以直接套用預設值。
    • 也可以另外自己創造新的群組,例如我要監控 /var/www 內的網頁資料。
      (
        rulename = "WWW",
        severity = 100
      )
      {
           /var/www/html                             -> $(SEC_CRIT) ;
      }
執行方式:
  1. 設定密碼:
    • # tripwire-setup-keyfiles
    • 執行過程中會要求你設定兩個密碼(pass phrase):
      • site pass phrase :加密 twpol.txt 及 twcfg.txt 時用。
      • local pass phrase:加密指紋資料庫時用。
  2. 從twcfg.txt生成加密配置文件tw.cfg
    # twadmin --create-cfgfile -S /etc/tripwire/site.key /etc/tripwire/twcfg.txt
    此時會提示「
    Please enter your site passphrase」
  3. 用twadmin對策略文件進行語法檢查
    # twadmin -m P /etc/tripwire/twpol.txt
    此時會提示「Please enter your site passphrase」
  4. tripwire數據庫初始化
    # tripwire --init
    會跑1-3分鐘。
  5. 測試email電子郵件通知功能
    # tripwire -m c | mail -s “Tripwire Daily Report from {$HOSTNAME}”  root@localhost ((打上自己的email)
  6. 定時檢查
    • 在 /etc/cron.daily/ 下新增 script: (tw-check)
      #!/bin/bash
      /usr/sbin/tripwire -m c | mail -s “Tripwire Daily Report from {$HOSTNAME}” root@localhost
email報告內容範例:
  • 第一次執行 # tripwire -m c | mail -s “Tripwire Daily Report from {$HOSTNAME}”  root@localhost   時:
    Parsing policy file: /etc/tripwire/tw.pol
    *** Processing Unix File System ***
    Performing integrity check...
    Wrote report file: /var/lib/tripwire/report/202-
    3-168-16-static.unigate.net.tw-20130205-013834.twr
    Open Source Tripwire(R) 2.4.2.2 Integrity Check Report

    Report generated by:          root
    Report created on:            西元2013年02月05日 (週二) 01時38分34秒
    Database last updated on:     Never

    ==============================
    ==============================
    Report Summary:
    ==============================
    ==============================
    Host name:                    oooooooo
    Host IP address:              Unknown IP
    Host ID:                      None
    Policy file used:             /etc/tripwire/tw.pol
    Configuration file used:      /etc/tripwire/tw.cfg
    Database file used:           /var/lib/tripwire/oooooooo.twd
    Command line used:            tripwire -m c

    ==============================
    ==============================
    Rule Summary:
    ==============================
    ==============================
    ------------------------------
    -------------------------------------------------
      Section: Unix File System
    ------------------------------
    -------------------------------------------------
      Rule Name                       Severity Level    Added    Removed  Modified
      ---------                       --------------    -----    -------  --------
      Invariant Directories           66                0        0        0
      Temporary directories           33                0        0        0
    * Tripwire Data Files             100               1        0        0
      Critical devices                100               0        0        0
      User binaries                   66                0        0        0
      Tripwire Binaries               100               0        0        0
      Critical configuration files    100               0        0        0
      Libraries                       66                0        0        0
      Operating System Utilities      100               0        0        0
      Critical system boot files      100               0        0        0
      File System and Disk Administraton Programs
                                      100               0        0        0
      Kernel Administration Programs  100               0        0        0
      Networking Programs             100               0        0        0
      System Administration Programs  100               0        0        0
      Hardware and Device Control Programs
                                      100               0        0        0
      System Information Programs     100               0        0        0
      Application Information Programs
                                      100               0        0        0
      Shell Related Programs          100               0        0        0
      Critical Utility Sym-Links      100               0        0        0
      Shell Binaries                  100               0        0        0
      System boot changes             100               0        0        0
      WWW                             100               0        0        0
      (/var/www/html)
      OS executables and libraries    100               0        0        0
      Security Control                100               0        0        0
      Login Scripts                   100               0        0        0
      Root config files               100               0        0        0

    Total objects scanned:  18817
    Total violations found:  1

    ==============================
    ==============================
    Object Summary:
    ==============================
    ==============================
    ------------------------------
    -------------------------------------------------
    # Section: Unix File System
    ------------------------------
    -------------------------------------------------
    ------------------------------
    -------------------------------------------------
    Rule Name: Tripwire Data Files (/var/lib/tripwire)
    Severity Level: 100
    ------------------------------
    -------------------------------------------------
    Added:
    "/var/lib/tripwire/oooooooo.
    bak"
    ==============================
    ==============================
    Error Report:
    ==============================
    ==============================
    ------------------------------
    -------------------------------------------------
      Section: Unix File System
    ------------------------------
    -------------------------------------------------
    1.   File system error.
         Filename: /dev/kmem
         \xe6\xb2\x92\xe6\x9c\x89\xe6\
    xad\xa4\xe4\xb8\x80\xe6\xaa\x94\xe6\xa1\x88\xe6\x88\x96\xe7\x9b\xae\xe9\x8c\x84
    2.   File system error.
         Filename: /proc/ksyms
         \xe6\xb2\x92\xe6\x9c\x89\xe6\
    xad\xa4\xe4\xb8\x80\xe6\xaa\x94\xe6\xa1\x88\xe6\x88\x96\xe7\x9b\xae\xe9\x8c\x84
       ====略====
    -------------------------------------------------
    *** End of report ***

    Open Source Tripwire 2.4 Portions copyright 2000 Tripwire, Inc. Tripwire is a registered
    trademark of Tripwire, Inc. This software comes with ABSOLUTELY NO WARRANTY;
    for details use --version. This is free software which may be redistributed
    or modified only under certain conditions; see COPYING for details.
    All rights reserved.
    Integrity check complete.
  • 修改 /var/www/html/index.php 之後
    Open Source Tripwire(R) 2.4.2.2 Integrity Check Report
    Report generated by:          root
    Report created on:            西元2013年02月05日 (週二) 01時49分02秒
    -------------------------------------------------
    Rule Name: WWW (/var/www/html)
    Severity Level: 100
    ------------------------------
    -------------------------------------------------
    Modified:
    "/var/www/html"
    "/var/www/html/index.php"

    ------------------------------
    -------------------------------------------------
    Rule Name: Root config files (/root)
    Severity Level: 100
    ------------------------------
    -------------------------------------------------
    Modified:
    "/root"
    "/root/.viminfo"

2013年1月31日 星期四

postfix 分析工具

安裝方式:# yum install postfix-pflogsumm

使用方式:
  • 分析今天:pflogsumm -d today /var/log/maillog
  • 分析昨天;pflogsumm -d yesterday /var/log/maillog
  • 分析全部:pflogsumm /var/log/maillog
  • 分析多檔:pflogsumm /var/log/maillog /var/log/maillog.1
  • 分析 postfix今天的 maillog,並且寄信通知:pflogsumm -d today /var/log/mailllog | mail -s ‘Postfix Maillog Report’ mailAccount


2013年1月10日 星期四

利用 Fail2ban 封鎖暴力破解

前輩丟出個功課找些好方法來自動偵測+阻擋。

Fail2ban 就是一個非常實用的套件!

官方網頁:http://www.fail2ban.org

環境:
  • CentOS release 5.8 (Final)
  • Dovecot 1.0.7
  • Postfix 2.3.3 
  • fail2ban 0.8.4
安裝:# yum -y install fail2ban

若無法安裝,用 # yum search fail2ban 也無法找到套件,需編輯以下資料。

# vim /etc/yum.repos.d/CentOS-Base.repo

[atrpms]
name=Red Hat Enterprise Linux $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/el$releasever-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1
enabled=1





套件架構:
  • 安裝位置:/etc/fail2ban
  • 設定檔:
    •  fail2ban.conf      fail2ban 設定
    •  jail.conf               各服務阻擋參數設定
      2013.03.19 取自官方文件
      Every .conf file can be overridden with a file named .local. The .conf file is read first, then .local, with later settings overriding earlier ones. Thus, a .local file doesn't have to include everything in the corresponding .conf file, only those settings that you wish to override.
      因此有任何客製化的設定,要另外建立 jail.local
    • filter.d/*. conf       過濾規則、判斷式 
  • jail.conf 內的各個設定,必須在filter.d有一個對應的 conf 檔案。
    例如:在 jail.conf內新增 [dovecot-check] 設定,且filter設為 dovecot-check,那就必須在 filter.d資料夾新增 dovecot-check.conf
 fail2ban.conf 設置說明:
  • 沒什麼特別的地方,重點放在log設置位置
    logtarget = /var/log/fail2ban.log
 jail.local 設置說明:
  • 主要為各個需要偵測的服務設定。
  • 範例:
    新增 dovecot-check 設定
    [dovecot-check]
    enabled = true
    #過濾名稱,對應filter.d/*.conf 
    filter = dovecot-check 
    #iptables設定 
    action =  iptables-multiport[name=dovecot-check, port="pop3,pop3s,imap,imaps",  protocol=tcp]
              sendmail-whois[name=dovecot, dest=xxx@example.com, sender=xxx@example.com] 
     
    #需要掃描的記錄檔
    logpath = /var/log/secure
    #排除的ip、網域
    ignoreip = 168.192.0.1  192.168.1.0/24
    #阻擋的時間,-1表示永久阻擋 
    bantime  = 86400
    #監視的log時間區段
    findtime  = 300
    #最高嘗試錯誤次數
    maxretry =  3
    其中部份參數說明如下:
    • action中的port:可直接打上標準的服務名稱或是port number。
    • sendmail-whois中的dest:預設是寄到 root ,也就是本機端的root帳戶的信箱。
    • sendmail-whois中的sender:這個設定會顯示在寄信的來源位置,預設是 fail2ban@mail.com 。
      sendmail-whois 可省略。
    • logpath:mail log預設值是 /var/log/secure。每個Linux發行版的服務記錄登入訊息的位置都不太一樣,dovecot會將訊息記錄在 /var/log/secure ,因此參數必須設置成此路徑。
    • maxretry:最高嘗試錯誤次數。一旦登入錯誤超過這個次數,fail2ban就會發生阻擋事件,將該IP擋在門外。預設是使用 [DEFAULT] 區塊中的maxretry ,可另外在這邊重新指定。實際上,嘗試登入時可以比maxretry還多一次,例如maxretry = 3,那麼登入時可以錯誤4次才會被擋下。
    • bantime:發生阻擋事件之後,阻擋該IP的時間。預設是用 [DEFAULT] 區塊中的 bantime ,單位是秒,也就是10分鐘。但是這個阻擋時間實在太短,有人設定為 86400,也就是一整天。若設定為 -1 ,表示永久阻擋。
filter.d/*. conf設置說明:
  • 比照 jail.local 的設定,由於新增了 dovecot-check,因此也在 filter.d資料夾新增 dovecot-check.conf
  •  dovecot-check.conf 內容範例:
    [Definition]
    #掃描log檔時的過濾規則
    failregex =  (?: Authentication failure|Aborted login|Disconnected).*rip=(?:::f{4,6}:)?(?P<host>\S*),
    .*
    #排除部份
    ignoreregex  = (?: Disconnected: Logged out).*
    • failrege:可自行使用正規表示式修改成需要的內容(由於小弟不熟,直接套用網路上的設定後再做測試)

測試 filter 內設定是否正確:
  • fail2ban-regex [log路徑] [filter路徑]
    fail2ban-regex /var/log/dovecot.log /etc/fail2ban/filter.d/dovecot-check.conf 
啟動 fail2ban 的服務:
  •  service fail2ban start
    {start|stop|status|restart}
重新載入 fail2ban 的設定:
  • fail2ban-client reload
查看iptable的設定:
  • iptables –L
查看 fail2ban 的狀態:
  • fail2ban-client status 
查看某服務過濾情況:
  • fail2ban-client status [jail.conf 設定的名稱]
    fail2ban-client status dovecot-check
 設定 fail2ban 開機時自動啟動:
  • chkconfig fail2ban on


補充說明:
  • 如果在 dovecot 有另外指定log位置,jail.local內的設定要指到相對應的log。
  • dovecot 會將登入失敗的訊息會放在 /var/log/secure /var/log/maillog(預設) 內,2邊都做測試會比較保險。



參考:

2012年10月22日 星期一

postfix 查看、刪除佇列郵件

參考官方說明:http://www.postfix.org/postqueue.1.html

POSTQUEUE(1)                                                      POSTQUEUE(1)

NAME
       postqueue - Postfix queue control

SYNOPSIS
       postqueue [-v] [-c config_dir] -f
       postqueue [-v] [-c config_dir] -i queue_id
       postqueue [-v] [-c config_dir] -p
       postqueue [-v] [-c config_dir] -s site

--以下略--


官方上面只有這些參數,但是網路上一堆轉貼都是說

看被Queue的信:
postqueue -q
強迫將Queue信寄出:
postqueue -f
刪除所有被Queue的信:
postsuper -d ALL
刪除某封Queue的信:
postsuper -d queue_id
刪除所有正在 deferred 佇列中的郵件 ( 刪除曾經發送失敗的信 ):
postsuper -d ALL deferred
是版本的問題嗎?

不管他...

從 postfix 官方說明:http://www.postfix.org/qmgr.8.html
可查到佇列相關資訊。

另外也有人整理好相關資訊:

※ Mail Queue 所在的目錄 
/var/spool/mqueue
/var/spool/postfix -- 底下列出 postfix 的子目錄

 》active
  目前正在準備發送的信件。(在 message id 後會多加一個 * 號)
Messages  that  the  queue  manager  has opened for delivery. Only a  limited  number  of  messages  is allowed  to  enter  the  active queue (leaky bucket strategy, for a fixed delivery rate).

 》bounce
  每一位收件者的傳送狀態,並記載為何會被退信
Per-recipient status information about why mail  is bounced.    These   files  are  maintained  by  the bounce(8) daemon.

 》corrupt
  信件損毀導致無法傳送的信件
Unreadable  or  damaged  queue files are moved here for inspection.
 》defer
   暫時無法被傳送的信件,並記載為何會被延遲傳送。這種情形最常發生在你的 Mail Server 被列入灰名單(GrayList)的時候,你會看到訊息為「 Your access to this mail system has been rejected due to the sending MTA's poor reputation. If you believe that this failure is in error, please contact the intended recipient via alternate means.」
Per-recipient status information about why mail  is delayed. These files are maintained by the defer(8) daemon.

 》deferred
  無法被傳送的信件會放置在此目錄,但 Mail Server 還是會嘗試幫你繼續送,只是必須等 Backoff time。
Mail that could not be  delivered  upon  the  first attempt.  The  queue manager implements exponential backoff  by  doubling  the  time  between  delivery attempts.

 》hold
  被暫時停止發送的信件,如要發送出去,需要由手動(在 message id 後會多加一個 ! 號)
Messages that are kept  "on  hold"  are  kept  here until someone sets them free.

 》incoming
  從外部或本地寄送到本機的信件。
Inbound mail from the network, or mail picked up by the local pickup(8) daemon from the maildrop directory.
 知道這些就好辦了,直接到相對應的資料夾把信刪掉即可。


參考:Postfix Mail Queue - 一些簡單的管理指令





2012年10月8日 星期一

ssh斷線後,利用screen套件恢復被中斷的作業


參考來源:

使用 GNU Screen 回復被中斷的遠端存取作業階段
SSH 斷線了怎麼辦?沒關係,還有 Screen 幫你保留! 


套件:
screen

使用:

#screen 開啟一個新的作業階段,如果連線中斷,此作業階段依舊會被保留住。

檢視工作階段列表:
$ screen -ls
There are screens on:
        13454.pts-2.mail        (Attached)
        13670.pts-4.mail        (Detached)
2 Sockets in /var/run/screen/S-zongyan..

其中,13670.pts-4.mail        (Detached)代表中斷的作業階段。
 復原作業階段:
#screen -r [作業階段識別號]
例如:
#screen -r 13670.pts-4.mail
切換到Attached的作業階段:
#screen -d -r [作業階段識別號]
例如:
#screen -d -r 13454.pts-2.mail
離開作業階段方式:
#exit

2012年4月24日 星期二

利用newsyslog製作log循環備份

newsyslog 是安裝 freebsd 後就會有的套件,其主要功用是配合crontab排程,將log製作備份。

參考:
http://www.weithenn.org/cgi-bin/wiki.pl?newsyslog.conf
http://contest.ks.edu.tw/syshtml/freebsd-newsyslog.html

補充:
 
     ※要是我們要新加入的一些非預設的,程式(例如www)所產生的紀錄檔怎麼辦?
         /var/log/httpd-access.log         640    5    *    @T00     Z /var/run/httpd.pid 30
         /var/log/httpd-error.log          640    5    *    @T00     Z /var/run/httpd.pid 30
 
         第一欄是紀錄檔的位置, 第二欄是紀錄檔的權限 (mode),5 表示在硬碟
         內保留過去六次處理的紀錄(log.0.gz~ log.5.gz), 比六次還舊的紀錄
         就把他砍了。* 表示不管紀錄檔的大小。 @T00 表示每天零點零分的時候
         處理這個檔案,Z 表示把處理過的檔案壓縮起來, 節省空間。
         
   
     ※為什麼後面要加上/var/run/httpd.pid 30?
         因為 newsyslog 在系統 default 的 contable (/etc/crontab) 裡被預先
         設定為每一個小時啟動一次,然而在 newsyslog.conf 裡設定讓 apache log
         自動 rotate,不過發現 newsyslog 後接下來的 apache log 都不會寫入了,
         只留下一行 newsyslog[66253]: logfile turned over
         這個問題出在當 newsyslog rotate log之後,沒有送個 SIGHUP 給 apache,
         導致 apache的log 寫到不知道什麼地方去,所以要在 newsyslog.conf 裡面
         有關 httpd-access.log 及 httpd-error.log 的部份後面加上要 KILL -HUP
         的 pid 檔,才能正常運作。 
 
==== 20120425 ====

為什麼httpd.pid的sig_num 要設定為30? 不能設定其他值嗎?


 
hwakeye  在下面有作解釋
===== 
 
 
flags   This optional field is made up of one or more characters that
             specify any special processing to be done for the log files
             matched by this line.  The following are valid flags:

             B       indicates that the log file is a binary file, or has some
                     special format.  Usually newsyslog(8) inserts an ASCII
                     message into a log file during rotation.  This message is
                     used to indicate when, and sometimes why the log file was
                     rotated.  If B is specified, then that informational mes-
                     sage will not be inserted into the log file.

             C       indicates that the log file should be created if it does
                     not already exist, and if the -C option was also speci-
                     fied on the command line.

             D       indicates that newsyslog(8) should set the UF_NODUMP flag
                     when creating a new version of this log file.  This
                     option would affect how the dump(8) command treats the
                     log file when making a file system backup.

             G       indicates that the specified logfile_name is a shell pat-
                     tern, and that newsyslog(8) should archive all filenames
                     matching that pattern using the other options on this
                     line.  See glob(3) for details on syntax and matching
                     rules.

             J       indicates that newsyslog(8) should attempt to save disk
                     space by compressing the rotated log file using bzip2(1).

             N       indicates that there is no process which needs to be sig-
                     naled when this log file is rotated.

             U       indicates that the file specified by path_to_pid_file
                     will contain the ID for a process group instead of a
                     process.  This option also requires that the first line
                     in that file be a negative value to distinguish it from a
                     process ID.

             Z       indicates that newsyslog(8) should attempt to save disk
                     space by compressing the rotated log file using gzip(1).

             -       a minus sign will not cause any special processing, but
                     it can be used as a placeholder to create a flags field
                     when you need to specify any of the following fields.

架設LogAnalyzer 網頁日誌分析工具

,這幾天因為看了網管人雜誌在介紹「LogAnalyzer 網頁日誌分析工具」,上網搜尋了一下發現該篇文章作者 Weithenn ,已將文章同步放置在網站上:
http://www.weithenn.org/cgi-bin/wiki.pl?LogAnalyzer_網頁日誌分析工具_(上)
http://www.weithenn.org/cgi-bin/wiki.pl?LogAnalyzer_網頁日誌分析工具_(下)

由於尚未熟悉freebsd的apache,藉由此次機會順便跑一次 apache+php的安裝

這邊要注意的是:
apache的位置可能與教學不同 ,例如本次架設是freebsd 8.1 + Apache 2.2.15。
apache的一些路徑如下:
  • /usr/local/etc/apache22                   // apache安裝位置
  • /usr/local/etc/rc.d/apache22           // start、stop…
  • /usr/local/www/apache22/data       // 網站預設根目錄
其他則與教學相同

=====
20120425 補充:
log必須確認可以讓 LogAnalyzer 讀取,例如:檔案權限為 644


2012年3月23日 星期五

安裝sudo

# cd /usr/ports/security/sudo
# make install clean

設定檔的位置在
/usr/local/etc/sudoers
設定的方法,指定某個帳號可以使用全部權限:
帳號 ALL=(ALL) ALL
指定某個群組的使用者都有權限:
%wheel ALL=(ALL) ALL

freebsd安裝vim

使用ports安裝

# cd /usr/ports/editors/vim-lite/
# sudo make install clean

安裝完畢後即可使用vim指令,若要將vim取代vi

# alias vi='vim'

另外,由於安裝時並不會產生設定檔,需自行由安裝目錄複製
# cp /usr/local/share/vim/vim73/vimrc_example.vim /usr/local/share/vimrc

在freebsd上使用locate

基本上,安裝完locate之後,需要先建立索引檔案,否則會無法搜尋
在以往使用ubuntu時,只要直接下 updatedb 即可,但是在freebsd裡面,則是執行
 /usr/libexec/locate.updatedb

一般來說,不需要特別去執行updatedb,系統會例行更新。

* 執行時需以root權限執行

2012年3月22日 星期四

調整freebsd更新套件(ports)來源

 http://www.24m.org/wordpress/?p=258

編輯 /etc/make.conf ,如果沒有就做個新的吧。
內容如下:
KERNCONF=MYBSD
SUP_UPDATE= yes
SUP= /usr/local/bin/cvsup
SUPHOST= cvsup.tw.FreeBSD.org
SUPFILE= /usr/share/examples/cvsup/stable-supfile
PORTSSUPFILE= /usr/src/share/examples/cvsup/ports-supfile
接下來,到 /usr/src 或是 /usr/ports 底下,下
make update
然後就去喝茶吃蛋糕等吧。(通常cvsup server會限制連進來的連線數,所以一次就抓一個就好)
更新了ports tree後,要make新東西,都得到國外去抓,所以要讓抓取速度快,就得改一下make.conf,讓系統就進在台灣抓就好啦。
# for make install
MASTER_SITE_BACKUP?= \
ftp://ftp.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp2.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp3.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp4.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp5.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp7.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp8.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/\
ftp://ftp9.tw.freebsd.org/pub/FreeBSD/distfiles/${DIST_SUBDIR}/
MASTER_SITE_OVERRIDE?= ${MASTER_SITE_BACKUP} MASTER_SORT_REGEX= \.tw/ \.tw\. \.edu/ \.edu\. FETCH_CMD=fetch -U -A -P
7.1上是work的。

Freebsd 和套件有關的指令

Freebsd 和套件有關的指令 無次要群組
作者或來源 瘦河馬 2009-10-27 15:52:24
關鍵字 1freebsd 2port
此文完整連結 http://note.tc.edu.tw/179.html

Freebsd 套件和套件有關的指令
Freebsd 有著極棒的套件管理方式,讓使用者一點也不會覺得麻煩和混亂。
在 Freebsd 上的套件(packages)要如何安裝,可以自行下載檔案解壓編譯,或是利用 ports,什麼是 ports?
在網路上諸多的套件,經安裝及測試沒問題後,將其依編譯時所需的組態設定、編譯程序及安裝程序以固定的格式擺在一起,並經 Freebsd 維護小組認可後即加入 ports 的集合中。當安裝完 freebsd 後(或同時),可以選擇安裝 ports 的集合,如此未來若有套件想安裝,只要進到  /usr/ports/ 一陣亂找後,就能找到想要的套件了。
一、安裝 ports 的集合(ports tree/ports collection)
# sysinstall
Configure --> Distributions -->ports 然後選擇 install,可以丟入 cd或dvd,讓他由光碟片安裝,要花滿久的時間,至少一個小時,可以先去喝杯茶。
二、用ports安裝套件的方法
安裝完 ports 的集合之後,未來要用 ports 安裝套件就像吃飯一樣簡單
例如要安裝 mysql 6.0
# cd /usr/ports/databases/mysql60-server/
# make install
如此會產生一個 work/ 的資料夾,裡面有下載回來的套件,如果要安裝完畢後刪除下載檔,加一個'clean' 即可
# make install clean
三、有關套件的指令:
安裝好的套件在 /var/db/pkg
查看套件資訊 # pkg_info -L <== -L可看版本
加入套件 # pkg_add 套件名
刪除套件 # pkg_delete 套件名 <==套件名必需完整。
查看套件相依性 # pkg_tree <==請ports sysutils/pkg_tree安裝
看現在版本和/usr/ports中的版本比較 # pkg_version -v
四、維持ports 集合的更新
ports 的集合也需要更新,以取得新的套件及/usr/src的原始碼更新,更新 ports tree 的方法很簡單,可以使用 CVSup 來保持 ports 在最新狀態。
CVSup 是一套用來維持軟體原始碼和開發團隊同步的工具,它會經由網路向所設定的軟體伺服器檢查並更新原始碼的版本。我們可以使用 CVSup 來更新 port tree,也可以用來更新 /usr/src 目錄下的 FreeBSD 原始碼。
安裝 CVSup,因為我們不使用圖形介面,所以安裝 cvsup-without-gui
# cd /usr/ports/net/cvsup-without-gui
# make install
完成後,在系統中有一份以 CVSup 更新 port tree 的設定檔範例,可以直接加以修改或著先複製一份後再修改。我們將該設定檔範例複製到 /root 之後再加以修改:
# cp /usr/share/examples/cvsup/ports-supfile /root/
修改 /root/ports-supfile 所要使用的 CVSup 伺服器:
*default host=cvsup.tw.freebsd.org
設定完畢之後,就可以開始進行 ports 的更新了
# cvsup -g -L 2 /root/ports-supfile 上述指令中,參數 g 表示不使用圖形介面,而參數 L 及其後所跟隨的數字 2 表示我們要看到更新過程的記錄的詳細程度,數字可以從 0 ~ 2,最後的檔名表示所要使用的設定檔。
這樣就能維持 ports tree 的更新。
五、現有套件的更新
現有套件可使用以下指令來查看是否有更新
# pkg_version -v
倘若有較新版本的套件想更新時,可以先移除舊的再安裝新的,但這樣不是很方便,所以可以使用portupgrade來更新
安裝portupgrade
# cd /usr/ports/ports-mgmt/portupgrade
# make install
安裝完畢後,未來要更新套件,就到ports中套件的目錄下 portupgrade 指令即可
安裝完套件記得要執行 rehash 才會生效,否則要重新登入。