make clean
make deinstall
make install
make clean 即可
升级系统源码树及ports更新/usr/share/examples/cvsup目录下stand-cvsup和ports-cvsup文件,并执行cvsup –g –L2 standard-supfile和cvsup –g –L2 ports-cvsup两个文件,升级ports树?
CPUTYPE=i686
CFLAGS= -O3 -pipe
COPTFLAGS= -O3 -pipe
升级操作系统进入/usr/src
执行make world
整个过程很久,需要2小时左右。
#disable ctrl+alt+delete
options SC_DISABLE_REBOOT
#quota limit
options QUOTA
#ipfw support
options IPFIREWALL
options DUMMYNET
options HZ=3000
options IPDIVERT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPSTEALTH
options TCP_DROP_SYNFIN
options IPFIREWALL_DEFAULT_TO_ACCEPT
options ICMP_BANDLIM
options ACCEPT_FILTER_DATA
options ACCEPT_FILTER_HTTP
#ipfilter support
#options IPFILTER
#options IPFILTER_LOG
#options IPFILTER_DEFAULT_BLOCK
再执行:
/usr/sbin/config onlinecq
cd ../../compile/onlinecq
make depend
make
make install
#enable_quotas="YES"
#check_quotas="YES"
firewall_enable="YES"
firewall_script="/etc/rc.firewall"
firewall_type="/etc/ipfw.rules" #create it!
firewall_quiet="NO"
firewall_logging_enable="YES"
log_in_vain="NO"
tcp_drop_synfin="NO"
tcp_restrict_rst="YES"
icmp_drop_redirect="YES"
优化内核参数修改系统内核参数,实现微调:vi /etc/sysctl.conf
kern.ipc.somaxconn=8192
kern.ipc.maxsockbuf=2097152
kern.maxfilesperproc=32768
kern.maxfiles=65536
kern.securelevel=-1
net.inet.tcp.sendspace=65536
net.inet.tcp.recvspace=32768
net.inet.udp.maxdgram=57344
net.inet.icmp.drop_redirect=1
net.inet.icmp.log_redirect=0
net.inet.ip.redirect=0
net.inet6.ip6.redirect=0
net.inet.icmp.icmplim=100
net.inet.tcp.always_keepalive=0
net.inet.tcp.delayed_ack=0
net.inet.tcp.log_in_vain=0
net.inet.udp.log_in_vain=0
net.inet.tcp.blackhole=2
net.inet.udp.blackhole=1
net.local.stream.sendspace=65535
net.local.stream.recvspace=32768
net.inet.ip.fastforwarding=1
vfs.vmiodirenable=1
make clean
make deinstall
make WITH_OPENSSL=yes WITH_LINUXTHREADS=yes BUILD_OPTIMIZED=yes install 或者使用下面可参考的编译参数:BUILD_STATIC=yes
编译成静态执行版本
make clean
更改mysql的root密码:
mysqladmin –uroot –p password 123456
生成/etc/my.cnf,使用如下命令:
vi /etc/my.cnf
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
[mysqld]
skip-innodb
skip-locking
skip-networking
set-variable = port=3306
set-variable = socket=/tmp/mysql.sock
set-variable = back_log=50
set-variable = connect_timeout=3
set-variable = key_buffer=128M
set-variable = max_connections=1000
set-variable = max_allowed_packet=1M
set-variable = net_buffer_length=8K
set-variable = wait_timeout=3
set-variable = read_buffer_size=1M
set-variable = sort_buffer_size=1M
set-variable = table_cache=256
set-variable = myisam_sort_buffer_size=32M
set-variable = log_slow_queries=/var/log/log_slow_queries.log
#log-bin
server-id = 1
[mysqldump]
quick
set-variable = max_allowed_packet=16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[myisamchk]
set-variable = key_buffer=20M
set-variable = sort_buffer=20M
set-variable = read_buffer=2M
set-variable = write_buffer=2M
[mysqlhotcopy]
interactive-timeout
make clean
make deinstall
make install
make clean
新建立一个system的数据库备用。
make clean
make deinstall
make WITH_MYSQL=1 install 或者使用下面可参考的编译参数:WITH_LANG=simplified-chinese
使用简体中文语言包
make clean配置pure-ftpd,主要需要做以下的工作:
cp /usr/local/etc/pure-ftpd.conf.sample /usr/local/etc/pure-ftpd.conf
cp /usr/local/etc/pureftpd-mysql.conf.sample /usr/local/etc/pureftpd-mysql.conf
再修改/usr/local/etc/pure-ftpd.conf的如下部份为:
NoAnonymous yes
MySQLConfigFile /usr/local/etc/pureftpd-mysql.conf
再修改/usr/local/etc/pureftpd-mysql.conf的如下部份为您的设定值:
# Mandatory : user to bind the server as.
MYSQLUser demo
# Mandatory : user password. You must have a password.
MYSQLPassword demo
# Mandatory : database to open.
MYSQLDatabase demo
再进入使用mysql –uroot –p123456 进入mysql的文本方式?
使用如下命令建立新表:
use system;
DROP TABLE IF EXISTS users;
CREATE TABLE users (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;
/usr/local/www/data
chmod –R 755 /usr/local/www/data/pureftpd_php_manager
再加入一个普通用户和一个群组,以供ftp使用:
pw groupadd ftpusers
pw useradd ftpuser –g ftpusers –s /sbin/nologin
记住他们的uid和gid号,备用!
进入并编辑pureftp.config.php文件
更改里面的如下行:
$PUREFTP_CONFIG_FILE = '/usr/local/etc/pureftpd-mysql.conf';^M
$DefaultUser = "ftpuser"; # Default User Logon^M
$DefaultPass = ""; # Default User Password^M
$DefaultUid = "1002"; # Default User ID ( must be a re
al user acct )^M
$DefaultGid = "1001"; # Default Group ID ( must be a r
eal group acct )^M
$DefaultDir = "/home"; # Default User Dir ( use
/./ at the end to chroot )^M
$DefaultUL = "0"; # Default Upload Throttl
e ( 0 disables it )^M
$DefaultDL = "0"; # Default Download Throt
tle ( 0 disables it )^M
$Defaultip = "*"; # Default IP restriction
s ( * = any IP )^M
$DefaultQS = "200"; # Default Quota Size ( 0 disable
s it )^M
$Defaultcmt = ""; # Default Comment for us
er^M
^M
// UA^M
$DefaultQF = "0"; # Default Quota Files ( 0 disabl
make clean
make deinstall
make WITH_APACHE_SUEXEC=yes APACHE_HARD_SERVER_LIMIT=1024 APACHE_PERF_TUNING=yes install 编译时带上suexec和优化。
Make clean
取消所有Options里面的Indexes,禁止浏览目录及文件。
设置KeepAlive Off
安装PHP语言安装php
进入/usr/ports/www/mod_php4
执行:
make clean
make deinstall
make install编译常用的选项即可,一定记得选择上mysql和gd。
Make clean安装完成后,在/usr/local/etc/apache/httpd.conf里面,加入如下内容:
AddType application/x-httpd-php .php .php3 .php4 .phtml
AddType application/x-httpd-php-source .phps
替换DirectoryIndex细节为:
<IfModule mod_dir.c>
DirectoryIndex index.html index.htm index.wml index.cgi index.shtml index.jsp index.js index.jp index.php4 index.php3 index.php index.phtml default.htm default.html home.htm
</IfModule>
再cp php.ini-recommended /etc/php.ini
以及修改php.ini里面的参数
vi /etc/php.ini
修改下面两处为:
register_globals = On
magic_quotes_gpc = On
tar zxvf ZendOptimizer-2.1.0b-FreeBSD4.0-i386.tar.gz
cd ZendOptimizer-2.1.0b-FreeBSD4.0-i386
sh setup 即可完成傻瓜式的安装。
注意:此时您的php.ini配置文件,一般会移到
/usr/loca/Zend/etc/php.ini
并且底部会增加以下几行:
[Zend]
zend_optimizer.optimization_level=15
zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-2.1.0
zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-2.1.0
zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so
您可以根据需要,改变15为1023,来提升加速的等级。
make clean
make deinstall
make install 编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule bandwidth_module libexec/apache/mod_bandwidth.so
AddModule mod_bandwidth.c
make clean
语法及作用:
* BandWidthModule
该模块的开关,可以对每个Server进行配置
* BandWidthPulse
设定计时单位,MS(微秒),建议为:1000000 (1秒)
* BandWidth
可以针对特定来源的对象控制流,rate以字节为单位,但当rate为0时,为不限制流速。
例子:
BandWidth ecp.fr 0
BandWidth 138.195 0
BandWidth all 1024
* LargeFileLimit
当传送一个大于等于filesize KB大小的档时,设定一个最大流速(字节/秒),当rate
为0的时候,不限速。
例子:
LargeFileLimit 200 3072
LargeFileLimit 1024 2048以上例子设定小于200KB的档将不会被限制流速,大小在200K到1024K之间的档将会被
限速3072 B/s,大于1024KB的文件将会被限速2048 B/s.
* MinBandWidth
设定每个连接传送数据的基本带宽占用,以Byte为单位。默认值:256 B/s。
当rate设定为0时,使用默认带宽限制。
安装mod_fastcgi
进入/usr/ports/www/mod_ fastcgi
执行:
make clean
make deinstall
make install编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule fastcgi_module libexec/apache/mod_fastcgi.so
AddModule mod_fastcgi.c
AddHandler fastcgi-script fcgi fcgi fpl
make clean
安装mod_gzip
进入/usr/ports/www/mod_gzip
执行:
make clean
make deinstall
make install编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule gzip_module libexec/apache/mod_gzip.so
AddModule mod_gzip.c make clean
安装mod_limitipconn
进入/usr/ports/www/mod_limitipconn
执行:
make clean
make deinstall
make install编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule limitipconn_module libexec/apache/mod_limitipconn.so
AddModule mod_limitipconn.c
make clean
安装mod_perl进入/usr/ports/www/mod_perl
执行:
make clean
make deinstall
make install编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule perl_module libexec/apache/mod_perl.so
AddModule mod_perl.c
make clean
安装mod_throttle
进入/usr/ports/www/mod_throttle
执行:
make clean
make deinstall
make install编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule throttle_module libexec/apache/mod_throttle.so
AddModule mod_throttle.c
make clean
安装mod_watch
进入/usr/ports/www/mod_watch
执行:
make clean
make deinstall
make install编译完成后,一定记得
vi /usr/local/etc/apache/httpd.conf
LoadModule watch_module libexec/apache/mod_watch.so
AddModule mod_watch.c
make clean
apxs -c mod_vhost_limit.c -o /path/to/libexec/mod_vhost_limit.so 在 httpd.conf 加入:
LoadModule vhost_limit_module libexec/mod_vhost_limit.so
AddModule mod_vhost_limit.c配置:
MaxClients 150
ExtendedStatus On
NameVirtualHost *
<VirtualHost *>
ServerName server1
DocumentRoot /some/where/1
MaxVhostClients 100
</VirtualHost>
<VirtualHost *>
ServerName server2
DocumentRoot /some/where/2
MaxVhostClients 30
</VirtualHost>
<VirtualHost *>
ServerName server3
DocumentRoot /some/where/3
</VirtualHost>其中: server1 被限制为 100 个并发线程数。 server2 被限制为 30 个并发线程数。 server3 没有被限制。
注:需 mod_status 的 ExtendedStatus On 支持!!
如超出限制的并发数在客户端就会出现503错误:
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
--------------------------------------------------------------------------------
Apache/1.3.27 Server at server1 Port 80
在 error_log 中将会有类似以下的错误提示:
[Mon Jun 23 15:22:24 2003] [error] client access to server1 deferred, MaxVhostClients 100 exceeded
安装防止ddos攻击的软件
dosevasive1.8.tar.gz
安装方法:
tar zxvf mod_dosevasive.tar.gz
cd dosevasive/
/usr/local/apache/bin/apxs -i -c mod_dosevasive.c
vi /usr/local/apache/conf/httpd.conf加入
LoadModule dosevasive_module libexec/mod_dosevasive.so
AddModule mod_dosevasive.c
<IfModule mod_dosevasive.c>
DOSHashTableSize 3097
DOSPageCount 2
DOSSiteCount 50
DOSPageInterval 1
DOSSiteInterval 1
DOSBlockingPeriod 10
</IfModule>
make clean
make deinstall
make install
make clean
安装mrtg
进入/usr/ports/net/mrtg
执行:
make clean
make deinstall
make install
make clean设置虚空间的mrtg和流量分析
生成流量控制?:
/usr/local/sbin/apache2mrtg.pl /usr/local/etc/apache/httpd.conf > /usr/local/etc/apache/mod_watch.cfg修改此文件,并且加如下头部信息:
WorkDir:/usr/local/www/data/mrtg
Options[_]: growright,bits
#Language: gb2312
#Title[^]: Traffic Analysis for
PageTop[^]: <H1>Traffic Stats for OnlineCQ.COM User</H1><HR>
#PageTop[$]: Contact QQ: 151482576<HR>
PageFoot[^]: WWW.OnlineCQ.COM MSN: cqfanli@hotmail.com QQ:151482576
保证WorkDir目录可以被浏览器访问,并且目录存在!如果不是,您可以自己修改!
执行一下,看是否正确:
/usr/local/sbin/mrtg /usr/local/etc/apache/mod_watch.cfg如果有错误,多执行几次即可!
再将此加入到排程里面,15分钟自动执行一次:
vi /etc/crontab
*/15 * * * * root /usr/local/bin/mrtg /usr/local/e
tc/apache/mod_watch.cfg
make clean
make deinstall
make install
make clean 然后再记得修改name.conf
等配置文件,具体的内容太复杂,建议看一下其它专门讲授这方面的书籍。
安装邮件服务器安装qmail邮件系统
使用iceblood的安装包,傻瓜式的安装就可以了!注意第一次安装时,多看几遍它的说明,不要弄错了!
安装完成后,自己再加上qmailadmin,它可以让您在一台主机上面,开多个域名的企业邮局!
tar zxvf webmin-1.100.tar.gz 进入目录开始安装:
cd webmin-1.100
sh setup.sh
安装时使用它的默认设置即可,自己要设置好管理员密码,这一定要注意保密!
并且请设置为自动启动,以便以后可以通过此来管理。
安装完成后,可以通过如下方式访问:
http://IP:10000/
注意,默认埠是10000
tar zxvf usermin-1.030.tar.gz
进入目录开始安装:
cd usermin-1.030
sh setup.sh
安装时使用它的默认设置即可。
安装完成后,可以通过如下方式访问:
http://IP:20000/
注意,默认埠是20000。
Usermin会自动和webmin整合的,使用webmin的管理员密码,并且可以在webmin里面启动它。
结束语至此为止,一般可以实际运作的FREEBSD系统就建立起来了,您可以reboot一下,让最新的设置及软件生效。
如果在安装过程中出现错误,您可以先检查完错误,再接着安装下去。或者你可以选择你感兴趣的某些部份安装!
当然因为时间仓促,涉及到的知识太广,加上本人能力有限,其中错误在所难免,恳请各位读者提出来,大家共同提高,共同进步