Wednesday, August 20, 2008

การติดตั้ง torrentflux บน FreeBSD ผมว่ามันน่าใช้มากครับเพราะมี web interface ด้วยใช้งานง่ายกว่า ctorrent ครับ บทความนี้ผม copy มาจาก http://www.torrentflux.com/forum/index.php/topic,2472.0.html เป็นประสบการณ์ของผู้เขียนมา share กันครับ ต้องขอบคุณเค้าด้วยครับ เพราะไม่ได้เค้าผมก็รันไม่ขึ้นเหมือนกัน

1. Download/ Extract the files
tar -zxf torrentflux_x.x.tar.gz

2. create database/ install tables.
cd torrentflux_x.x
mysql -u root -p
create database torrentflux;
quit
mysql -u root -p torrentflux <>

2.1 check the tables
mysql -u root -p
use torrentflux;
show tables;
quit

จะแสดง tables ออกมาตามนี้ครับ
+-----------------------+
| Tables_in_torrentflux |
+-----------------------+
| tf_cookies |
| tf_links |
| tf_log |
| tf_messages |
| tf_rss |
| tf_settings |
| tf_users |
+-----------------------+
7 rows in set (0.00 sec)


Note: If you are not root, su to superuser now. Note, in FreeBSD, you must be a member of the group 'wheel' to use the 'su' command.

3. Now we are going to copy the required files to the web root, into a folder called 'bt', we'll make Apache own it and then make the Python scripts executeable. Lastly the config file needs to add the MySQL password.
Code:
mkdir /usr/local/www/data/bt
cd html
cp -R * /usr/local/www/data/bt
cd /usr/local/www/data
chown -R www:www bt
cd bt
chmod -R 755 TF_BitTornado
nano config.php

$cfg["db_pass"] = ""; // password for database
ใส่ password ^ ลงไประหว่างเครื่อง "

(ตรงนี้ครับผมติด ถ้าไม่ได้ผู้เขียนนี้คงไม่ได้ใช้แน่ 5555)
4. Now the last thing we need to do is correct the cache limit for 'ps'. We'll do that in two steps, first cahnge it in real time, then modify the startup script so that it is correct on later reboots of the server.
Code:
sysctl kern.ps_arg_cache_limit=1024
echo 'kern.ps_arg_cache_limit=1024' >> /etc/sysctl.conf

5. ก็เป็นเรื่องการ configure apache อาจจะทำ alias หรือจะทำเป็น domain ก็ตามใจครับ แต่ผมเลือกทำ alias ครับ ง่ายที่สุด ส่วนวิธีทำหาดูตาม net ครับไม่ยาก

Friday, August 15, 2008

คำสั่งเกี่ยวกับ ports

ติดตั้ง cvsup ก่อนเลย
#cd /usr/ports/net/cvsup-without-gui
#make install && make clean

ติดตั้งโปรแกรม fastest_cvsup จาก ports
# cd /usr/ports/sysutils/fastest_cvsup/
# make install clean
#rehash

การใช้งานโปรแกรม
# fastest_cvsup -help

เช่น
# fastest_cvsup -c uk,fr,de,th,jp
หรือ
# fastest_cvsup -c all


ทำการ synchronize ports index กับ cvsup server โดยใช้ cvsup จาก fastest_cvsup
#/usr/local/bin/cvsup -g -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/ports-supfile

ติดตั้ง portupgrade
#cd /usr/ports/sysutils/portupgrade
#make install && make clean

ทำการอัพเดท ports database
#/usr/local/sbin/portsdb -Uu

#cd /usr/ports && make fetchindex



ทำการ auto fix package database
#/usr/local/sbin/pkgdb -aF

ค้นหาซอฟท์แวร์ต่างๆที่เคยถูกติดตั้งแล้วใน ports เพื่อทำการอัพเดท จะว่าไปแล้วข้อนี้ไม่ต้องทำก็ได้เพราะพึ่งจะติดตั้ง freebsd ใหม่
#/usr/local/sbin/portversion -v

รีบูตเครื่องใหม่
#shutdown -r now
*********ref. จาก http://www.thaibsd.com/webboard/show.php?Category=thaibsd&No=4485

Install software ผ่าน ports
#portinstall -R [package name]

ในกรณีที่ต้องการใส่ค่า configure เพิ่มเติม
#portinstall -R -m [configure] [package name]

upgrade software ผ่าน ports
#portupgrade -R [package name]

หรือ
#portupgrade -f -R -m [configure] [package name]

แสดง version ของ package ที่ install อยู่ในเครื่อง
#portversion -v [package name]
เปลี่ยน ข้อความของ Version kernel เองใน sysinstall

#sysinstall
เลือก Configure
เลือก Options
เลือก Release Name
กด Space bar แล้วเปลี่ยนเป็น Version ที่ต้องการ

