欢迎光临TRip的专栏

--焦急的等待燃烧的刹那

曹宇ID:trip
85762次访问,排名997好友0人,关注者2
trip的文章
原创 75 篇
翻译 0 篇
转载 1 篇
评论 9 篇
待燃的烟头的公告
声明:本Blog的部分文章是费尽千辛万苦从全国各地搜刮而来的,版权归原作者所有.
点击发送消息给我 QQ : 10245499
最近评论
agjyfm:wow gold
xiaohang99:我在网上找了好久,好不容易找到了您blog里收藏的php rsa代码,以下是我写的一段程序,可是rsa加密出来的使用是乱码,我郁闷了,请老大您不吝指点
<?
include("rsa.php");
//p:4133935801205863
//q:391939488017981
//n:16202526814238280264……
TOM:我想要一个直接可以运行的代码,可以给我吗!非常感谢!
E-mail:pulanhui@hotmail.com 狂等!
kus:但也许是我的问题,有的地方老是调试不通
6yhgyknyji:kjyujhklihmjolkomkmjliojhjkjkjkl
文章分类
收藏
    相册
    DOwnlOAd
    Java资料收集
    Eclipse 3 + Lomboz 3 + Tomcat 5 开发网站
    Eclipse, Lomboz and Tomcat 的 JSP 调试
    Eclipse, Lomboz and Tomcat 的 Web Project 设置
    IBM JAVA技术专区
    SUN 社区论坛
    吴蔚文集
    Linux相关
    Linux AS 3 中文手册
    linux资源站(EN)
    中国网关联盟论坛
    开源软件国际化·简体中文组
    Lotus资源
    OA软件联盟
    PHP相关Blog
    "阿信"的javascript强站!
    Haohappy的专栏--PHP5研究中心--
    paulgao-高春辉
    PHP&More 杂志 Wiki
    PHP5研究中心
    PHP5研究室
    PHP中文站(RSS)
    存档
    软件项目交易
    订阅我的博客
    XML聚合  FeedSky
    订阅到鲜果
    订阅到Google
    订阅到抓虾
    订阅到BlogLines
    订阅到Yahoo
    订阅到GouGou
    订阅到飞鸽
    订阅到Rojo
    订阅到newsgator
    订阅到netvibes

    原创 FreeBSD网站平台建设全过程收藏

    新一篇: win2000 2003命令大全

    (一、系统安装)

    前言

    写本文的初衷主要是记录下我一段时间学习使用FreeBSD建设网站平台的一些经验和体会。因为本人是菜鸟,所以很多地方不够完善。本文权当给初学者提供一个具体可操作的实例。所有操作步骤都是我边做边写。避免出现遗漏或一些不必要的小错误,给初学者带来麻烦。
    本网站平台建设全过程包括FreeBSD系统的安装,web、ftp、mail、proxy服务器、视频点播服务器等。所有过程都在FreeBSD4.7环境下测试通过。
    由于写本文时参考了网上太多前辈和大侠的资料,无法一一列举。还请作者原谅。
    本连载文章前后关联很紧密,建议初学者一步一步来做。
    试验环境如下:
    硬件环境:普通pc机,双网卡。配制不需要高,主要是稳定,并能适应长时间开机。听前辈介绍AMD k6的cpu运行FreeBSD好像有点问题。不过我没有试验。建议用intel的。
    软件环境:操作系统:FreeBSD4.7(4.8)
    web服务器:Apache 1.3.27+modssl +mod_php4+mod_gzip+mod_fastcgi +mod_perl +mysql3.23
    ftp服务器:Proftpd1.2.7+proftpd-mod-quotatab-1.2.4+mysql
    mail服务器: iceblood前辈制作的qmail安装包(经过修改)+vqregister-2.5
    proxy服务器:使用FreeBSD内置的NAT和PPP拨号+squid
    视频点播服务器:Helix Universal Servevr (realserver9.01)
    网络环境:我用的是adsl动态拨号方式,因为动态ip所存在的一些问题,我把所有的服务都装在一台机器上,且这台机器要直接与外网相连。静态ip更方便一些。(本文两种方式都会讨论)

    第一步:安装系统
    关于安装过程网上有很多文章,这里不作详述。仅提出几点建议供大家参考:
    1、 采用最小化安装。
    2、 安装时启用inetd,并在编辑inetd.conf文件时,把带有“ftp”的行前面的“#”号去掉。这样作是为了以后安装软件时可以用ftp上传文件。
    3、 添加一个wheel组的用户,这样在系统工作正常后可以在windows系统上通过终端登录软件(如SecureCRT)进行所有操作。FreeBSD4.7在最小安装时支持SSH终端登录,所以我们需要使用支持SSH协议的终端软件,如SecureCRT。例如我添加的用户名是ylf,隶属wheel系统组。系统产生一个用户目录/home/ylf。我可以通过SecureCRT以ylf身份登录到系统,然后通过su命令切换到root用户。同时我也可以在IE浏览器内键入[url]ftp://192.168.0.1[/url] ,并输入ylf用户名和密码登录ftp将需要的文件上传到自己的用户目录里。(192.168.0.1是我的服务器连接内网的网卡ip地址)。以下除系统安装部分,我都是采用终端方式操作。
    4、 分区时将/home、/usr和/var划的大一些,因为/usr为程序目录,/var要存放日志,/home是用户主目录,我的用户文件如网页、ftp上传文件等都放在这里。还有最好保留一部分空间留作以后需要的时候用。我的机器上有2块硬盘,一快18.2G SCSI硬盘,一块40G IDE硬盘。我是这样划分的。
    128M /
    20G /home
    2G /ftp
    256M /tmp
    6G /usr
    5G /var
    其中/ftp是为匿名ftp用户访问专用。剩余空间留作备用。当然如果硬盘空间少的话,做我们的试验也是够用的。
    关于安装方面的文章,大家也可以参考delphij写的《FreeBSD服务器的安装与优化》。[url]http://community.freebsdchina.org/catalog.php?forum=34[/url] 一文。
    安装完系统后,要重新编译内核。目的是要系统支持Firrwall和提高运行效率。
    首先确认系统是否安装了FreeBSD的内核支持。如果是最小安装,则需要运行/stand/sysinstall命令安装内核支持。方法如下:
    # /stand/sysinstall
    选Configure—Distributions—src—sys,内核文件将被安装在/usr/src/sys目录中。
    注意:这之后的过程在终端上操作要方便许多。SecureCRT支持在终端界面上直接拷贝和粘贴文本内容。
    转到内核文件目录
    # cd /usr/src/sys/i386/conf
    编辑内核文件
    # vi kernel_wwwx # kernel_wwwx为我的内核文件名
    我的内核文件如下:
    #
    # GENERIC -- Generic kernel configuration file for FreeBSD/i386
    #
    # For more information on this file, please read the handbook section on
    # Kernel Configuration Files:
    #
    #[url]http://www.FreeBSD.org/doc/en_US.IS...fig-config.html[/url]
    #
    # The handbook is also available locally in /usr/share/doc/handbook
    # if you've installed the doc distribution, otherwise always see the
    # FreeBSD World Wide Web server ([url]http://www.FreeBSD.org/)[/url] for the
    # latest information.
    #
    # An exhaustive list of options and more detailed explanations of the
    # device lines is also present in the ./LINT configuration file. If you are
    # in doubt as to the purpose or necessity of a line, check first in LINT.
    #
    # $FreeBSD: src/sys/i386/conf/GENERIC,v 1.246.2.48 2002/08/31 20:28:26 obrien Exp $

    machine i386
    cpu I586_CPU
    cpu I686_CPU
    ident kernel_wwwx #内核文件名,这个要和你的内核文件名一致
    maxusers 0

    options INET #InterNETworking
    options FFS #Berkeley Fast Filesystem
    options FFS_ROOT #FFS usable as root device [keep this!]
    options SOFTUPDATES #Enable FFS soft updates support
    options UFS_DIRHASH #Improve performance on big directories
    options PROCFS #Process filesystem
    options COMPAT_43 #Compatible with BSD 4.3 [KEEP THIS!]
    options SCSI_DELAY=15000 #Delay (in ms) before probing SCSI
    options SYSVSHM #SYSV-style shared memory
    options SYSVMSG #SYSV-style message queues
    options SYSVSEM #SYSV-style semaphores
    options P1003_1B #Posix P1003_1B real-time extensions
    options _KPOSIX_PRIORITY_SCHEDULING
    options ICMP_BANDLIM #Rate limit bad replies
    options AHC_REG_PRETTY_PRINT # Print register bitfields in debug
    # output. Adds ~128k to driver.
    options AHD_REG_PRETTY_PRINT # Print register bitfields in debug
    # output. Adds ~215k to driver.

    device tun 1
    options IPFIREWALL #防火墙
    options IPFIREWALL_FORWARD #允许透明代理
    options IPFIREWALL_VERBOSE #允许防火墙日志
    options IPFIREWALL_VERBOSE_LIMIT=100 #限制日志
    options IPFIREWALL_DEFAULT_TO_ACCEPT #默认允许所有IP包
    options IPDIVERT #启用由ipfw divert使用的转向IP套接字

    # To make an SMP kernel, the next two are needed
    #options SMP # Symmetric MultiProcessor Kernel
    #options APIC_IO # Symmetric (APIC) I/O

    device isa
    device eisa
    device pci


    # ATA and ATAPI devices
    device ata
    device atadisk # ATA disk drives


    # SCSI Controllers #没有SCSI设备不需要这段
    device ahb # EISA AHA1742 family
    device ahc # AHA2940 and onboard AIC7xxx devices
    device ahd # AHA39320/29320 and onboard AIC79xx devices
    device amd # AMD 53C974 (Tekram DC-390(T))
    device isp # Qlogic family
    device mpt # LSI-Logic MPT/Fusion
    device ncr # NCR/Symbios Logic
    device sym # NCR/Symbios Logic (newer chipsets)
    options SYM_SETUP_LP_PROBE_MAP=0x40
    # Allow ncr to attach legacy NCR devices when
    # both sym and ncr are configured

    device adv0 at isa?
    device adw
    device bt0 at isa?
    device aha0 at isa?
    device aic0 at isa?

    device ncv # NCR 53C500
    device nsp # Workbit Ninja SCSI-3
    device stg # TMC 18C30/18C50

    # SCSI peripherals #没有SCSI设备不需要这段
    device scbus # SCSI bus (required)
    device da # Direct Access (disks)
    device sa # Sequential Access (tape etc)
    device cd # CD
    device pass # Passthrough device (direct SCSI access)



    # atkbdc0 controls both the keyboard and the PS/2 mouse
    device atkbdc0 at isa? port IO_KBD
    device atkbd0 at atkbdc? irq 1 flags 0x1

    device vga0 at isa?


    # syscons is the default console driver, resembling an SCO console
    device sc0 at isa? flags 0x100


    # Floating point support - do not disable.
    device npx0 at nexus? port IO_NPX irq 13


    # Serial (COM) ports
    device sio0 at isa? port IO_COM1 flags 0x10 irq 4

    # 我用的是8139和Dlink DFE-530TX网卡,大家可根据自己的网卡型号保留或删除
    # 使用公共的MII总线控制器代码的PCI以太网适配器
    # 注意:一定要保留'device miibus'以确保可用
    # PCI Ethernet NICs that use the common MII bus controller code.
    # NOTE: Be sure to keep the 'device miibus' line in order to use these NICs!
    device miibus # MII bus support
    device fxp # Intel EtherExpress PRO/100B (82557, 82558)
    device rl # RealTek 8129/8139
    device vr # VIA Rhine, Rhine II
    device xl # 3Com 3c90x (``Boomerang'', ``Cyclone'')

    # Pseudo devices - the number indicates how many units to allocate.
    pseudo-device loop # Network loopback
    pseudo-device ether # Ethernet support
    pseudo-device sl 1 # Kernel SLIP
    pseudo-device ppp 1 # Kernel PPP
    pseudo-device tun # Packet tunnel.
    pseudo-device pty # Pseudo-ttys (telnet etc)
    pseudo-device md # Memory "disks"
    pseudo-device gif # IPv6 and IPv4 tunneling
    pseudo-device faith 1 # IPv6-to-IPv4 relaying (translation)

    # The `bpf' pseudo-device enables the Berkeley Packet Filter.
    # Be aware of the administrative consequences of enabling this!
    pseudo-device bpf #Berkeley packet filter
    (完)

    我用的是8139网卡和Dlink DFE-530TX网卡,如果你用其他型号的网卡,需要察看当前目录的GENERIC 内核文件,找到描述自己的网卡型号的段并将其添加到新的内核文件里。其他的不改直接拷贝过来就可以用了。
    接下来编译安装新内核:
    # /usr/sbin/config kernel_wwwx #kernel_wwwx为你的内核文件名
    # cd ../../compile/kernel_wwwx
    # make depend
    # make
    # make install
    重新启动(reboot)

    如果系统升级过源代码树,按下面方法编译内核:
    # cd /usr/src
    # make kernel KERNCONF=kernel_wwwx #kernel_wwwx为你的内核文件名
    重新启动

    FreeBSD网站平台建设全过程(二、接入Internet并配制代理服务)

    使用adsl接入Internet有两种情况,通过拨号获取动态ip或服务商直接给定静态ip。后者配制起来较容易。本文先讨论动态ip如何设置。
    由于第一步重新编译内核时已经加进了对Firewall的支持。这里就可以通过直接编辑/etc/ppp/ppp.conf文件和/etc/rc.conf文件就可以上网并支持NAT方式透明代理了。
    # vi /etc/ppp/ppp.conf
    我的ppp.conf文件内容如下:(注意set前要留空格)
    default:
    set log Phase tun command
    set ifaddr 10.0.0.1/0 10.0.0.2/0
    adsl: # 配置代号
    set device PPPoE:vr0 # vr0 改成你连接ADSL modem的网卡名
    set mru 1492
    set mtu 1492
    set authname username # username是拨号用户名
    set authkey password # password是拨号密码
    set dial
    set login
    add default HISADDR
    (完)

    # vi /etc/rc.conf
    我的rc.conf文件内容如下:(动态ip)
    # -- sysinstall generated deltas -- # Tue Jul 15 21:20:28 1997
    # Created: Tue Jul 15 21:20:28 1997
    # Enable network daemons for user convenience.
    # Please make all changes to this file, not to /etc/defaults/rc.conf.
    # This file now contains just the overrides from /etc/defaults/rc.conf.
    hostname="wwwx.3322.org" # 你的主机域名
    ifconfig_fxp0="inet 192.168.0.1 netmask 255.255.255.0" #内网网卡ip地址,fxp0是网卡名
    inetd_enable="YES" # 开机加载inetd
    kern_securelevel_enable="NO"
    linux_enable="YES"
    nfs_reserved_port_only="NO"
    sendmail_enable="NO"
    sshd_enable="YES"
    usbd_enable="NO"
    gateway_enable="YES"
    firewall_enable="YES" #启用防火墙
    firewall_script="/etc/rc.firewall"
    firewall_type="open"
    firewall_quiet="YES"
    firewall_logging_enable="YES"
    ppp_enable="YES" # 开机自动拨号
    ppp_mode="ddial"
    ppp_nat="YES" # 启用透明代理
    ppp_profile="adsl" # 配置代号
    # -- sysinstall generated deltas -- # Wed Jul 16 06:52:13 1997
    (完)

    这样重新启动后就可以拨号上网并实现透明代理了。客户端需要设置dns服务器为服务商提供的dns,网关设成代理服务器的内网卡ip地址,这里是192.168.0.1。并把IE中“internet选项”关于连接设置的所有复选框清除。
    如果解析不了域名,检查一下/etc/resolv.conf文件是否加入了正确的dns服务器地址。

    如果是静态ip方式,则只需要编辑/etc/rc.conf文件。
    我的/etc/rc.conf文件如下:(静态ip)
    # -- sysinstall generated deltas -- # Tue Jul 15 21:20:28 1997
    # Created: Tue Jul 15 21:20:28 1997
    # Enable network daemons for user convenience.
    # Please make all changes to this file, not to /etc/defaults/rc.conf.
    # This file now contains just the overrides from /etc/defaults/rc.conf.
    hostname="wwwx.3322.org" #主机域名
    defaultrouter="218.10.104.1" #服务商提供的路由器地址
    ifconfig_vr0="inet 218.10.104.188 netmask 255.255.255.0" #服务商提供的静态ip
    ifconfig_fxp0="inet 192.168.0.1 netmask 255.255.255.0" #内部网卡ip
    inetd_enable="YES" #开机加载inetd
    kern_securelevel_enable="NO"
    linux_enable="YES"
    nfs_reserved_port_only="NO"
    sshd_enable="YES"
    sendmail_enable="NO"
    usbd_enable="NO"
    gateway_enable="YES"
    firewall_enable="YES"
    firewall_script="/etc/rc.firewall"
    firewall_type="open"
    firewall_quiet="YES"
    firewall_logging_enable="YES"
    natd_enable="YES" # 启用透明代理
    natd_interface="vr0" # natd接口,vr0为连接外网modem的网卡
    # -- sysinstall generated deltas -- # Wed Jul 16 06:52:13 1997
    (完)

    重起后网络连接及透明代理生效。客户端同样要按上面说的方法配制。

    使用Squid:
    Squid是一个非常不错的代理缓存软件。我曾经一直在使用,后来因为我经常要改变web服务器里的网页,而Squid总是把我以前的页面缓存,致使不能马上反映页面的更新情况,再加上公司上网的负担不是很重。所以就不用了。
    安装方法:
    在FreeBSD下安装软件最方便的方法是使用ports。本文为了让大家对通用的软件安装方法做一定的了解,我们采用通用的方法来安装squid,也就是说,下面的方法同样适用于linux或其他unix版本。

    在ylf的用户目录下创建目录app用来存放程序安装临时文件:
    # mkdir /home/ylf/app
    将用户ylf设为/home/ylf/app目录及其子目录的所有者
    # chown –R ylf /home/ylf/app
    到[url]http://www.squid-cache.org/Versions/v2/2.5/[/url] 下载squid 的最新稳定版本,现在是squid-2.5.STABLE3
    打开IE浏览器,在地址栏输入[url]ftp://192.168.0.1[/url] ,出现ftp登陆对话框,输入用户名ylf及密码,登录成功后。将下载的squid-2.5.STABLE3复制到app目录中。
    执行如下命令:
    # cd /home/ylf/app
    # tar zxvf squid-2.5.STABLE3.tar.gz #解压缩安装包
    # cd squid-2.5.STABLE3 #进入解开的目录
    # ./configure --prefix=/usr/local/squid #配制、将squid安装在/usr/local/squid目录
    # make all #编译
    # make install #安装
    下面编辑squid的配置文件:
    # cd /usr/local/squid/etc
    将原来的配置文件改名
    # mv squid.conf squid.conf.bak
    编辑新的配置文件
    # vi squid.conf
    我的squid.conf内容如下:

    #取消对代理阵列的支持
    icp_port 0

    #对日志文件和pid文件位置进行设置
    cache_store_log none
    cache_access_log /usr/local/squid/var/logs/access.log
    cache_log /usr/local/squid/var/logs/cache.log
    emulate_httpd_log on
    pid_filename /usr/local/squid/var/logs/squid.pid

    #设置运行时的用户和组权限
    cache_effective_user squid
    cache_effective_group squid

    #设置管理信息
    visible_hostname wwwx.3322.org.
    cache_mgr [email]yourname@yourdomain.com[/email]

    #设置监听地址和端口
    http_port 3128
    udp_incoming_address 0.0.0.0

    #设置squid用户hot object的物理内存的大小以及设置cache目录
    cache_mem 32 MB
    cache_dir ufs /usr/local/squid/cache 1024 16 256

    #访问控制设置
    acl mynet src 192.168.0.0/255.255.255.0
    acl all src 0.0.0.0/0.0.0.0
    http_access allow mynet
    http_access deny all

    #透明代理设置
    httpd_accel_host virtual
    httpd_accel_port 80
    httpd_accel_with_proxy on
    httpd_accel_uses_host_header on

    #swap 性能微调
    half_closed_clients off
    cache_swap_high 100%
    cache_swap_low 80%
    maximum_object_size 1024 KB

    #控制对象的超时时间
    refresh_pattern -i .html 1440 90% 129600 reload-into-ims
    refresh_pattern -i .shtml 1440 90% 129600 reload-into-ims
    refresh_pattern -i .hml 1440 90% 129600 reload-into-ims
    refresh_pattern -i .gif 1440 90% 129600 reload-into-ims
    refresh_pattern -i .swf 1440 90% 129600 reload-into-ims
    refresh_pattern -i .jpg 1440 90% 129600 reload-into-ims
    refresh_pattern -i .png 1440 90% 129600 reload-into-ims
    refresh_pattern -i .bmp 1440 90% 129600 reload-into-ims
    refresh_pattern -i .js 1440 90% 129600 reload-into-ims
    (完)

    需要改的地方是访问控制设置中的子网改成你自己的子网。其他的地方可根据需要调整。不改也可。
    如果不使用日志,将日志设置部分改成如下句子:
    cache_store_log none
    cache_access_log /dev/null
    cache_log /dev/null

    添加squid系统用户和组
    # pw groupadd squid
    # pw useradd squid -g squid -s /sbin/nologin
    建立cache目录
    # mkdir /usr/local/squid/cache
    改变cache目录和logs目录的所有者为squid用户和组
    # chown –R squid /usr/local/squid/cache
    # chgrp –R squid /usr/local/squid/cache
    # chown –R squid /usr/local/squid/var/logs
    # chgrp –R squid /usr/local/squid/var/logs
    运行squid –z建立cache目录结构
    # /usr/local/squid/sbin/squid –z

    测试squid运行情况
    # /usr/local/squid/sbin/squid –NCd1
    出现下面显示证明squid安装成功
    2003/06/21 18:01:09| Starting Squid Cache version 2.5.STABLE3 for i386-unknown-freebsd4.7...
    2003/06/21 18:01:09| Process ID 160
    2003/06/21 18:01:09| With 957 file descriptors available
    2003/06/21 18:01:09| Performing DNS Tests...
    2003/06/21 18:01:09| Successful DNS name lookup tests...
    2003/06/21 18:01:09| DNS Socket created at 0.0.0.0, port 1029, FD 4
    2003/06/21 18:01:09| Adding nameserver 202.97.224.68 from /etc/resolv.conf
    2003/06/21 18:01:09| Unlinkd pipe opened on FD 9
    2003/06/21 18:01:09| Swap maxSize 1048576 KB, estimated 80659 objects
    2003/06/21 18:01:09| Target number of buckets: 4032
    2003/06/21 18:01:09| Using 8192 Store buckets
    2003/06/21 18:01:09| Max Mem size: 32768 KB
    2003/06/21 18:01:09| Max Swap size: 1048576 KB
    2003/06/21 18:01:09| Store logging disabled
    2003/06/21 18:01:09| Rebuilding storage in /usr/local/squid/cache (DIRTY)
    2003/06/21 18:01:09| Using Least Load store dir selection
    2003/06/21 18:01:09| Current Directory is /usr/local/squid/etc
    2003/06/21 18:01:09| Loaded Icons.
    2003/06/21 18:01:09| Accepting HTTP connections at 0.0.0.0, port 3128, FD 8.
    2003/06/21 18:01:09| WCCP Disabled.
    2003/06/21 18:01:09| Ready to serve requests.
    2003/06/21 18:01:16| Done scanning /usr/local/squid/cache swaplog (0 entries)
    2003/06/21 18:01:16| Finished rebuilding storage from disk.
    2003/06/21 18:01:16| 0 Entries scanned
    2003/06/21 18:01:16| 0 Invalid entries.
    2003/06/21 18:01:16| 0 With invalid flags.
    2003/06/21 18:01:16| 0 Objects loaded.
    2003/06/21 18:01:16| 0 Objects expired.
    2003/06/21 18:01:16| 0 Objects cancelled.
    2003/06/21 18:01:16| 0 Duplicate URLs purged.
    2003/06/21 18:01:16| 0 Swapfile clashes avoided.
    2003/06/21 18:01:16| Took 7.3 seconds ( 0.0 objects/sec).
    2003/06/21 18:01:16| Beginning Validation Procedure
    2003/06/21 18:01:16| Completed Validation Procedure
    2003/06/21 18:01:16| Validated 0 Entries
    2003/06/21 18:01:16| store_swap_size = 0k
    2003/06/21 18:01:17| storeLateRelease: released 0 object
    否则根据提示检查配制文件。

    为了使squid的透明代理起作用,需要设置端口转发。方法如下:
    编辑/etc/rc.firewall文件,添加下面一句
    ipfw add 00500 fwd 127.0.0.1,3128 tcp from 192.168.0.0/24 to any 80

    下面建立squid的启动脚本squid.sh:
    首先建立/usr/local/etc/rc.d目录
    # mkdir /usr/local/etc
    # mkdir /usr/local/etc/rc.d
    # cd /usr/local/etc/rc.d
    # vi squid.sh
    文件内容如下:
    #!/bin/sh

    #if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
    # echo "$0: Cannot determine the PREFIX" >&2
    # exit 1
    #fi

    case "$1" in
    start)
    if [ -x /usr/local/squid/sbin/squid -a -f /usr/local/squid/etc/squid.conf ]; then
    (cd /usr/local/squid/var/logs; /usr/local/squid/sbin/squid >/dev/null 2>&1 &) ; echo -n ' squid'
    fi
    ;;
    stop)
    /usr/local/squid/sbin/squid -k shutdown 2>&1
    # Uncomment this if you'd like the system to (attempt to
    # wait for) squid to shut down cleanly
    #echo "Sleeping for 45 seconds to allow squid to shutdown.."
    #sleep 45
    ;;
    *)
    echo "Usage: `basename $0` {start|stop}" >&2
    ;;
    esac

    exit 0
    (完)

    这样每次启动后,squid就会自动运行。
    运行/usr/local/etc/rc.d/squid.sh start 启动squid
    运行/usr/local/etc/rc.d/squid.sh stop 停止squid

    关于域名的问题
    如果需要对外提供www服务,域名必不可少。域名分静态和动态域名两种,网上提供二级免费域名的站点有很多,本文例子的域名wwwx.3322.org就是在希网申请的( [url]http://www.3322.org[/url] )。希网同时提供支持FreeBSD客户端的动态域名服务。如果是使用拨号上网的情况,则需要使用动态域名服务。由于拨号方式获得的ip地址是变化的,因此动态域名需要每次拨号上网后,客户端运行域名更新程序与服务端联系,使得申请的域名可以随时指向变化的ip地址,以完成动态域名解析服务。希网的网站上提供了详细的在FreeBSD上安装动态域名客户程序的方法,详情参见[url]http://www.3322.org/help/help_service.html#service_3[/url] 。大家可以到那里去下载客户程序并按照说明安装。另外一个比较好的提供免费动态域名服务的网站是科迈网,他们的动态域名可以支持内网机器的域名解析。详细内容大家可以到他们的网站上去看,[url]http://www.dns0755.net[/url] 。

    第三步:安装配置web服务器

    注意:在进行这步操作前建议把squid关掉,因为在进行主页更新测试时squid的cache会使更新后的主页不能及时反映出来!
    为了不使用squid,除了关掉squid外,还要删除ipfw的透明代理端口转发语句:
    # cd /usr/local/etc/rc.d
    # ./squid.sh stop
    # mv squid.sh squid.sh.bak
    # ipfw del 500 fwd 127.0.0.1,3128 tcp from 192.168.0.0/24 to any 80

    本web服务器的其本组成为
    Apache 1.3.27+modssl +mod_php4+mod_gzip+mod_fastcgi +mod_perl +mysql3.23

    为了简化安装过程并发挥FreeBSD安装软件的优势,本文后续部分将采用ports安装。Ports 使在FreeBSD下安装各种软件变得很轻松。

    首先安装ports:(如果已经有/usr/ports目录则证明已经安装过了)
    # /stand/sysinstall
    选Configure—Distributions—ports,ports将被安装在/usr/ports目录中。

    下面安装apache1.3.27+modssl
    # cd /usr/ports/www/apache13-modssl
    # make install
    系统会自动下载安装包并安装完毕。
    安装后系统会自动产生启动脚本apache.sh,在/usr/local/etc/rc.d目录中。可以通过运行apache.sh start|stop来启动或停止apache。

    安装mysql3.23:
    # cd /usr/ports/databases/mysql323-server
    # make install
    安装后产生启动脚本/usr/local/etc/rc.d/mysql-server.sh

    安装apache模块mod_php4:
    # cd /usr/ports/www/mod_php4
    首先编辑scripts目录下的configure.php文件,加入对OpenSSL的支持
    # vi scripts/configure.php
    找到下面一句
    OpenSSL "OpenSSL support" ON \
    改成
    OpenSSL "OpenSSL support" YES \

    # make install
    出现对话框时直接选ok继续

    安装完成后编辑apache的配制文件/usr/local/etc/apache/httpd.conf ,添加如下内容:

    # 设置默认可以使用的主页名称,这句系统一般已经有了,不用添加了
    DirectoryIndex index.php index.html

    # 这2句需要手工添加
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps

    安装其他apache常用模块mod_gzip+mod_fastcgi +mod_perl

    # cd /usr/ports/www/mod_gzip
    # make install

    # cd /usr/ports/www/mod_fastcgi
    # make install
    编辑/usr/local/etc/apache/httpd.conf文件
    添加下面一句
    AddHandler fastcgi-script fcgi fcgi fpl

    # cd /usr/ports/www/mod_perl
    # make install

    重新启动让所有软件自动运行。

    测试
    首先以root身份执行线程察看命令top,列表中应该有下面几个线程正在运行:
    PID USERNAME PRI NICE SIZE RES STATE COMMAND
    69 root 2 0 440K 296K select natd # 网络地址转换进程
    132 root 2 0 3692K 3052K select httpd # apache进程
    166 mysql 2 0 27480K 4824K poll mysqld # mysql进程
    在浏览器地址栏输入[url]http://192.168.0.1[/url] ,如果显示apache的欢迎页面,证明web服务器安装成功!web页面文件存放在/usr/local/www/data目录中,你可以把自己的网页拷贝到这个目录,就可以访问自己的主页了!
    键入命令
    # mysql
    出现下面显示证明mysql安装成功!
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 2 to server version: 3.23.52

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql>
    键入exit退出mysql。

    为mysql的root用户设置一个口令123456
    # mysqladmin -u root password '123456'

    现在我们来安装一个支持php+mysql的论坛。到[url]http://www.faeryboard.com/[/url]去下载完美版的仙境论坛程序。将下载的rar压缩包解开,然后使用ftp上传到/home/ylf/app目录。

    事先备份web服务器演示页面
    # cd /usr/local/www/data
    # mkdir backup
    # mv * backup

    将论坛程序拷贝到/usr/local/www/data目录
    # cd /home/ylf/app/vbb2.3.0final
    # cp –r * /usr/local/www/data
    编辑论坛配置文件
    # vi /usr/local/www/data/admin/config.php
    内容如下
    ^M
    /////////////////////////////////////////////////////////////^M
    // Please note that if you get any errors when connecting, //^M
    // that you will need to email your host as we cannot tell //^M
    // you what your specific values are supposed to be //^M
    /////////////////////////////////////////////////////////////^M
    ^M
    // type of database running^M
    // (only mysql is supported at the moment)^M
    $dbservertype='mysql';^M #数据库类型
    ^M
    // hostname or ip of server^M
    $servername='localhost';^M #主机名
    ^M
    // username and password to log onto db server^M
    $dbusername='root';^M #登录数据库用户
    $dbpassword='123456';^M #密码
    ^M
    // name of database^M
    $dbname='fin230';^M #论坛所使用的数据库名称
    ^M
    // technical email address - any error messages will be emailed here^M
    $technicalemail='[email]webmaster@yoursite.com[/email]';^M #管理信息
    ^M
    // use persistant connections to the database^M
    // 0 = don't use^M
    // 1 = use^M
    $usepconnect=1;^M
    ^M
    ?>
    (完)

    除了root用户的密码需要添入外,其他部分可以不改。
    保存后,在浏览器地址栏输入[url]http://192.168.0.1/admin/install.php[/url] ,根据提示一步步安装即可。
    安装成功后,在在浏览器地址栏输入[url]http://192.168.0.1[/url] ,就可以看到论坛了!怎么样,挺漂亮吧!关于论坛的其他问题,请仔细看论坛安装包里面的说明文档,或者到仙境论坛的主页,那里有仙境论坛的一切!
    下一节,我们要讨论关于虚拟主机的问题。

    配制虚拟主机:
    Apache的虚拟主机支持有两种方式,一是基于用户访问Apache主机时所使用的域名,另一种是通过指定IP地址来提供。这里我们只介绍如何通过不同的域名来实现虚拟主机的支持。
    要实现基于域名的虚拟主机的前提条件是必须有两个域名同时指向Apache主机的IP地址,这里我们假设这两个域名分别是www01.3322.org和www02.3322.org ,这两个域名的文档都分别放置于 /home/www01 和 /home/www02这两个目录内,同时这两个目录已经设置好权限,对于目录让所有的人都可以读取、运行,对于文件,让所有的人都可以读取。
    以下是具体的配置过程:
    首先到希网去注册2个域名。然后为这2个域名分别建立文档目录
    # mkdir /home/www01
    # mkdir /home/www02

    编辑apache的配制文件httpd.conf
    # vi /usr/local/etc/apache/httpd.conf
    在文件最后找到下面2行




    在2行中间添加如下内容:
    NameVirtualHost * # 指定运行虚拟主机服务的主机ip地址
    # 静态ip方式可以将*替换为你的ip地址,动态ip直接用*即可


    ServerAdmin [email]webmaster@www01.3322.org[/email] #指定WEB管理员的邮箱
    DocumentRoot /home/www01 #指定本虚拟主机的文档目录
    ServerName www01.3322.org #指定本虚拟主机的域名
    ErrorLog /var/wwwlogs/www01.3322.org.error.log #指定错误记录应该存放于那里
    CustomLog /var/wwwlogs/www01.3322.org.log common #指定常规记录应该存放于那里



    ServerAdmin [email]webmaster@www02.3322.org[/email]
    DocumentRoot /home/www02
    ServerName www02.3322.org
    ErrorLog /var/wwwlogs/www02.3322.org.error.log
    CustomLog /var/wwwlogs/www02.3322.org.log common

    (完)

    创建/var/wwwlogs目录
    # mkdir /var/wwwlogs
    重新启动apache
    # /usr/local/etc/rc.d/apache.sh stop
    # /usr/local/etc/rc.d/apache.sh start
    分别在/home/www01和/home/www02目录拷入不同的网页文件进行测试,注意主页名称必须是index.html或index.php

    测试
    确认注册的2个域名已经指向了你的主机ip。
    在浏览器地址栏输入域名[url]http://www01.3322.org[/url] 和[url]http://www02.3322.org[/url] ,如果分别显示你拷入的主页证明虚拟主机配置成功!

    利用上面的方法我们可以建立更多的虚拟主机,甚至对外提供主页空间服务!

    如果要对外提供虚拟主机服务,需要为使用者提供ftp上传功能。下一节我们将讨论如何通过Proftpd1.2.7+proftpd-mod-quotatab-1.2.4+mysql实现带有空间限额和数据库用户验证功能的ftp服务器。

    第四步:安装配置ftp服务器

    由于为每一个需要使用ftp服务的用户建立系统帐户会影响系统的安全,所以我们使用数据库用户进行ftp用户验证。
    系统组成:Proftpd1.2.7+proftpd-mod-quotatab-1.2.4+mysql
    因为ports里没有proftpd-mod-quotatab-1.2.4模块,我们下载源代码安装。
    下载源代码包:(必须下载相同版本的源代码包)
    到[url]http://www.proftpd.org[/url] 或[url]ftp://ftp.servus.at/ProFTPD/distrib/source/proftpd-1.2.7.tar.gz/[/url]。
    到[url]http://www.castaglia.org/proftpd/[/url] 去下载proftpd-mod-quotatab-1.2.4.tar.gz。(1.2.5 版本的mod_quotatab是用在1.2.8rc1上的)
    用ftp将它们上传到/home/ylf/app目录。
    然后解压缩源代码包
    # cd /home/ylf/app
    # tar zxvf proftpd-1.2.7.tar.gz
    # tar zxvf proftpd-mod-quotatab-1.2.4.tar.gz
    进入mod-quotatab目录
    # cd mod_quotatab
    把mod_quotatab中的文件拷贝到proftpd 中的modules 目录中
    # cp * ../proftpd-1.2.7/modules

    在开始运行configure之前,我们要先改动一个文件
    进入 proftpd-1.2.7/contrib 目录
    # cd /home/ylf/app/proftpd-1.2.7/contrib
    修改 mod_sql_mysql.c
    # vi mod_sql_mysql.c
    找到#include 把他该为你实际路径,这里是:
    #include

    然后编译安装
    # cd /home/ylf/app/proftpd-1.2.7
    #./configure --prefix=/usr/local/proftpd --with-modules=mod_sql:mod_sql_mysql:mod_quotatab:mod_quotatab_sql --with-includes=/usr/local/include/mysql --with-libraries=/usr/local/lib/mysql
    # make
    # make install

    进入到proftpd配置文件所在目录
    # cd /usr/local/proftpd/etc
    备份原配置文件
    # mv proftpd.conf proftpd.conf.bak
    然后编辑新的配置文件proftpd.conf
    # vi proftpd.conf
    我的proftpd.conf内容如下:

    # This is a basic ProFTPD configuration file (rename it to
    # 'proftpd.conf' for actual use. It establishes a single server
    # and a single anonymous login. It assumes that you have a user/group
    # "nobody" and "ftp" for normal operation and anon.

    ServerName "ftpx.3322.org"
    ServerType standalone
    DefaultServer on

    # 用户登陆时不显示ftp服务器版本信息
    ServerIdent off

    # Port 21 is the standard FTP port.
    Port 21

    # Umask 022 is a good standard umask to prevent new dirs and files
    # from being group and world writable.
    Umask 022

    MaxLoginAttempts 3
    TimeoutLogin 120
    TimeoutIdle 600
    TimeoutNoTransfer 900
    TimeoutStalled 3600

    MaxClients 100

    #设置每台主机最多并发连接数
    MaxClientsPerHost 3

    AllowOverwrite no
    AllowStoreRestart on
    UseReverseDNS off

    #设置如果shell为空时允许用户登录
    RequireValidShell off

    #将用户限制在自己的主目录下
    DefaultRoot ~ ftpusers
    DefaultRoot ~ FTPGRP

    # To prevent DoS attacks, set the maximum number of child processes
    # to 30. If you need to allow more than 30 concurrent connections
    # at once, simply increase this value. Note that this ONLY works
    # in standalone mode, in inetd mode you should use an inetd server
    # that allows you to limit maximum number of processes per service
    # (such as xinetd).
    MaxInstances 30

    # Set the user and group under which the server will run.
    User FTPUSR
    Group FTPGRP

    # Normally, we want files to be overwriteable.

    AllowOverwrite on


    # A basic anonymous configuration, no upload directories.
    # 匿名登录设置。匿名用户目录为/ftp

    User ftp
    Group ftpusers

    # We want clients to be able to login with "anonymous" as well as "ftp"
    UserAlias anonymous ftp

    # Limit the maximum number of anonymous logins
    MaxClients 10

    # We want 'welcome.msg' displayed at login, and '.message' displayed
    # in each newly chdired directory.
    DisplayLogin welcome.msg
    DisplayFirstChdir .message

    # Limit WRITE everywhere in the anonymous chroot
    #
    # DenyAll
    #



    #数据库联接的信息,FTP是数据库名,localhost是主机名,root是连接数据库的用户名,#123456是密码(如果没有密码留空)
    SQLConnectInfo FTP@localhost root 123456

    #数据库认证的类型
    SQLAuthTypes Backend Plaintext

    #指定用来做用户认证的表的有关信息。("FTPUSERS"和"FTPGRPS"是数据表名字,等一会
    #在下面建立)
    SQLUserInfo FTPUSERS userid passwd uid gid homedir shell
    SQLGroupInfo FTPGRPS groupname gid members

    #数据库的鉴别
    SQLAuthenticate users groups usersetfast groupsetfast

    #如果home目录不存在,则系统会根据它的home项新建一个目录
    SQLHomedirOnDemand on

    #启用磁盘限额
    QuotaDirectoryTally on

    #磁盘限额单位 b"|"Kb"|"Mb"|"Gb"
    QuotaDisplayUnits "Kb"

    QuotaEngine on

    #磁盘限额日志记录
    QuotaLog "/var/log"

    # 打开磁盘限额信息,当登陆FTP帐户后,使用命令 "quote SITE QUOTA" 后可显示当前用#户的磁盘限额
    QuotaShowQuotas on

    #SQL调用语句,不用修改
    SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session, limit_type, bytes_in_avail, bytes_out_avail, bytes_xfer_avail,files_in_avail, files_out_avail, files_xfer_avail FROM quotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"

    SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used, bytes_xfer_used, files_in_used, files_out_used, files_xfer_used FROM quotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"

    SQLNamedQuery update-quota-tally UPDATE "bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1}, bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3}, files_out_used = files_out_used + %{4}, files_xfer_used = files_xfer_used + %{5} WHERE name = '%{6}' AND quota_type = '%{7}'" quotatallies

    SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2}, %{3}, %{4}, %{5}, %{6}, %{7}" quotatallies

    QuotaLimitTable sql:/get-quota-limit
    QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
    (完)

    下面为ftp用户建立相应的数据库和表
    进入mysql数据库命令状态:
    # mysql –p
    提示输入密码

    建立数据库FTP(注意大小写和每句话后面的“;”)
    CREATE DATABASE FTP;

    然后在这个数据库中建立一个用户表FTPUSERS,这个表是必须的:
    use FTP;

    create table FTPUSERS (
    userid TEXT NOT NULL,
    passwd TEXT NOT NULL,
    uid INT NOT NULL,
    gid INT NOT NULL,
    homedir TEXT,
    shell TEXT
    );

    此表格是为了用户认证所需要的,其中userid、passwd是必不可少的,userid是用做FTP服务的用户名;passwd是指此用户的密码;uid是系统用户的ID,也就是所映射的系统用户;gid是所属系统组的ID;homedir是该用户所在的HOME目录;shell可以为该用户指定相应的shell。当然你可以建立更多的字段,例如:用来记录用户登录次数的count,或者是日期的date,如果你对配置熟悉了之后,你可以根据自己的喜欢添加更多的功能。在此就不多讲。

    如果需要更多的功能,可以添加另外一个需要的表:FTPGRPS,也就是确定组的表格,当然也可以不用,这里讲一个它的格式:
    create table FTPGRPS (
    groupname TEXT NOT NULL,
    gid SMALLINT NOT NULL,
    members TEXT NOT NULL
    );
    其中groupname是组的名称,gid是系统组的ID,members是组的成员。注意:多成员,他们之间要用逗号隔开,不能使用空格。

    为FTP用户建立相应的系统用户。
    在本例中,将整个FTP服务只提供一个有效的系统用户FTPUSR和组FTPGRP,当然你也可以设置多个系统用户。但出于安全的考虑,我只设一个,用他来启动FTP daemon,并把所有的FTP用户映射过这个用户。

    先建立FTPGRP组:
    # pw groupadd FTPGRP -g 2001
    建立FTPUSR用户:
    # pw adduser FTPUSR -u 2001 -g 2001 -d /home/FTP -s /sbin/nologin

    为FTPUSR建立HOME,把所有的FTP user 活动空间全放在此目录下:
    # mkdir /home/FTP
    # chown FTPUSR /home/FTP
    # chgrp FTPGRP /home/FTP

    下面为磁盘限额建立数据表:
    # use FTP
    CREATE TABLE quotalimits (
    name VARCHAR(30),
    quota_type ENUM("user", "group", "class", "all") NOT NULL,
    per_session ENUM("false", "true") NOT NULL,
    limit_type ENUM("soft", "hard") NOT NULL,
    bytes_in_avail FLOAT NOT NULL,
    bytes_out_avail FLOAT NOT NULL,
    bytes_xfer_avail FLOAT NOT NULL,
    files_in_avail INT UNSIGNED NOT NULL,
    files_out_avail INT UNSIGNED NOT NULL,
    files_xfer_avail INT UNSIGNED NOT NULL
    );

    CREATE TABLE quotatallies (
    name VARCHAR(30) NOT NULL,
    quota_type ENUM("user", "group", "class", "all") NOT NULL,
    bytes_in_used FLOAT NOT NULL,
    bytes_out_used FLOAT NOT NULL,
    bytes_xfer_used FLOAT NOT NULL,
    files_in_used INT UNSIGNED NOT NULL,
    files_out_used INT UNSIGNED NOT NULL,
    files_xfer_used INT UNSIGNED NOT NULL
    );

    说明一下,quotatallies表不需要作修改,它记录了用户当前的磁盘使用情况,由程序自动记录
    要注意的是quotalimits 表中一些字段的含意
    quota_type 磁盘限额的鉴别,可以设置单个用户,也可以设置一个组中的全部用户,还可以设置全部用户
    bytes_in_avail 上传最大字节数,就是FTP用户空间容量 (设置这个字段的时候是以byte(字节)为单位,如果要限额在10M,那就是10240000,下面也一样)
    bytes_out_avail 下载最大字节数,需要注意的是,这个字段中记录的是用户总共能从服务器上下载多少数据,数据是累计的。
    bytes_xfer_avail 总共可传输的文件的最大字节数(上传和下载流量)需要注意的是,这个字段中记录的是用户总共能传输文件的最大字节数,数据是累计的。
    files_in_avail INT 总共能上传文件的数目
    files_out_avail INT 能从服务器上下载文件的总数目
    files_xfer_avail INT 总共可传输文件的数目(上传和下载)

    测试
    首先停掉inetd的ftp服务
    # ps ax|grep inetd
    得到inetd的线程号
    # kill 得到的线程号

    启动proftpd
    # cd /usr/local/proftpd/sbin
    # ./proftpd
    如果出现错误提示可以进入proftpd的调试模式进行调试:
    # ./proftpd -n -d 5 -c /usr/local/proftpd/etc/proftpd.conf
    proftpd就会将调试信息打印到consle上以供调试之用。

    添加一个测试用户并为他设置磁盘限额
    use FTP

    添加用户
    INSERT INTO FTPUSERS (userid, passwd, uid, gid, homedir, shell)
    valueS ('user1', '999999', '2001', '2001', '/home/FTP/user1', '' );

    设置磁盘限额
    将上面建立的user1帐号给予10M空间,最多能上传500个文件到服务器上,文件传输流量为20M,只能传输10个文件。
    INSERT INTO `quotalimits` ( `name` , `quota_type` , `per_session` , `limit_type` , `bytes_in_avail` , `bytes_out_avail` , `bytes_xfer_avail` , `files_in_avail` , `files_out_avail` , `files_xfer_avail` )
    VALUES ('user1', 'user', 'false', 'soft', '10240000', '0', '2048000', '500', '0', '10');
    不需要设置的部分用0代替就可以了。

    在windows提示符下登录ftp服务器。输入用户名user1,密码999999
    c:\> ftp 192.168.0.1

    运行quote SITE QUOTA显示当前用户的磁盘限额
    ftp> quote SITE QUOTA
    200-The current quota for this session are [current/limit]:
    Name: user1
    Quota Type: User
    Per Session: False
    Limit Type: Soft
    Uploaded Kb: 0.00/10000.00
    Downloaded Kb: unlimited
    Transferred Kb: 0.00/2000.00
    Uploaded files: 0/500
    Downloaded files: unlimited
    Transferred files: 0/10
    200 Please contact [email]root@wwwx.3322.org[/email] if these entries are inaccurate

    数据库用户验证和磁盘限额测试成功!

    另:如果添加了FTPGRPS表,也可以为此添加记录,不过一定要注意在members的字段多个成员一定要用逗号隔开。
    INSERT INTO FTPGRPS VALUES ('FTPGRPS', 2001, 'FTPUSR');

    关于匿名登录:
    本文的ftp服务器提供了匿名登录服务。对于匿名登录用户,我专门在硬盘上划分了一个2G的分区/ftp,所有的匿名用户文件都放在这个单独的分区里。

    添加匿名系统用户组ftpusers和匿名用户ftp
    # pw groupadd ftpusers
    # pw useradd ftp -g ftpusers -d /ftp -s /sbin/nologin
    如果ftp用户已经存在使用如下格式
    # pw usermod ftp –g ftpusers –d /ftp –s /sbin/nologin

    在/ftp下建立匿名用户目录并设置权限
    # mkdir /ftp/incoming
    # mkdir /ftp/pub
    # mkdir /ftp/bin
    # mkdir /ftp/etc
    # chown ftp /ftp/incoming
    # chgrp ftpusers /ftp/incoming

    测试
    在浏览器地址栏输入[url]ftp://192.168.0.1[/url] ,应该显示刚才建立的几个目录。进入incoming目录,应该可以在里面新建文件夹或文件。这样就完成对匿名ftp的测试!

    注意:由于我的这个配置文件设置了每台主机的最多并发连接数为3
    MaxClientsPerHost 3
    所以打开多个ftp登录窗口时会报错。


    建立proftpd的启动脚本
    # cd /usr/local/etc/rc.d
    # vi proftpd.sh
    内容如下:

    #!/bin/sh

    case "$1" in

    start)
    /bin/mkdir -p /var/run/proftpd
    if [ -x /usr/local/proftpd/sbin/proftpd ]; then
    /usr/local/proftpd/sbin/proftpd && echo -n ' proftpd'
    fi
    ;;

    stop)
    killall proftpd
    ;;
    *)
    echo "$0 start | stop"
    ;;

    esac
    (完)

    设置脚本可执行
    # chmod 750 proftpd.sh

    Proftpd全部安装结束后,就可以不用inetd(Internet超级服务器)了。
    编辑/etc/rc.conf文件,将inetd=”YES”改成inetd=”NO”。
    编辑/etc/inetd.conf文件,将带有ftp字样的行前面加上#号。
    这样在重新启动后,inetd将不会自动运行。

    使用本文的ftp服务器加上第三步介绍的web服务器应该可以提供比较基本的虚拟主机服务了。以上面建立的测试用户user1为例,其方法是:
    设置了数据库用户和磁盘限额后,编辑apache的配置文件/usr/local/etc/rc.d/httpd.conf,为用户配置虚拟主机并将文档目录指向/home/FTP/user1。这样user1就可以自己更新主页了。

    第五步:安装配置E-mail服务器

    演示地址:[url]http://baihua.3322.org/cgi-bin/sqwebmail[/url]
    iceblood前辈制作的qmail安装包使安装qmail邮件服务器简化了许多,只是sqwebmail汉化的好像有点问题,我下载了一个汉化好的sqwebmail,将它填入iceblood前辈的安装包内,可以随安装包一次安装完成。为了提供邮箱注册功能,我使用了最新版本的vqregister-2.5,并将其界面进行了简单的汉化。

    本E-mail服务器包含的功能
    1、Qmail帐号与系统帐号的分离。
    2、Qmail邮件列表功能。
    3、Qmail自动回复功能。
    4、对vpopmail的支持。
    5、邮件帐号WEB管理方式。
    6、邮件的WEB使用方式,如:WEB发邮件,查看邮件。
    7、能任意调整WEB的CGI以及HTML路径。
    8、SMTP服务的密码验证功能,能有效的防止别人利用自己的服务器发送匿名信。
    9、选择性安装webmail。
    10、对虚拟域的支持。
    11、增加qmail的管理脚本,安装后可以运行qmail start|stop|restart来管理qmail。
    12、全面支持Mysql数据库,只要在SQL设置区里打开数据库的支持,并设置好数据库密码,就可以支持数据库了。
    13、增加了QmailAdmin和sqwebmail的中文界面!![新]
    14、对很多包有是否安装的可选择余地![新]
    以上为iceblood前辈制作的qmail安装包v1.5.3自带功能。
    在此基础上我添加了修改过的sqwebmail的中文界面并增加了邮箱注册功能(中文界面)。

    下载qmail安装包1.5.3
    [url]ftp://baihua.3322.org/pub/server/Qmail_setup-v1.5.3.tar.gz[/url]
    下载修改过的汉化安装包sqwebmail-3.5.0
    [url]ftp://baihua.3322.org/pub/server/sqwebmail-3.5.0-cn.tar.gz[/url]
    下载我汉化后的vqregister-2.5
    [url]ftp://baihua.3322.org/pub/server[/url]
    英文原版vqregister-2.5下载地址
    [url]http://inter7.com/vqregister.html[/url]

    首先把下载的安装文件上传到/home/ylf/app目录
    解压缩qmail_setup-v1.5.3安装包
    # cd /home/ylf/app
    # tar zxvf qmail_setup-v1.5.3.tar.gz
    进入解开的目录
    # cd Qmail_setup
    将新的sqwebmail中文安装包拷到此目录
    # cp ../sqwebmail-3.5.0-cn.tar.gz ./
    编辑安装配置文件setup
    # vi seutp
    按系统情况修改如下内容:(这里是我的配置)

    # 操作系统类型为FreeBSD
    _OS="FreeBSD"

    # 默认语言为中文
    _LANG="CN"

    # 不安装apache
    _INSTALLAPACHE="NO"

    # 添加qmail用户
    _ADDQMAILUSERS="YES"

    # 域名
    _DOMAIN=mail01.3322.org

    # 邮箱管理员密码
    _MAILPASSWD=1234

    # CGI路径
    _CGIBIN=/usr/local/www/cgi-bin

    # Html路径
    _HTMLPATH=/usr/local/www/data


    ###########--------Advanced set--------#################
    # 设置邮箱容量50M
    _MAILSIZE=50000000
    # enable virutal domain lookup via reverse ip address lookup for virtual domains. "y" and "n"
    _USERCRUISE=n
    # apache 安装路径
    _APACHEPATH=/usr/local
    # 不使用系统用户验证
    _SYSTEMPASS=n
    # 安装 vpopmail
    _VPOPMAIL="YES"
    # 安装 ezmlm
    _EZMLMIN="YES"
    # ezmlm coding
    _EZMLM=ch_GB
    # 安装 autorespond
    _AUTORESPOND="YES"
    # 安装 QmailAdmin
    _QMAILADMIN="YES"

    ##########--------SqWebMail set--------#############
    # 安装 webmail
    _WEBMAIL="YES"
    # webmail coding set.have "iso","gb2312","big5" and more.
    _MIMESET=gb2312
    # webmail use SSL,"YES" or "NO"
    _WEBHTTPS="NO"

    ##########--------SQL set---------################
    # 使用数据库
    _SQL=y
    # mysql 主机
    _SQLHOST=localhost
    # mysql 用户
    _SQLUSER=root
    # mysql 密码
    _SQLPASS=123456
    # include path
    _INCDIR=/usr/local/include/mysql
    # lib file path
    _LIBDIR=/usr/local/lib/mysql


    然后在安装脚本里找到下面几句
    tar xzf sqwebmail-3.3.7.20020910.tar.gz
    cd sqwebmail-3.3.7.20020910
    if [ "$_LANG" = "CN" ]; then
    cp /tmp/iceblood/Qmail_setup/iceblood/sqwebmailcn/*.html sqwebmail/html/en-us
    fi

    将其改为
    tar xzf sqwebmail-3.5.0-cn.tar.gz
    cd sqwebmail-3.5.0
    #if [ "$_LANG" = "CN" ]; then
    #cp /tmp/iceblood/Qmail_setup/iceblood/sqwebmailcn/*.html sqwebmail/html/en-us
    #fi

    改好后保存。这样安装包就可以自动安装新的sqwebmail程序。

    让setup可执行
    # chmod 700 setup
    执行setup安装
    # ./setup
    安装完成后系统自动运行qmail程序。可以通过qmail start|stop手动启动或停止qmail程序。

    测试
    因为我们前面设置了虚拟主机www01.3322.org 和 www02.3322.org,他们的文档目录不是安装qmail时所指定的目录。为了保证邮件访问正常,我们再添加一个虚拟主机mail01.3322.org,
    将它的文档目录指向/usr/local/www/data:
    先到希网申请一个域名,我们假设它是mail01.3322.org

    编辑/usr/local/etc/apache/httpd.conf
    # vi /usr/local/etc/apache/httpd.conf
    添加下面一段

    ServerAdmin [email]webmaster@mail01.3322.org[/email]
    DocumentRoot /usr/local/www/data
    ServerName mail01.3322.org
    ErrorLog /var/wwwlogs/mail01.3322.org.error.log
    CustomLog /var/wwwlogs/mail01.3322.org.log common


    重新启动apache
    # /usr/local/etc/rc.d/apache.sh stop
    # /usr/local/etc/rc.d/apache.sh start

    首先确认mail01.3322.org已经正确指向了你的主机ip地址。然后在浏览器地址栏输入[url]http://mail01.3322.org/cgi-bin/qmai...g[/url],密码是1234。
    建立一个新用户,然后在浏览器地址栏输入[url]http://mail01.3322.org/cgi-bin/sqwebmail[/url]
    以你新建立的用户登录,就可以收发邮件了!

    关于SMTP验证的问题:
    网上有很多讨论关于qmail安装包的smtp验证有问题的文章,我经过反复测试,发现iceblood前辈的安装包本身并没有问题,问题出在foxmail上,如果你使用Foxmail4.2发邮件,不需要在smtp验证添任何内容就能发出去;如果是使用outlook,不添或添错了smtp验证内容都发不出去。大家可以试试。所以我这里没有给qmail-smtp打补丁。(iceblood前辈的安装包不同版本之间好像有区别,建议大家下载我这个)

    安装vqregister-2.5
    vqregister-2.5是vqsignup的升级版本,提供qmail邮箱注册功能。
    进入vqregister-2.5安装目录
    # cd /home/ylf/app/vqregister-2.5-cn

    编译安装前需要修改两个文件
    修改register.c文件
    # vi register.c
    找到下面一行
    eret = execl("/var/qmail/bin/qmail-remote", "/var/qmail/bin/qmail-remote", p, "[email]register@inter7.com[/email]", cemail, NULL);
    将里面的qmail路径指向正确的路径,这里改为
    eret = execl("/usr/local/qmail/bin/qmail-remote", "/usr/local/qmail/bin/qmail-remote", p, "[email]register@inter7.com[/email]", cemail, NULL);

    修改安装配置文件Makefile
    # vi Makefile
    找到这几行
    DEFS = -I$(VDIR)/include -I/usr/local/mysql/include

    LIBS = -L$(VDIR)/lib -lvpopmail -lcrypt -L/usr/local/mysql/lib/mysql -lmysqlclient

    INSTALL_DIR = /usr/local/apache/cgi-bin/vqregister

    将它们改成实际路径,这里是
    DEFS = -I$(VDIR)/include -I/usr/local/include/mysql

    LIBS = -L$(VDIR)/lib -lvpopmail -lcrypt -L/usr/local/lib/mysql -lmysqlclient

    INSTALL_DIR = /usr/local/www/cgi-bin/vqregister

    编译安装
    # make install

    安装完成后需要编辑vqregister的配置文件
    # cd /usr/local/www/cgi-bin/vqregister
    # vi vqregister.conf
    修改下面几项

    # 设置管理信息
    AdminEmail [email]postmaster@mail01.3322.org[/email]

    # 设置邮箱使用的域名
    AllowDomain mail01.3322.org

    其它项目可根据注释修改,不改也行,直接保存即可。

    测试vqregister
    在浏览器地址栏输入[url]http://mail01.3322.org/cgi-bin/vqre.../vqregister.cgi[/url] ,按要求添入注册信息,提交后显示注册成功信息,证明你的vqregister安装成功!如果出现错误,请按提示检查注册信息或检查vqregister.conf文件。

    第六步:安装配置视频点播服务器

    演示地址:[url]http://baihua.3322.org/media[/url]
    FreeBSD下的流媒体视频点播服务器软件可以使用苹果公司的Darwin Streaming Server或者Real公司的Helix Universal Server,前者最大的优点是免费,后者在网上使用的很多。我在使用这两种产品时发现Darwin Streaming Server对各种媒体格式支持的没有Helix Universal Server支持的好,比如象现在流行的mp4,再加上现在网上rm格式的节目源非常丰富,制作rm媒体文件的工具也非常多,所以本文还是选用了Helix Universal Server做为视频点播服务器。
    下载FreeBSD版的Helix Universal Servevr Basic,免费版的Helix Universal Servevr最大支持1M的带宽。并可申请1年的使用证书。
    [url]http://forms.real.com/rnforms/products/servers/eval/mbps.html[/url]
    需要填写一些信息才能下载,注意要添入正确的email地址,因为下载后授权证书会发到你添的邮箱里。还有操作系统一定要选FreeBSD!
    下载后的文件名为rs901-freebsd4-ia32.bin,将它上传到/home/ylf/app目录。

    安装过程很简单:
    进入/home/ylf/app目录
    # cd /hom/ylf/app
    修改rs901-freebsd4-ia32.bin权限为可执行
    # chmod 700 rs901-freebsd4-ia32.bin
    执行rs901-freebsd4-ia32.bin进行安装
    # ./rs901-freebsd4-ia32.bin
    当提示输入证书文件路径时先按回车跳过
    接下来要你看一个协议,按方向键走到最后
    下面提示安装位置
    输入/usr/local/realserver
    接着会有一些端口选择的提示,一般按回车接受默认值即可,80端口如果冲突可改为8080。系统还会随机产生一个管理端口,把端口号记下来,我们安装后通过web页进行管理时要输入这个端口号。
    另外安装时还会提示输入管理员用户名和密码,这个也要记下来。

    安装结束后,打开real公司给你发的邮件,里面有一句“License key for Helix Server may be downloaded from:”,下面的连接就是下载证书的连接。下载后把证书文件上传到/home/ylf/app目录。然后拷贝证书文件到指定的目录
    # cd /home/ylf/app
    # cp RNKey-Helix_Server-90-2804003590401434.lic /usr/local/realserver/License
    其中RNKey-Helix_Server-90-2804003590401434.lic为证书文件名,你的证书文件名会不同,
    /usr/local/realserver/License是证书文件路径。
    至此安装过程结束。

    进入程序目录
    # cd /usr/local/realserver
    启动Helix Universal Server
    # Bin/rmserver rmserver.cfg
    出现一连串的“Starting PID”提示,证明Helix Universal Server已经启动。

    测试
    在浏览器地址栏按如下格式输入[url]http://192.168.0.1:28274/admin/index.html[/url] ,这里28274是安装时系统随机产生的管理端口号,你的和这个不一样。
    这时会弹出登陆对话框,添入你上面设置的管理员用户名和密码,这样就打开了管理界面。
    选左侧的Server Setup——Media Samples就可以看系统提供的演示多媒体文件了!注意客户端要有RealPlayer8以上的媒体播放器才行。
    如果要添加自己的rm文件,可以将文件放到/usr/local/realserver/Content目录,然后在RealPlayer上输入地址[url]rtsp://192.168.0.1:554/xxx.rm[/url]就可以看了,其中xxx.rm是你的rm文件名。
    多媒体文件存放路径可以通过Server Setup——Mount Points修改。

    有一个问题值得注意:当系统使用超过一块网卡时,Helix Universal Server在安装时总是将管理端口自动绑定到系统的第一块网卡上,也就是使用ifconfig命令察看网卡信息时显示的第一块网卡。这样如果你的终端不是连接在第一块网卡上,将不能打开管理web页面。
    这个问题可以在能打开管理web页面的时候,选Server Setup——IP Binding,通过添加地址0.0.0.0来绑定所有的网卡。
    另外还可以通过修改Helix Universal Server的配置文件来解决:
    # cd /usr/local/realserver
    # vi rmserver.cfg
    添加如下内容:



    重新启动Helix Universal Server即可。

    如果自己制作rm流媒体文件,有两种工具很好,一个是real自己的Real Producer Plus,另一个是网络多媒体梦工厂real2002。前者功能强大,后者是类似前者的简化版,用起来很方便。

    发表于 @ 2005年11月11日 11:52:00|评论(loading...)|编辑

    旧一篇: sniffer超级详细介绍

    评论:没有评论。

    发表评论  


    当前用户设置只有注册用户才能发表评论。如果你没有登录,请点击登录
    Csdn Blog version 3.1a
    Copyright © 待燃的烟头