2012年7月27日 星期五

2012年7月26日 星期四

FreeBSD中讓apache不顯示版本

修改 /usr/local/etc/apache22/extra/httpd-default.conf
本來
ServerTokens Full
ServerSignature On
改為
ServerTokens Prod
ServerSignature Off


測試
測試方式  telnet 192.168.1.1 80
輸入 HEAD / HTTP/1.0

HTTP/1.1 200 OK
Date: Thu, 26 Jul 2033 03:58:45 GMT
Server: Apache/2.2.22 (FreeBSD) mod_ssl/2.2.22 OpenSSL/1.0.1a DAV/2
Last-Modified: Fri, 18 Jul 2003 06:52:30 GMT
ETag: "621cea-182-3c2b5d5162780"
Accept-Ranges: bytes
Content-Length: 386
Connection: close
Content-Type: text/html

隱藏版本後
HTTP/1.1 200 OK
Date: Thu, 26 Jul 2033 04:20:26 GMT
Server: Apache
Last-Modified: Fri, 18 Jul 2003 06:52:30 GMT
ETag: "621cea-182-3c2b5d5162780"
Accept-Ranges: bytes
Content-Length: 386
Connection: close
Content-Type: text/html

2012年7月25日 星期三

查詢遠端網頁伺服器版本

telnet 主機IP/Domain service port
輸入 HEAD / HTTP/1.0 按下Enter

ex:
c:\> telnet 192.168.1.1 80
HTTP/1.1 200 OK
Date: Thu, 26 Jul 2012 03:58:45 GMT
Server: Apache/2.2.22 (MyOS) mod_ssl/2.2.22 OpenSSL/1.0.1a DAV/2
Last-Modified: Fri, 18 Jul 2003 06:52:30 GMT
ETag: "621abc-182-3c2b5d5162780"
Accept-Ranges: bytes
Content-Length: 386
Connection: close
Content-Type: text/html

如何重新安裝透過ports安裝的套件

如何重新安裝透過ports安裝的套件

重新安裝的前提是:之前有安裝過或目前已安裝。以apache22為例
# cd /usr/ports/www/apache22
# make deinstall clean install

portupgrade升級軟體注意事項

升級前後,建議先執行pkgdb -F來修復程式間的關連性。
# pkgdb -F

2012年7月19日 星期四

FreeBSD套件管理工具 pkg

pkg_info  查看目前系統上已安裝那些套件
pkg_info -a 列出目前系統中已經安裝套件及詳細資料
pkg_info -L <套件完整名稱ex: apache-2.2.21 > 列出套件相關檔案清單及安裝路徑
pkg_info -s <套件完整名稱ex: apache-2.2.21 > 列出套件占用磁碟空間

pkg_version -v 與ports tree比對可更新的套件

ex:
# pkg_version -v

GeoIP-1.4.8_1                       =   up-to-date with index
apache-2.2.21                       =   up-to-date with index
apr-ipv6-devrandom-gdbm-db42-ldap24-mysql55-1.4.2.1.3.10  <   needs updating (port has 1.4.5.1.3.12_1)
arpwatch-2.1.a15_6                  =   up-to-date with index
autoconf-2.68                       <   needs updating (port has 2.69)
autoconf-wrapper-20101119           =   up-to-date with port

也可以執行
# pkg_version -v | grep 'v'   只列出需要更新的套件


2012年7月17日 星期二

FreeBSD常見套件管理指令


修復程式間關連性 , 建議軟體有做新增刪除後執行
# pkgdb -F 
--->  Checking the package registry database

查詢目前套件版本及可升級之版本
# pkg_version -v
GeoIP-1.4.8_1                       <   needs updating (port has 1.4.8_3)
apache-2.2.17_1                     <   needs updating (port has 2.2.22_5)
apr-ipv6-devrandom-gdbm-db42-ldap24-mysql55-1.4.2.1.3.10  <   needs updating (port has 1.4.5.1.3.12_1)
arpwatch-2.1.a15_6                  =   up-to-date with port
autoconf-2.68                       <   needs updating (port has 2.69)


備份目前版本套件

ex: 備份目前系統中的apache-2.2.17_1
# pkg_create -b apache-2.2.17_1

使用PortUpgrade來升級PortUpgrade套件



先更新ports tree
# portsnap update
若失敗則改先執行下列指令
# portsnap fetch update

未來更新ports tree只要執行下列指令即可
# portsnap update

確認ports tree已有更新
# more /usr/ports/UPDATING
可查看有沒有最近release的最新update資訊

-----UPDATING 部份內容-----

20120717:
  AFFECTS: users of ftp/proftpd
  AUTHOR: mm@FreeBSD.org

-----UPDATING 部份內容結束-----


開始進行portupgrade套件更新
# portupgrade portupgrade

升級完後會看到下列資訊
===>   Running ldconfig
/sbin/ldconfig -m /usr/local/lib/compat/pkg
===>   Installing ldconfig configuration file
===>   Registering installation for portupgrade-2.4.9.5,2
===>  Cleaning for portupgrade-2.4.9.5,2
--->  Cleaning out obsolete shared libraries
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... - 151 packages found (-0 +1) . done]

檢查目前portupgrade版本
pkg_version -v | grep portupgrade

portupgrade-2.4.9.5,2               =   up-to-date with port

升級完後建議執行"pkgdb -F"修復程式間關連性
# pkgdb -F 
--->  Checking the package registry database

Freebsd 使用portsnap 更新ports Tree

使用portsnap更新ports Tree

若是第一次更新ports Tree
# portsnap fetch extract
# portsnap update
更新ports Tree
# portsnap fetch update

查看ports Tree更新狀況
# less /usr/ports/UPDATING

內容中可看到最新近的更新資訊

20120716:
  AFFECTS: users of www/lighttpd
  AUTHOR: mm@FreeBSD.org

  The following port options have been reorganized:
  The OPENLDAP option has been renamed to LDAP.
  The MAGNET and CML options have been withdrawn in favor of new LUA option.