**** ใช้ได้เฉพาะ การทำงานของ sysinstall เท่านั้น พอออกมาก็จะเป็น version เดิม ไม่มีผลต่อระบบ********

การ upgrade FreeBSD จาก Version เก่าเป็น Version ใหม่

ที่ผมเขียนบทความนี้ ผมจะทำการ upgrade FreeBSD จาก Version 7 RC1 เป็น 7 RELEASE
โดยใช่คำสั่ง freebsd-update
=========================================================
# freebsd-update -h
usage: freebsd-update [options] command ... [path]

Options:
-b basedir -- Operate on a system mounted at basedir (default: /)
-d workdir -- Store working files in workdir (default: /var/db/freebsd-update/)
-f conffile -- Read configuration options from conffile (default: /etc/freebsd-update.conf)
-k KEY -- Trust an RSA key with SHA256 hash of KEY
-r release -- Target for upgrade (e.g., 6.2-RELEASE)
-s server -- Server from which to fetch updates (default: update.FreeBSD.org)
-t address -- Mail output of cron command, if any, to address (default: root)

Commands:

fetch -- Fetch updates from server
cron -- Sleep rand(3600) seconds, fetch updates, and send an
email if updates were found
upgrade -- Fetch upgrades to FreeBSD version specified via -r option
install -- Install downloaded updates or upgrades
rollback -- Uninstall most recently installed updates
=========================================================
Exemple: freebsd-update -f /etc/freebsd-update.conf -r 7.0-RELEASE upgrade
=========================================================

serverA#uname -a
FreeBSD xxx.xxx.co.th 7.0-RC1 FreeBSD 7.0-RC1 #0: Mon Dec 24 12:18:24 UTC 2007 root@logan.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386

serverA# locate freebsd-update.conf
/etc/freebsd-update.conf
/usr/share/examples/etc/freebsd-update.conf
/usr/share/man/man5/freebsd-update.conf.5.gz

serverA# freebsd-update -f /etc/freebsd-update.conf -r 7.0-RELEASE upgrade
Looking up update.FreeBSD.org mirrors... 1 mirrors found.
Fetching metadata signature for 7.0-RC1 from update1.freebsd.org... done.
Fetching metadata index... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic src/sys world/base world/dict world/doc world/games
world/info world/manpages

The following components of FreeBSD do not seem to be installed:
src/base src/bin src/cddl src/compat src/contrib src/crypto src/etc
src/games src/gnu src/include src/krb5 src/lib src/libexec src/release
src/rescue src/sbin src/secure src/share src/tools src/ubin src/usbin
world/catpages world/proflibs

Does this look reasonable (y/n)?y
Fetching metadata signature for 7.0-RELEASE from update1.freebsd.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Fetching files from 7.0-RC1 for merging... done.
Preparing to download files... done.
Fetching 1304 patches.....10....20....30....40....50....60....70....80....90....100....110....120....130....140....150....160....170....180....190....200....210....220....230....240....250....260....270....280....290....300....310....320....330....340....350....360....370....380....390....400....410....420....430....440....450....460....470....480....490....500....510....520....530....540....550....560....570....580....590....600....610....620....630....640....650....660....670....680....690....700....710....720....730....740....750....760....770....780....790....800....810....820....830....840....850....860....870....880....890....900....910....920....930....940....950....960....970....980....990....1000....1010....1020....1030....1040....1050....1060....1070....1080....1090....1100....1110....1120....1130....1140....1150....1160....1170....1180....1190....1200....1210....1220....1230....1240....1250....1260....1270....1280....1290....1300.. done.
Applying patches... done.
Fetching 22 files... done.
Attempting to automatically merge changes in files... done.

The following changes, which occurred between FreeBSD 7.0-RC1 and
FreeBSD 7.0-RELEASE have been merged into /etc/mail/sendmail.cf:
--- current version
+++ new version
@@ -15,11 +15,11 @@
######################################################################
######################################################################
#####
##### SENDMAIL CONFIGURATION FILE
#####
-##### built by root@logan.cse.buffalo.edu on Mon Dec 24 09:40:07 UTC 2007
+##### built by root@logan.cse.buffalo.edu on Sun Feb 24 17:22:36 UTC 2008
##### in /usr/obj/usr/src/etc/sendmail
##### using /usr/src/etc/sendmail/../../contrib/sendmail/cf/ as configuration include directory
#####
######################################################################
#####
Does this look reasonable (y/n)?y

serverA# freebsd-update -f /etc/freebsd-update.conf install
Installing updates...
Kernel updates have been installed. Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.

serverA#shutdown -r now

serverA#
freebsd-update -f /etc/freebsd-update.conf install
Installing updates... done.
serverA#shutdown -r now


แค่เนี๊ยครับ