FreeBSD网站平台建设全过程 第三步( 二 )


# 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="webmaster@yoursite.com";^M#管理信息
^M
// use persistant connections to the database^M
// 0 = don"t use^M
// 1 = use^M
$usepconnect=1;^M
^M
?>除了root用户的密码需要添入外,其他部分可以不改 。
保存后,在浏览器地址栏输入http://192.168.0.1/admin/install.php ,根据提示一步步安装即可 。
安装成功后,在在浏览器地址栏输入http://192.168.0.1 ,就可以看到论坛了!怎么样,挺漂亮吧!关于论坛的其他问题,请仔细看论坛安装包里面的说明文档,或者到仙境论坛的主页,那里有仙境论坛的一切!
下一节,我们要讨论关于虚拟主机的问题 。
配制虚拟主机:
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 webmaster@www01.3322.org#指定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 webmaster@www02.3322.org
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 。
在浏览器地址栏输入域名http://www01.3322.org 和http://www02.3322.org,如果分别显示你拷入的主页证明虚拟主机配置成功!
利用上面的方法我们可以建立更多的虚拟主机,甚至对外提供主页空间服务!

推荐阅读