用OpenBSD内置的Apache 1.3建立web服务器FAQ里描述的很清楚里,请自行参阅。
安装Apache2.2.13
这里以i386平台下的当前版OpenBSD为例:
代码: 全选
# [color=red]export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/snapshots/packages/i386/[/color]
# [color=red]pkg_add apache-httpd-2.2.13[/color]
libiconv-1.13: complete
apr-util-mt-1.2.10p4:db-4.6.21p0: complete
apr-util-mt-1.2.10p4:apr-mt-1.2.11p3: complete
apr-util-mt-1.2.10p4: complete
pcre-7.9: complete
apache-httpd-2.2.13: complete
--- apache-httpd-2.2.13 -------------------
This is the official httpd distributed by the Apache Server Project,
provided as a port for those who, for various reasons, need to run
version 2.
OpenBSD provides a custom Apache server, httpd(8), in the base system
which has been audited for security and may run in a chroot(2)
environment. Users are STRONGLY encouraged to use the system httpd
rather than this port.
#
启动Apache2.2.13
代码: 全选
# [color=red]/usr/local/sbin/apachectl2 start[/color]
这表明Apache2.2.13已经可以正常工作了.
Apache2.2.13随系统自动启动
如果想在OpenBSD系统启动时自动运行Apache2,在/etc/rc.local文件里加上如下两行:
代码: 全选
[color=red]echo "starting apache2..."[/color]
[color=red]/usr/local/sbin/apachectl2 start[/color]
(友情提示:如果你事先开启了系统自带的Apache1.3,别忘了先在rc.conf.local或rc.conf里关闭它。)
Apache2的配置文件位于在/etc/apache2/httpd2.conf,你可以参考如下内容进行修改:
代码: 全选
1.设定Apache服务器根目录
ServerRoot "/var/apache2"
2.设定监听端口:
Listen 80
3.设定网管邮箱地址
ServerAdmin [EMAIL="[email protected]"][email protected][/EMAIL]
4.主机名
ServerName [url=http://www.gobsd.org:80]www.gobsd.org:80[/URL]
5.文件根目录
DocumentRoot "/var/apache2/htdocs"
6.错误信息文件的位置
ErrorLog "logs/error_log"
...............