pkg_delete pkg-config-0.25_1 出錯 可以強制刪除

執行刪除時因為相依性無法執行:
# pkg_delete pkg-config-0.25_1
pkg_delete: package ‘pkg-config-0.25_1’ is required by these other packages
and may not be deinstalled:
libstatgrab-0.17
freecolor-0.8.8
xproto-7.0.22
libxslt-1.1.26_3
libpthread-stubs-0.3_3
libXau-1.0.6
libXdmcp-1.1.0
libxcb-1.7

強制刪除並重新安裝新版的套件:
pkg_delete -f pkg-config-0.25_1
cd /usr/ports/devel/pkgconf
make install clean

FreeBSD install LAMP Server

===================================
1. 安裝 MySQL ~ 設定編碼為 unicode
===================================
# cd /usr/ports/databases/mysql50-server
# make WITH_CHARSET=utf8 WITH_XCHARSET=all WITH_COLLATION=utf8_unicode_ci BUILD_OPTIMIZED=yes install clean

安裝好之後,我們要產生 MySQL 一開始所要用的 Database,預設會裝在 /var/db/mysql 裡 ( 若不想裝在預設的地方,安裝時下參數 –localstatedir=/path/to/your/location )
# rehash
# mysql_install_db

複製 MySQL 的系統設定檔到 /etc 下
# cp /usr/local/share/mysql/my-xxx.cnf /etc/my.cnf

設定 MySQL 資料庫權限,並且啟動它
# chown -R mysql:mysql /var/db/mysql
# echo “mysql_enable=yes” >> /etc/rc.conf
# /usr/local/etc/rc.d/mysql-server start

設定 MySQL Root 的密碼
# mysqladmin -u root password 新密碼

若是更新舊的版本,就稍微注意一下
Remember to run mysql_upgrade (with the optional –datadir=<dbdir> flag) the first time you start the MySQL server after an upgrade from an earlier version.

最後我們可以測試登入一下 MySQL,有出現以下畫面就 OK
# mysql -u root -p
Enter password: (請輸入密碼)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.60-log FreeBSD port: mysql-server-5.1.60
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

===================================
2. 安裝 Apache
===================================
# cd /usr/ports/www/apache22
# make install clean

===================================
3. 安裝 PHP
===================================
# cd /usr/ports/lang/php5
# make config install clean

記得要勾選此選項喔,不然 Apache 會不認得 PHP
APACHE Build Apache module

再安裝 PHP Extensions
# cd /usr/ports/lang/php5-extensions
# make config install clean

建議加勾選 GD、MYSQL、MySQLI、MBSTRING、ZIP 和 ZLIB

===================================
4. 修改設定檔
===================================
首先設定 PHP 的設定檔,以後就是設定 php.ini 這檔
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

修改 Apache 的設定
# vi /usr/local/etc/apache22/httpd.conf

在最上面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

找到
DirectoryIndex index.html
把它變成
DirectoryIndex index.php index.html index.htm

設定一開機啟動 Apache & MySQL
# vi /etc/rc.conf

加入這三行
apache22_enable="YES"
apache22_http_accept_enable="YES"
mysql_enable="YES"

在 /usr/local/www/apache22/data 裡新增一個檔案叫 index.php,內容如下
<?php phpinfo(); ?>

FreeBSD 9.0 install Nagios 3.4.1

更新 package-tree :
//如果是第一次更新取得 package-tree
# portsnap fetch ; portsnap extract ; portsnap update ;
//之後僅需要 fetch 和 update
# portsnap fetch ; portsnap update ;

安裝 nagios :
# cd /usr/ports/net-mgmt/nagios
# make ; make install ; // 首次安裝 nagios
# make ; make deinstall ; make reinstall //先前已安裝過 nagios

設定 nagios :

//切換至 nagios 設定檔目錄下
# cd /usr/local/etc/nagios
//將範例設定檔更名為正確設定檔名稱
# cp cgi.cfg-sample cgi.cfg ; cp nagios.cfg-sample nagios.cfg ; cp resource.cfg-sample resource.cfg

