网络安全 频道

用FreeBSD+Windows架设个人WEB服务器

mod_gzip_on Yes
mod_gzip_minimum_file_size 1000
mod_gzip_maximum_file_size 300000
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.htm$
mod_gzip_item_include file \.php$
mod_gzip_item_include mime text/.*
mod_gzip_item_include mime httpd/unix-directory
mod_gzip_temp_dir /tmp/mod_gzip
mod_gzip_dechunk Yes
mod_gzip_keep_workfiles No
Module>
##########################################################################

按“Ctrl+[”,存盘退出。



php的配置文件:php.ini

test# ee /usr/local/www/php/lib/php.ini

加入或更改如下内容:

register_globals = On
mysql.default_port = 3306


按“Ctrl+[”,存盘退出。


mysql

test# cd /usr/local/mysql
test# ./bin/safe_mysqld --user=mysql &

test# ./bin/mysql

mysql>use mysql
mysql>grant all privileges on *.* to "winname"@"192.168.0.3";

mysql>quit
Bye
test# killall mysqld


samba的配置文件:smb.conf


test# ee /usr/local/samba/lib/smb.conf

加入或更改如下内容并把所有关于printer的部分用“;”注释掉:

#======================= Global Settings =====================================
[global]
workgroup = WORKGROUP
server string = FreeBSD
hosts allow = 192.168.0.3 127.
guest account = winname
log file = /var/log/samba/log.%m
#============================ Share Definitions ==============================
;[homes]
; comment = Home Directories
; browseable = no
; writeable = yes
[sos]
path = /sos
public = yes
writeable = yes
[htdocs]
path = /usr/local/www/htdocs
public = yes
writeable = yes

按“Ctrl+[”,存盘退出。

test# chown -R winname /sos
test# chown -R winname /usr/local/www/htdocs


ez-ipupdate的配置文件:qdns.conf

test# ee /usr/local/ez/qdns.conf

加入或更改如下内容:

service-type=qdns
user=user:passwd
host=test.8866.org
interface=tun0
max-interval=2073600
cache-file=/tmp/ez-ipupdate.cache

其余部分用“#”注释掉。按“Ctrl+[”,存盘退出。


配置ipfw

test# ee /etc/ipfw.conf

加入如下内容:(其中希网的DNS服务器的ip为202.108.36.139)

#ipfw防火墙规则的修正:(其中xxx.xxx.xxx.xxx和yyy.yyy.yyy.yyy是你所处地区的DNS服务器的IP)

# /etc/ipfw.conf

add 00100 allow ip from any to any via lo0

add 00310 deny log ip from any to any ipopt rr
add 00320 deny log ip from any to any ipopt ts
add 00330 deny log ip from any to any ipopt ssrr
add 00340 deny log ip from any to any ipopt lsrr
add 00350 deny tcp from any to any in tcpflags syn,fin

add 00400 allow tcp from any to me 80 in

add 00500 check-state
add 00520 allow tcp from any to any out setup keep-state
add 00530 allow tcp from any to any out

# ICMP
add 00600 allow icmp from any to any icmptype 3
add 00610 allow icmp from any to any icmptype 4
add 00620 allow icmp from any to any out icmptype 8
add 00630 allow icmp from any to any in icmptype 0
add 00640 allow icmp from any to any in icmptype 11

# DNS
add 00700 allow ip from xxx.xxx.xxx.xxx to any
add 00710 allow ip from any to xxx.xxx.xxx.xxx
add 00720 allow ip from yyy.yyy.yyy.yyy to any
add 00730 allow ip from any to yyy.yyy.yyy.yyy
add 00740 allow ip from 202.108.36.139 to any
add 00750 allow ip from any to 202.108.36.139
add 00760 allow udp from any to any out


# LAN
add 00900 allow ip from 192.168.0.0/16 to any
add 00910 allow ip from any to 192.168.0.0/16


按“Ctrl+[”,存盘退出。


再配置rc.conf

还记得前面/etc/rc.conf中有:

#ipfw_enable="YES"
#ipfw_type="/etc/ipfw.conf"

吗?

test# ee /etc/rc.conf

去掉前面的“#”,按“Ctrl+[”,存盘退出。

至此,大功告成!

test# reboot

以root身份登入FreeBSD

运行samba

test# /usr/local/samba/sbin/smbd start
test# /usr/local/samba/sbin/nmbd start

运行mysql

test# cd /usr/local/mysql
test# ./bin/safe_mysqld --usr=mysql &

运行apache

test# /usr/local/www/bin/apachectl start

运行ez-ipupdate

test# /usr/local/ez/ez-ipupdate -c /usr/local/ez/qdns.conf


好了,如果没有什么异常,你的FreeBSD就正在运行着现在最流行的apache,mysql和samba。

2 Windows上

右键点击网上邻居,在菜单上选择属性,点击左键,打开后,右键点击本地连接,在菜单上选择属性,双击“Internet 协议

(TCP/IP)”,选择“使用下面的IP”,“IP地址(I)”处输入“192.168.0.3”,“子网掩码”处输入“255.255.255.0”,“默认网关”处输入

“192.168.0.1”;记得你在FreeBSD里记下的DNS服务器的IP吗?在“使用下面的DNS服务器地址”处输入它们,确定。好了,赶紧打开网上邻

居吧,看到FreeBSD里的sos和htdocs文件夹拉吧,你可以随意地在Windows和FreeBSD的这两个文件夹之间拷贝文件了。
打开MS-DOS,在根目录下输入:

C:\>ping 192.168.0.1

有回应,表示局域网配置正常。

C:\>ping test.8866.org

有回应,表示域名解析成功。

打开一个你常去的网站,这是通过FreeBSD作网关上去的。


打开记事本,输入:



hello,world! welcome to test.8866.org.



存为index.html,拷贝到网上邻居FreeBSD的htdocs内,打开IE,在地址栏输入:

http://test.8866.org

回车,看到那行字了吗?这就是你的首页。

再打开记事本,输入:

phpinfo();
?>

存为phpinfo.php,拷贝到网上邻居FreeBSD的htdocs内,在地址栏输入:

http://test.8866.org/phpinfo.php

回车,你会看到你的WEB服务器的信息。会有类似的一行:

This program makes use of the Zend Scripting Language Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2002 Zend Technologies with Zend Optimizer
v2.1.0, Copyright (c) 1998-2003, by Zend Technologies




配置调试用服务器

apache

安装在C:\www\apache下

httpd.conf中加入或改写:

LoadModule php4_module c:/php/sapi/php4apache.dll
LoadModule gzip_module modules/ApacheModuleGzip.dll

AddModule mod_php4.c
AddModule mod_gzip.c

ServerName localhost

AddType application/x-httpd-php .php


LogFormat "%h %l %u %t \"%r\" %>s %b mod_gzip: %{mod_gzip_compression_ratio}npct." common_with_mod_gzip_info1
LogFormat "%h %l %u %t \"%r\" %>s %b mod_gzip: %{mod_gzip_result}n In:%{mod_gzip_input_size}n

Out:%{mod_gzip_output_size}n:%{mod_gzip_compression_ratio}npct." common_with_mod_gzip_info2

CustomLog logs/access.log common_with_mod_gzip_info2

mod_gzip_on Yes
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 0
mod_gzip_maximum_inmem_size 100000
mod_gzip_keep_workfiles No
mod_gzip_dechunk Yes
mod_gzip_temp_dir "c:\www\apache\mod_gzip_tmp"
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.htm$
mod_gzip_item_include file \.jsp$
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.pl$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-httpd-php
mod_gzip_item_include handler ^perl-script$
mod_gzip_item_include handler ^server-status$
mod_gzip_item_include handler ^server-info$
mod_gzip_item_exclude file \.css$
mod_gzip_item_exclude file \.js$
mod_gzip_item_exclude mime ^image/.*
Mldule>

Window 2000下可以用“服务”方式启动apache
MS-DOS下,输入:

C:\>cd www\apache
C:\www\apache>apache -i -n "apache"

这样就把apache安裝到系统的服务中了,你可以在控制台的服务中看到apache列在服务列表內,以后开机时就自动执行apache了。
要启动apache也可以直接在MS-DOS下输入:net start apache,关闭apache输入:net stop apache

mod_gzip

将ApacheModuleGzip.dll拷贝至C:\www\apache\modules,创建c:\www\apache\mod_gzip_tmp即可。


php

将php解压缩到C:\www\apache\php

将php4ts.dll拷贝C:\windows\system

将php.ini-dist拷贝至C:\WINNT 目录下,并改名为 php.ini

修改php.ini:

register_globals = On
mysql.default_port = 3306



ZendOptimizer

执行ZendOptimizer*.exe

安装目录设为 C:\www\apache\Zend


安装程序将自动更新php.ini,并在其内容结尾处自动添加:
  
[Zend]
zend_optimizer.optimization_level=15
zend_extension_ts="C:\www\apache\Zend\lib\ZendOptimizer.dll"


mysql


运行setup,安装到C:\www\mysql下
将C:\www\mysql目录下的my-example.cnf文件改名为my.cnf拷贝到c:\目录下面
打开MS-DOS

C:\>write my.cnf

[mysqld]
port=3306

basedir = C:/www/mysql/

保存后退出。

设定mysql为“服务”方式启动:
MS-DOS下,输入:

C:\>cd apache\mysql\bin
C:\>apache\mysql\bin>mysqld-nt --install

以后开机时就自动执行mysql了,和apache一样,启动mysql时也可以在 DOS 下输入: net start

mysql关闭mysql时输入: net stop mysql


phpMyAdmin

将phpMyAdmin的zip文件解压缩到C:\www\apache\htdocs\localsql\和C:\www\apache\htdocs\serversql\目录下


编辑localsql内的Config.inc.php

$cfg[''PmaAbsoluteUri''] = ''http://localhost/localsql/'';

$cfg[''Servers''][$i][''host''] = ''localhost''; // MySQL hostname
$cfg[''Servers''][$i][''port''] = ''3306''; // MySQL port - leave blank for default port
$cfg[''Servers''][$i][''socket''] = ''''; // Path to the socket - leave blank for default socket
$cfg[''Servers''][$i][''connect_type''] = ''tcp''; // How to connect to MySQL server (''tcp'' or ''socket'')
$cfg[''Servers''][$i][''compress''] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg[''Servers''][$i][''controluser''] = ''''; // MySQL control user settings
// (this user must have read-only
$cfg[''Servers''][$i][''controlpass''] = ''''; // access to the "mysql/user"
// and "mysql/db" tables)
$cfg[''Servers''][$i][''auth_type''] = ''config''; // Authentication method (config, http or cookie based)?
$cfg[''Servers''][$i][''user''] = ''root''; // MySQL user
$cfg[''Servers''][$i][''password''] = ''''; // MySQL password (only needed
// with ''config'' auth_type)
$cfg[''Servers''][$i][''only_db''] = '''';




编辑serversql内的Config.inc.php

$cfg[''PmaAbsoluteUri''] = ''http://localhost/serversql/'';

$cfg[''Servers''][$i][''host''] = ''192.168.0.1''; // MySQL hostname
$cfg[''Servers''][$i][''port''] = ''3306''; // MySQL port - leave blank for default port
$cfg[''Servers''][$i][''socket''] = ''''; // Path to the socket - leave blank for default socket
$cfg[''Servers''][$i][''connect_type''] = ''tcp''; // How to connect to MySQL server (''tcp'' or ''socket'')
$cfg[''Servers''][$i][''compress''] = FALSE; // Use compressed protocol for the MySQL connection
// (requires PHP >= 4.3.0)
$cfg[''Servers''][$i][''controluser''] = ''''; // MySQL control user settings
// (this user must have read-only
$cfg[''Servers''][$i][''controlpass''] = ''''; // access to the "mysql/user"
// and "mysql/db" tables)
$cfg[''Servers''][$i][''auth_type''] = ''config''; // Authentication method (config, http or cookie based)?
$cfg[''Servers''][$i][''user''] = ''winname''; // MySQL user
$cfg[''Servers''][$i][''password''] = ''''; // MySQL password (only needed
// with ''config'' auth_type)
$cfg[''Servers''][$i][''only_db''] = '''';


这样,当Windows和FreeBSD上的apache和mysql运行着的时候,在Windows的IE地址栏中输入:

http://localhost/localsql/index.php

时,连入Windows上的mysql;

输入:

http://localhost/serversql/index.php

时,则连入FreeBSD上的mysql;

这样,你就可以同时管理调试用的和正式使用的两个数据库了。


至此,你完成了组网的基本过程。当然,根据你的实际情况重新编译内核是必要的,在这里不再累数。
可算完了,不好意思,还有几句废话:


1 个人使用的带宽少的可怜,就不要一边运行服务器,一边在Windows上看在线电影,打在线游戏和长时间下载了,当然你要是Money充足,拉

个百兆专线,我强烈建议你做以上所有事情,否则就白瞎了,呵呵。

2 一般的PC与好的专业服务器的性能是没法比的,再者即使你有最好的专业服务器,没有带宽也是白搭。

3 带宽垄断终究是不会长久的,现在日本的个人家庭ADSL的传输速率是:12Mbps/1Mbps,上行1Mbps达不到我想800kbps还是能达到的,包月费

折合人民币不到280元,未来的趋势可见一斑。

4 作服务器的PC,建议使用:

P4 CPU
Maxtor ATA133 Disk

选择主板要注意:

FSB与内存总线的搭配
南北桥总线的传输率
支持ATA133

当然,你要做IDE的RAID就更象服务器了。

5 以上为个人体会与借鉴他人体会的总结,难免有不妥之处,请不吝指正。

6 转载请注明E-mail和名字。

cheentong@up369.com

cheentong from HarBin

http://netadmin.77169.com/HTML/20040607223600.html
0
相关文章