当前位置:首页 > 服务器类 > 安全防护 > > FreeBSD平台下Web服务器架设攻略

FreeBSD平台下Web服务器架设攻略

点击次数:30 次 发布日期:2008-11-22 09:20:12 作者:源代码网
源代码网推荐

源代码网整理以下  在FreeBSD系统中,一个标准的FreeBSD系统,至少要有一个网络界面以便与其他计算机通信。它支持Token Ring和FDDI,以及普通电话拨号连接、ISDN、ATM等广域网连接方式。本文要讨论的是基于此系统平台下的WEB服务的组建情况,FreeBSD的使用版本为4.7。

源代码网整理以下  一.接入Internet

源代码网整理以下
  配置的第一步就是让FreeBSD接入Internet并设置好代理服务。本机使用ADSL接入Internet有两种情况,即通过拨号获取的动态ip或ISP提供的静态ip。以下主要介绍动态IP的配置过程。

源代码网整理以下  方法很简单,通过直接编辑“/etc/ppp/ppp.conf”文件和“/etc/rc.conf”文件即可实现接入Internet并支持NAT方式的透明代理。

源代码网整理以下  打开PPP.conf文件对其实施配置时,使用以下命令:

源代码网整理以下  # vi /etc/ppp/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

源代码网整理以下  然后打开rc.conf文件对其实施配置时,使用以下命令:

源代码网整理以下  # vi /etc/rc.conf

源代码网整理以下  一个简单的配置实例:

源代码网整理以下  # -- 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="www.usweb.com"         # 你的主机域名

源代码网整理以下  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服务器地址。

源代码网整理以下  二.安装并设置web服务器

源代码网整理以下  Web服务器的安装与设置请按参照以下步骤进行:

源代码网整理以下  第一步:关掉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

源代码网整理以下  第二步:安装ports。使用它,可让FreeBSD安装各种软件变得很轻松。(如果已经有/usr/ports目录则证明已经安装过了),命令格式为:

源代码网整理以下  # /stand/sysinstall

源代码网整理以下  然后依次选择“Configure—Distributions—ports”,ports即被安装在“/usr/ports”目录中。

源代码网整理以下
  第三步:接着安装apache1.3.27 + modssl(关于软件的安装版本大家可以根据实际情况选择,下同)。安装后系统会自动产生启动脚本apache.sh,在/usr/local/etc/rc.d目录中。可以通过运行apache.sh start|stop来启动或停止apache。命令格式为:

源代码网整理以下  # cd /usr/ports/www/apache13-modssl

源代码网整理以下  # make install              #FreeBSD会自动从网络下载并安装

源代码网整理以下  第四步:安装mysql3.23。完成后将建立启动脚本“/usr/local/etc/rc.d/mysql-server.sh”。命令格式为:

源代码网整理以下  # cd /usr/ports/databases/mysql323-server

源代码网整理以下  # make install

源代码网整理以下  第五步:安装apache模块mod_php4,命令格式为:

源代码网整理以下  # cd /usr/ports/www/mod_php4      #FreeBSD会自动从网络下载并安装

源代码网整理以下  接着编辑scripts目录下的“configure.php”文件,加入对OpenSSL的支持,命令格式为:

源代码网整理以下  # vi scripts/configure.php

源代码网整理以下  打开此文件后,找到这一句:OpenSSL "OpenSSL support" ON 然后将其改为:OpenSSL "OpenSSL support" YES 修改完成“configure.php”后,再编辑apache的配制文件

源代码网整理以下  /usr/local/etc/apache/httpd.conf ,添加如下内容:

源代码网整理以下  DirectoryIndex index.php index.html       # 设置默认可以使用的主页名称

源代码网整理以下  AddType application/x-httpd-php .php

源代码网整理以下  AddType application/x-httpd-php-source .phps  # 这2句需要手工添加

源代码网整理以下  第六步:开始测试

源代码网整理以下  重新启动并以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进程

源代码网整理以下  在浏览器地址栏输入http://192.168.0.1 ,如果显示apache的欢迎页面,证明web服务器安装成功;web页面文件存放在/usr/local/www/data目录中,只要把自己的网页拷贝到这个目录,就可以访问自己的主页了。

源代码网整理以下  请作者联系本站,及时附注您的姓名。联系邮箱:edu#chinaz.com(把#改为@)。

源代码网供稿.
网友评论 (0)
会员中心
服务器类
本站推荐
服务器类之精华