//切換至 nagios/objects 物件設定檔放置的目錄下
# cd /usr/local/etc/nagios/objects
//將其中的範例設定檔更名為正確的設定檔名稱
# cp commands.cfg-sample commands.cfg ; cp contacts.cfg-sample contacts.cfg ; cp printer.cfg-sample printer.cfg ; cp templates.cfg-sample templates.cfg ; cp localhost.cfg-sample localhost.cfg ; cp switch.cfg-sample switch.cfg ; cp timeperiods.cfg-sample timeperiods.cfg

允許 Freebsd 可以啟動 nagios:
//編輯 /etc/rc.conf 加入 「nagios_enable="yes"」 字串於檔案中
# echo nagios_enable="YES" >> /etc/rc.conf

啟動 nagios 服務:
# /usr/local/etc/rc.d/nagios start

安裝 LAMP :
//MySQL 安裝
# cd /usr/ports/databases/mysql50-server
# make WITH_CHARSET=utf8 WITH_XCHARSET=all WITH_COLLATION=utf8_unicode_ci BUILD_OPTIMIZED=yes install clean

安裝好之後,我們要產生 MySQL 一開始所要用的 Database,預設會裝在 /var/db/mysql 裡 ( 若不想裝在預設的地方,安裝時下參數 –localstatedir=/path/to/your/location )
# rehash
# mysql_install_db

複製 MySQL 的系統設定檔到 /etc 下
# cp /usr/local/share/mysql/my-xxx.cnf /etc/my.cnf

設定 MySQL 資料庫權限,並且啟動它
# chown -R mysql:mysql /var/db/mysql
# echo “mysql_enable=yes” >> /etc/rc.conf
# /usr/local/etc/rc.d/mysql-server start

設定 MySQL Root 的密碼
# mysqladmin -u root password 新密碼

若是更新舊的版本,就稍微注意一下
Remember to run mysql_upgrade (with the optional –datadir=<dbdir> flag) the first time you start the MySQL server after an upgrade from an earlier version.

最後我們可以測試登入一下 MySQL,有出現以下畫面就 OK
# mysql -u root -p
Enter password: (請輸入密碼)
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.60-log FreeBSD port: mysql-server-5.1.60
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql>

安裝 Apache :
# cd /usr/ports/www/apache22
# make install clean

安裝 php
# cd /usr/ports/lang/php5
# make config install clean

記得要勾選此選項喔,不然 Apache 會不認得 PHP
APACHE Build Apache module

再安裝 PHP Extensions
# cd /usr/ports/lang/php5-extensions
# make config install clean

建議加勾選 GD、MYSQL、MySQLI、MBSTRING、ZIP 和 ZLIB

修改設定檔:
首先設定 PHP 的設定檔,以後就是設定 php.ini 這檔
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

修改 Apache 的設定
# vi /usr/local/etc/apache22/httpd.conf

在最上面加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

找到
DirectoryIndex index.html
把它變成
DirectoryIndex index.php index.html index.htm

設定一開機啟動 Apache & MySQL
# vi /etc/rc.conf

加入這三行
apache22_enable="YES"
apache22_http_accept_enable="YES"
mysql_enable="YES"

FreeBSD expand partition size with gpart

FreeBSD expand partition size with gpart

It’s not necessary to use this nowadays.
From Freebsd 8.3 (or you can just boot live cd of bsd 9) you can do

gpart show (remember the extendable partition)
gpart resize -i index_of_partition geom
gpart resize -i index_of_partition geom_slice
growfs geom_slice_partition

maybe must to do fsck_ufs /dev/partition or reboot system

why use uname -ra show version different use cat /var/db/freebsd-update/tag

I think you are right about am running p5:

garfield ~ # cat /var/db/freebsd-update/tag
freebsd-update|amd64|8.2-RELEASE|5|d500db1fa58e4ad4f33a16ce5c61dcef9c039a96eaadbb97d217881fbe2508b8|1343779200

But I think its strange when i type:

garfield ~ # uname -mrs
FreeBSD 8.2-RELEASE-p3 amd64

It says I’m running p3?

