Sign up

This page looks plain and unstyled because you're using a non-standard compliant browser. To see it in its best form, please upgrade to a browser that supports web standards. It's free and painless.

Cài đặt JDK 1.6 update 10 trên FreeBSD 7

Ports mặc định của FreeBSD 7 chỉ là JDK 1.6 update 3 do đó để cài đặt JDK 1.6 update 10 trước tiên cần phải cập nhật port linux-sun-jdk16 từ FreeBSD.
 (Xem tiếp)

Viết bởi freebsd, 29 November 2008 11:36 | Cài đặt & Cấu hình | Góp ý (1) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Ra mắt diễn đàn chính thức dành cho cộng đồng FreeBSD

Cuối cùng thì FreeBSD Foundation cũng cho ra mắt diễn đàn chính thức dành cho cộng đồng người dùng FreeBSD tại địa chỉ http://forums.freebsd.org.

Viết bởi freebsd, 17 November 2008 17:45 | Tips | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Linux + FreeBSD mini Howto

http://www.faqs.org/docs/Linux-mini/Linux+FreeBSD.html

Viết bởi freebsd, 16 November 2008 22:18 | Hệ thống | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Làm thế nào để đọc dữ liệu từ một ổ cứng Linux trên FreeBSD?

Mặc định thì Linux không hiểu cấu trúc file của FreeBSD và ngược lại. Do đó, khi bạn gắn một ổ cứng đang chạy Linux vào một máy đang chạy FreeBSD thì bạn sẽ không thể nào mount được.
 (Xem tiếp)

Viết bởi freebsd, 16 November 2008 19:04 | Hệ thống | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Theo dõi các user đã làm gì trên shell

Đôi khi có nhiều user xóa history của họ trước khi logout, hoặc chuyển output của shell log ra /dev/null, hoặc xóa luôn file /var/log/wtmp,... làm người quản trị hệ thống không thể biết họ làm gì trên server. Khi đó thì chỉ có nước pó tay thôi chứ đâu còn cách nào khác. Chỉ có thể đề phòng từ trước thôi.

 (Xem tiếp)

Viết bởi freebsd, 16 November 2008 10:17 | Bảo mật | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Kích hoạt Accounting

Thêm dòng accounting_enable="YES" vào tập tin /etc/rc.conf để chạy khi server khởi động. Sau đó chạy:
#/etc/rc.d/accounting start
 (Xem tiếp)

Viết bởi freebsd, 16 November 2008 02:23 | Bảo mật | Góp ý (2) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Xử lý mail queue của Sendmail

Xem mail queue: #mailq hoặc #sendmail -bp

 (Xem tiếp)

Viết bởi freebsd, 14 November 2008 22:44 | Email | Góp ý (1) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Đếm IP truy cập

Đoạn code sau sẽ in ra danh sách 10 IP truy cập nhiều nhất vào server dựa vào Apache log:

 (Xem tiếp)

Viết bởi freebsd, 14 November 2008 22:38 | Tips | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Makefile cho ZendOptimizer hỗ trợ FreeBSD 7

Hiện tại đến thời điểm này thì ZendOptimizer chưa chính thức hỗ trợ FreeBSD 7. Tuy nhiên có thể download Makefile này về rồi chép đè vào thư mục ZendOptimizer trong ports sau đó make thì sẽ ok.

 (Xem tiếp)

Viết bởi freebsd, 07 November 2008 02:48 | Cài đặt & Cấu hình | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

/etc/my.cnf

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-locking
#skip-networking
safe-show-database
query_cache_limit=1M
query_cache_size=64M ## 32MB for every 1GB of RAM
query_cache_type=1
max_user_connections=200
max_connections=500
interactive_timeout=10
wait_timeout=20
connect_timeout=20
thread_cache_size=128
key_buffer=128M ## 64MB for every 1GB of RAM
join_buffer=1M
max_connect_errors=20
max_allowed_packet=16M
table_cache=1024
record_buffer=1M
sort_buffer_size=2M ## 1MB for every 1GB of RAM
read_buffer_size=2M ## 1MB for every 1GB of RAM
read_rnd_buffer_size=2M  ## 1MB for every 1GB of RAM
thread_concurrency=2 ## Number of CPUs x 2
myisam_sort_buffer_size=64M
server-id=1
log_slow_queries=/var/log/mysql-slow-queries.log
long_query_time=2
collation-server=latin1_general_ci
old-passwords

[mysql.server]
user=mysql
basedir=/var/lib

[safe_mysqld]
err-log=/var/log/mysqld.log
pid-file=/var/lib/mysql/mysql.pid
open_files_limit=8192

[mysqldump]
quick
max_allowed_packet=16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer=32M
sort_buffer=32M
read_buffer=16M
write_buffer=16M

[myisamchk]
key_buffer=32M
sort_buffer=32M
read_buffer=16M
write_buffer=16M

[mysqlhotcopy]
interactive-timeout

Wael __________________

Viết bởi freebsd, 02 November 2008 21:13 | Mysql | Góp ý (4) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Đổi tên files hàng loạt

Đổi tên file hàng loạt:

Ví dụ, muốn đổi tất cả tập tin dạng IMG_00123.jpg thành IMG_000123.jpg ta dùng lệnh:

#rename IMG_ IMG_0 IMG_?????.jpg

Viết bởi freebsd, 26 October 2008 13:46 | Tips | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

FreeBSD 7, Apache 2, PHP 5, Mysql 5 optimize

About configuration

This post was redacted with at least this configuration in mind:

Of course, it may be usable for other configurations, or give elements to think about.

MySQL performances

Under FreeBSD and not under GNU/Linux, performances drop down where there are too many simultaneous connections. With my 1.8 GHz Celeron and 1.2 MB RAM, I can't go over 30 simultaneous connections without blocking the computer.

This issue seems to be fixed with FreeBSD 7.0, but it may be possible to attenuate it with previous versions.

Here are some ideas:

MPM and PHP

Since version 2, Apache support many distinct MPM. The most often used are the following ones:

If you read the previous list, you will want to use worker MPM: less slower, better memory usage, why hesitate ? the problem is that PHP only support prefork MPM, and nothing is guaranteed with worker MPM. It's may work, but it may not. In my case, it perfectly worked with PHP 5.0.x, but didn't worked with PHP 5.1.x. Related symptoms were session lost or blank pages.

Then if you don't want to prematurely loose your hairs, only use prefork MPM. So you may want to stay with Apache 1.3, and you're right. But remember, one day, this version will be obsolete and not supported anymore, and sooner than version 2.0.

PHP and MySQL

You have to ways to connect to a MySQL database: persistent connections, and non persistent connections. A persistent connection is a connection which will stay open until it's explicitly closed (with the related function or when the script ends). If may be useful if you don't want to lose time waiting to open connection again when you need it, but if you have too many simultaneous connexions the MyQSL service may be overloaded.
A non persistent connection is a connection which is open and close each time a query is sent to MySQL. Connection open and close functions are only here to create the variable used to manage the connexion. Unlike persistent connection, you have a slight overhead due to connection opening and closing, but it may be unnoticeable (unless your scripts need to often execute queries). In non persistent connection case, the server will be less often overloaded while getting many simultaneous connections.
In order to disable persistent connections with PHP, you have to set the parameter "mysql.allow_persistent" to "Off" into "/usr/local/etc/php.ini" file.

PHP and memory usage

It may be evident to you, but PHP is memory hungry. After a few quick tries, an Apache process use 7 MB without PHP, and 20 MB with PHP. And don't forget: more you have connections, more you have open Apache processes. With 20 MB per processes, memory usage will grow quickly.

In order to avoid important memory usage, only install PHP modules you need. And if you have problems with a module, you will loose less time to find which one is guilty with few modules than with many. When I write about problems with a module, I mean this: I open a page with use no function from this module, but Apache crashes with an error code 11. If you want to find the guilty module, disable all modules one by one, then restart Apache and reload the page until Apache doesn't crash anymore.

PHP and performances.

PHP is an interpreted language. This means each time a PHP script is opened and executed, PHP engine will need to check the syntax, compile it to a semi-native language ( called "bytecode"), then execute it. For only one PHP script, this syntax check then compilation dedicated time is invisible to the user. But when the web server has to treat hundreds of PHP script within a second, this overhead may be too important.

If you want to accelerate things, there are tools called "PHP accelerators" which optimize PHP scripts loading. When a PHP script is open for the first time, the syntax is checked, it's compiled to bytecode in an optimized may, and this bytecode is saved then executed. Then, each time this script is asked for, PHP engine will use the previously generated bytecode. This time gain may be appreciable.

There are many PHP accelerator. The most known are:

I first tried eAccelerator, but had some issues with: cache was not updated, some session loose, etc. With ZendOptimizer, I still have these issues, but less often. Then I don't use any of them.

If you want to use a PHP accelerator, you can accelerate ZendOptimizer if you don't use files protected by ZendGuard. You just have to add into "/usr/local/etc/php.ini" file, within ZendOptimizer section, the following lines:

zend_optimizer.enable_loader=0
zend_optimizer.disable_licensing=0

Apache and AcceptFilter

AcceptFilter is a feature based on kernel options used to optimize HTTP connections (see "accf_http" kernel module for FreeBSD). Said like that, it looks good. But I'm really not convinced: processes memory usage grow (45 MB memory usage per process), processes are opened but never closed (which does not help with memory usage). The only good thing is, when system was not overloaded, that connections seemed to answer quicker. Then disable AcceptFilter. With FreeBSD, it's easy: just add a line