If you want to see right patch level (shown by uname); do recompile system kernel (GENERIC). Short howto;

cd /usr/src
make buildkernel
make installkernel
reboot

uname -mrs

Howto Installing FreeBSD 9 source

Howto Installing FreeBSD 9 source

1. Download the tar file that matches the version you installed.
i386: ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/9.0-RELEASE/src.txz
amd64: ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/9.0-RELEASE/src.txz

Unpack the archive to /usr/src:
# tar -C / -xvzf src.txz

Be aware that this will only get you the code for FreeBSD-9.0-RELEASE, not anything that has been added since then.

2. svn(1)
SVN (Subversion) is a newer source control system. It is not part of the base system, so install devel/subversion. Then check out the source:
# svn checkout svn://svn.freebsd.org/base/releng/9.0/ /usr/src
Other versions will have different URLs, like svn://svn.freebsd.org/base/stable/9/ for 9-STABLE. svn includes a larger history and can take up to twice the amount of disk space as a CVS checkout.

See the Handbook SVN mirror list for alternate servers which may be faster for you.

Speed up FreeBSD KVM guests using Virtio Drive

Virtio has been around for a while in Linux but it’s still fairly new on FreeBSD, with support only arriving in versions 8.2 and 9.0. That’s something of a shame since tools like virt-manager make piss-poor default choices when creating FreeBSD guest VM’s. Like configuring PIO-only IDE controllers from the early 90’s, limited at 16MB/s throughput.. savages! If you do have a capable version of FreeBSD, loading virtio drivers certainly is worth the effort.

The first step after installing FreeBSD 9 would be to get your system up to date. I use freebsd-update for that, as it works a lot faster than compiling the whole OS from source for a minor patch.

#freebsd-update fetch
#freebsd-update install

These commands bring your system up to date, but you’ll need to have the system sources in place in order to build the virtio kernel modules. These modules are still experimental so they aren’t in the base system yet. In order to install them you need to install the emulators/virtio-kmod port. First we pull in sources.

#cp /usr/share/examples/cvsup/standard-supfile /root

In the resulting /root/standard-supfile you should look for the part where it says CHANGE_THIS, and modify that into a valid FreeBSD cvsup server. I always change it into cvsup.nl.freebsd.org but your mileage may vary.

#cd /root
#csup ./standard-supfile

The above commands start the download of all the system sources. They’ll end up in /usr/src/sys and weigh in at about 200MB so make sure you have enough room to store them.

Now you have everything you need to build the virtio modules. From /usr/ports/emulators/virtio-kmod you run the usual commands to install a port:

#make
#make install
#make clean

This takes a while as it copies tons of source files from /usr/src/sys into the port’s work directory, which is why the make clean at the end is important to save you some disk space. These steps give you compatible kernel modules for loading. Now make sure you actually load them at system startup by adding them to /boot/loader.conf like so:

virtio_load="YES"
virtio_pci_load="YES"
virtio_blk_load="YES"
if_vtnet_load="YES"

Apparently you can pick and choose which drivers to use, but I have yet to find a reason not to simply use all of them.

Before any of the virtio magic will work, you’ll need to tell FreeBSD to actually use it for its network driver and block devices. By default the virt-manager tool sets up any FreeBSD VM with an emulated Intel gigabit network card, which FreeBSD recognizes as em0. Add the following line to /etc/rc.conf to rename your virtio network card to em0 and use any existing network settings.

ifconfig_vtnet0_name="em0″

You should also change your /etc/fstab file to use virtio block devices instead of the emulated IDE drives. A line like:

/dev/ada0p2 / ufs rw 1

..would become:

/dev/vtbd0p2 / ufs rw 1

You’re almost done now. Fire up virt-manager on your host machine and modify the emulated hardware in your FreeBSD VM. Choose ‘virtio‘ for both the emulated network device and for each IDE, SATA or SCSI hard disk you emulate.

Finally, shut down the VM (do not reboot it, really shut it down!), virtually power it back up and things should be hunky-dory with FreeBSD gaining some considerable speed in its network and block I/O layers.