apache22_http_accept_enable="NO"

into "/etc/rc.conf" ("apache22" may change depending the version you use).

Apache and connections limitation.

I just come back to memory use with some trick to avoid server overload:

Conclusion

I hope these tricks will be useful to you. There are not perfect one because they come from empiric experience


Nguồn: http://goddess-gate.com/dc2/index.php/post/255

Viết bởi freebsd, 03 October 2008 09:46 | Optimize | Góp ý (1) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Fix cấu hình SSH2 để DreamWeaver có thể connect via SFTP

Khi cài đặt ssh2 thì với cấu hình mặc định, DreamWeaver hoặc WS_FTP không thể connect vào server thông qua giao thức SFTP. Để khắc phục lỗi này, chỉnh lại trong file cấu hình /etc/ssh/sshd_config như sau:
 (Xem tiếp)

Viết bởi freebsd, 29 September 2008 12:52 | Cài đặt & Cấu hình | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

How Do I Enable Remote Access To MySQL Database Server?

By default, MySQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home or from web server.

MySQL Remote Access

You need type the following commands which will allow remote connections:

Step # 1: Login over ssh if server is outside your IDC

First, login over ssh to remote MySQL database server

Step # 2: Enable networking

Once connected you need edit the mysql configuration file my.cfg using text editor such as vi.

# vi /etc/my.cnf

Step # 3: Once file opened, locate line that read as follows

[mysqld] 

Make sure line skip-networking is commented (or remove line) and add following line

bind-address=YOUR-SERVER-IP

For example, if your MySQL server IP is 65.55.55.2 then entire block should be look like as follows:
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = /usr/share/mysql/English
bind-address = 65.55.55.2
# skip-networking
....
..
....
Where,

Step# 4 Save and Close the file

Restart your mysql service to take change in effect:# /etc/init.d/mysql restart

Step # 5 Grant access to remote IP address

# mysql -u root -p mysqlGrant access to new database
If you want to add new database called foo for user bar and remote IP 202.54.10.20 then you need to type following commands at mysql> prompt:mysql> CREATE DATABASE foo;
mysql> GRANT ALL ON foo.* TO bar@'202.54.10.20' IDENTIFIED BY 'PASSWORD';

How Do I Grant access to existing database?

Let us assume that you are always making connection from remote IP called 202.54.10.20 for database called webdb for user webadmin, To grant access to this IP address type the following command At mysql> prompt for existing database:mysql> update db set Host='202.54.10.20' where Db='webdb';
mysql> update user set Host='202.54.10.20' where user='webadmin';

Step # 5: Logout of MySQL

Type exit command to logout mysql:mysql> exit

Step # 6: Open port 3306

You need to open port 3306 using iptables or BSD pf firewall.

A sample iptables rule to open Linux iptables firewall

/sbin/iptables -A INPUT -i eth0 -p tcp --destination-port 3306 -j ACCEPT

OR only allow remote connection from your web server located at 10.5.1.3:

/sbin/iptables -A INPUT -i eth0 -s 10.5.1.3 -p tcp --destination-port 3306 -j ACCEPT

OR only allow remote connection from your lan subnet 192.168.1.0/24:

/sbin/iptables -A INPUT -i eth0 -s 192.168.1.0/24 -p tcp --destination-port 3306 -j ACCEPT

A sample FreeBSD / OpenBSD pf rule ( /etc/pf.conf)

pass in on $ext_if proto tcp from any to any port 3306

OR allow only access from your web server located at 10.5.1.3:

pass in on $ext_if proto tcp from 10.5.1.3 to any port 3306  flags S/SA synproxy state

Step # 7: Test it

From remote system or your desktop type the command:
$ mysql -u webadmin -h 65.55.55.2 -p
Where,

You can also use telnet to connect to port 3306 for testing purpose:$ telnet 65.55.55.2 3306

Viết bởi freebsd, 20 September 2008 17:10 | Mysql | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

Ấn tượng với FreeBSD 7.0

FreeBSD 7.0 thực sự là một hệ điều hành ưu việt dành cho máy chủ. Khả năng hỗ trợ SMP được cải tiến mạnh mẽ, tốc độ cải thiện cực kỳ ấn tượng so với các phiên bản cũ. Đặc biệt là khi đem so sánh với một kernel Linux tốt nhất có thể thì FreeBSD 7.0 vẫn nhanh hơn đến 15%.
 (Xem tiếp)

Viết bởi freebsd, 16 September 2008 17:24 | Tips | Góp ý (0) | Đường dẫn cố định | Trackbacks (0) | Bản inBản in

1 2 3 4 5 6  Sau»
Powered by vnWeblogs
Valid XHTML 1.0 Strict - Valid CSS