安装配置基于KBS程序的BBS系统

五 16th, 2009
1,254 views | 没有评论

注:此文备录 相关信息来自网络 记录备用下并时刻更新
操作系统环境:VM虚拟机下的Ubuntu8.04 Server 只安装OpenSSH服务
KBS BBS: kbs svn上最新的源代码
Apache:apache1.3.41.tar.gz (下载:http://www.apache.org
PHP:php5.2.6.tar.gz(下载:http://www.php.net
代码目录:/home/bbs/src/

安装前准备工作:更新安装时可能所需要的包:

# apt-get install automake1.9
# apt-get install php5-dev
# apt-get install libmysqlclient15-dev
# apt-get install sendmail
# apt-get install libesmtp5
# apt-get install byacc
# apt-get install libgmp3-dev
# apt-get install flex
# apt-get install libxml2-dev
# apt-get install libjpeg62-dev
# apt-get install libpng12-dev
# apt-get install libfreetype6-dev
# apt-get install subversion

创建bbs用户:

    # adduser bbs

安装apache服务:

# tar xvf apache_1.3.41.tar.gz
# cd apache_1.3.41
# CC="gcc" OPTIM="-O2" ./configure --prefix=/home/bbs/www --enable-module=so
# make
# make install

编辑apache的配置文件,User和Group都改成bbs,Port改成想要的端口。

# cd /home/bbs/www/conf
# vim httpd.conf

安装PHP

# tar xvf php-5.2.6.tar.gz
# cd php-5.2.6
# ./configure --with-mysql --with-apxs=/home/bbs/www/bin/apxs \\
--with-gd --with-png-dir --with-iconv --with-jpeg-dir \\
--with-zlib --with-ttf --with-freetype-dir --enable-gd-native-ttf
# make
# make install

编辑apache的配置文件/home/bbs/www/conf/httpd.conf,在里面加入这样一行:

AddType application/x-httpd-php .php

下载安装KBS
从kbs的svn服务器上下载最新的kbs源代码。

# cd /home/bbs/src
# svn co http://svn.kcn.cn/repos/kbs/trunk/kbs_bbs
# svn co http://svn.kcn.cn/repos/kbs/trunk/www2

查看bbs用户的gid和uid是多少。

# cat /etc/passwd | grep bbs

到kbs的站点定义目录下,建造一份自己的站点的定义文件,比如站点叫做Yousri。尤其要修改Yousri.h中的BBSUID和BBSGID为刚才看到的bbs用户的编号。

# cd /home/bbs/src/kbs_bbs/site
# cp fb2k-v2.h yousri.h
# cp fb2k-v2.c yousri.c
# vim yousri.h
运行autogen.sh。
<pre lang="bash">
# cd /home/bbs/src/kbs_bbs
# ./autogen.sh
# cd sshbbsd
# ./autogen.sh

编译安装kbs。

# cd /home/bbs/src/kbs_bbs
# ./configure --prefix=/home/bbs --enable-site=yousri \\
--with-php --with-mysql --enable-ssh --enable-ssl \\
--with-openssl=/usr --with-libesmtp --enable-innbbsd CFLAGS="-O3 -g"
# make
# make install

如果是新建的bbs站点,还需要安装默认的站点文件。

# make install-home

给sshbbsd生成钥匙。

# cd /home/bbs/etc
# touch sshd_config
# ssh-keygen -t rsa1 -f ssh_host_key

从php源码目录复制来一个php的配置文件,并编辑之。

# cd /usr/local/lib
# cp /home/bbs/src/php-5.2.6/php.ini-dist php.ini
# vim php.ini

修改extension_dir一行为:

extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"

然后加入下面一行:

extension=libphpbbslib.so

把www2符号连接到apache的网页目录来。

# cd /home/bbs/www/
# mv htdocs htdocs.default
# ln -s ../src/www2 htdocs

因为之前很多操作需要用root执行,可能bbs的很多文件的owner和group不对,所以一并搞掉。

# chown -R bbs:bbs /home/bbs

启动BBS:

# cd /home/bbs/bin
# ./miscd daemon
# ./bbslogd
# ./bbsd -p 23
# ./sshbbsd -p 22
# cd ../www/bin
# ./apachectl start

如果要停止bbs的话按如下操作:

# cd /home/bbs/www/bin
# ./apachectl stop
# cd ../../bin
# killall sshbbsd
# killall bbsd
# killall bbslogd
# ./miscd flush
# killall miscd

其中期间遇到过两个比较莫名其妙的小问题
到最后启动bbs的时候 执行

root@yousri:/home/bbs/bin# ./miscd daemon
Bus error

这一步的时候出现如此的错误提示
还有就是启动后 telnet 127.0.0.1 进入要注册出现无法注册的现象如注册SYSOP账号却提示
“由于某些系统原因, 无法注册新的帐号.”
然后要再次连接 telnet 127.0.0.1 就无法连接了

“root@yousri:/home/bbs# telnet 127.0.0.1
  Trying 127.0.0.1...
  Connected to 127.0.0.1.
  Escape character is '^]'.
  Connection closed by foreign host.”

至于执行./miscd daemon报错的问题 后来又重新编译安装了下kbs代码 倒是可行了。。。
对于无法注册账号的 貌似要杀掉有关miscd及bbslogd的进程 然后重新创建才可以 即:

killall miscd
killall bbslogd

终于正常了。。。。
其他系统使用待更新。。。。

标签: , ,

DNS服务器调试工具dig、host、nslookup

四 20th, 2009
1,373 views | 没有评论

       先前曾经简单介绍过在CentOS5.2下搭建实现DNS服务器,可查看这里

       现在就再简单大致记录介绍三款常用于检查测试调试DNS服务器搭建是否成功的工具吧~即Dig、Host、Nslookup,介绍:

      
Shell方式可以使用3种工具来查询DNS数据库:nslookup、dig和host,在BIND的软件发布中包括nslookup和dig。
Nslookup是这三个工具中最老的,而且总是随同BIND一起发布;dig是域信息的探索程序,最初由SteveHotz编写,后来
MichaelSawy针对BIND 9将它重新编写,它也和BIND一起发布;host由Eric
Wassenaar编写,是另一个开放源代码的工具,其特点是输出对用户很友好,功能是可检查区文件的语法。另外三者使用的解析器库不同:dig和
host使用BIND的解析器,而nslookup有其自身的解析器。

       (1)、Dig命令

Usage:  dig [@global-server] [domain] [q-type] [q-class] {q-opt}
            {global-d-opt} host [@local-server] {local-d-opt}
            [ host [@local-server] {local-d-opt} [...]]

      
以上是关于dig用法参数列表,可以通过man dig 或者 dig –h | more 查看其命令相应的帮助信息~ 参数可接IP
address或domain name来获得name server所提供的相关讯息,提供不同资料记录型态,例如A、MX…等等

      (2)、Host命令

[root@yanqx ~]$ host -h              
host: illegal option — h
Usage: host [-aCdlriTwv] [-c class] [-N ndots] [-t type] [-W time]
            [-R number] hostname [server]
       -a is equivalent to -v -t *
       -c specifies query class for non-IN data
       -C compares SOA records on authoritative nameservers
       -d is equivalent to -v
       -l lists all hosts in a domain, using AXFR
       -i IP6.INT reverse lookups
       -N changes the number of dots allowed before root lookup is done
       -r disables recursive processing
       -R specifies number of retries for UDP packets
       -t specifies the query type
       -T enables TCP/IP mode
       -v enables verbose output
       -w specifies to wait forever for a reply
       -W specifies how long to wait for a reply
       -4 use IPv4 query transport only
       -6 use IPv6 query transport only

       默认情况下,只是简单使用host+欲查询域名得到只是简单一些A记录或MX记录等,想了解全部信息需加上 –a 参数查看 如:

[root@yanqx ~]$ host qingxianyan.cn
qingxianyan.cn has address 74.220.219.76
qingxianyan.cn mail is handled by 0 qingxianyan.cn.

   (3)、Nslookup命令

       在linux或win下
入nslookup命令后,会看到 > 提示符号,之后就可输入查询指令。一般会输入IP address或是domain
name来做反向及正向的解析。而nslookup不仅提供上述2种解析,亦像dig提供DNS中其它的资料记录型态,例如A、MX、NS…等等,可在提
示符号直接输入”?”来获得所有可以使用的参数或资料型态。

Commands:   (identifiers are shown in uppercase, [] means optional)
NAME            – print info about the host/domain NAME using default server
NAME1 NAME2     – as above, but use NAME2 as server
help or ?       – print info on common commands
set OPTION      – set an option
    all                 – print options, current server and host
    [no]debug           – print debugging information
    [no]d2              – print exhaustive debugging information
    [no]defname         – append domain name to each query
    [no]recurse         – ask for recursive answer to query
    [no]search          – use domain search list
    [no]vc              – always use a virtual circuit
    domain=NAME         – set default domain name to NAME
    srchlist=N1[/N2/.../N6] – set domain to N1 and search list to N1,N2, etc.
    root=NAME           – set root server to NAME
    retry=X             – set number of retries to X
    timeout=X           – set initial time-out interval to X seconds
    type=X              – set query type (ex. A,ANY,CNAME,MX,NS,PTR,SOA,SRV)
    querytype=X         – same as type
    class=X             – set query class (ex. IN (Internet), ANY)
    [no]msxfr           – use MS fast zone transfer
    ixfrver=X           – current version to use in IXFR transfer request
server NAME     – set default server to NAME, using current default server
lserver NAME    – set default server to NAME, using initial server
finger [USER]   – finger the optional NAME at the current default host
root            – set current default server to the root
ls [opt] DOMAIN [> FILE] – list addresses in DOMAIN (optional: output to FILE)
    -a          -  list canonical names and aliases
    -d          -  list all records
    -t TYPE     -  list records of the given type (e.g. A,CNAME,MX,NS,PTR etc.)
view FILE           – sort an ‘ls’ output file and view it with pg
exit            – exit the program

     参考资料:http://docsrv.sco.com/NET_tcpip/dnsC.nslook.html

标签: , , , ,

加强Apache配置的安全方法

四 19th, 2009
726 views | 1 条评论

一、确保你安装的是最新的补丁
         如果门是敞开的话,在窗户上加锁就毫无意义。同样道理,如果你没有打补丁,继续下面的操作就没有什么必要。
二、隐藏Apache的版本号及其它敏感信息
         默认情况下,很多Apache安装时会显示版本号及操作系统版本,甚至会显示服务器上安装的是什么样的Apache模块。这些信息可以为黑客所用,并且黑客还可以从中得知你所配置的服务器上的很多设置都是默认状态。
         这里有两条语句,你需要添加到你的httpd.conf文件中:

    ServerSignature Off
    ServerTokens Prod

         ServerSignature出现在Apache所产生的像404页面、目录列表等页面的底部。ServerTokens目录被用来判断 Apache会在Server HTTP响应包的头部填充什么信息。如果把ServerTokens设为Prod,那么HTTP响应包头就会被设置成:

Server:Apache

         如果你非常想尝试其它事物,你可以通过编辑源代码改成不是Apache的其它东西,或者你可以通过下面将要介绍的mod_security实现。
三、确保Apache以其自身的用户账号和组运行
         有的Apache安装过程使得服务器以nobody的用户运行,所以,假定Apache和你的邮件服务器都是以nobody的账号运行的,那么通过Apache发起的攻击就可能同时攻击到邮件服务器,反之亦然。

    User apache
    Group apache

四、确保web根目录之外的文件没有提供服务
         我们不让Apache访问web根目录之外的任何文件。假设你的所以web站点文件都放在一个目录下(例如/web),你可以如下设置:

    Order Deny,Allow
    Deny from all
    Options None
    AllowOverride None
    Order Allow,Deny
    Allow from all

         注意,因为我们设置Opitins None 和AllowOverride None,这将关闭服务器的所有Option和Override。你现在必须明确把每个目录设置成Option或者Override。
五、关闭目录浏览
      你可以在Directory标签内用Option命令来实现这个功能。设置Option为None或者-Indexes。
         Options -Indexes
六、关闭includes
      这也可以通过在Directory标签内使用Option命令来实现。设置Option为None或者-Includes。
         Options -Includes
七、关闭CGI执行程序
         如果你不用CGI,那么请把它关闭。在目录标签中把选项设置成None或-ExecCGI就可以:
         Options -ExecCGI
八、禁止Apache遵循符号链接
         同上,把选项设置成None或-FollowSymLinks:
         Options -FollowSymLinks
九、关闭多重选项
         如果想关闭所有选项,很简单:
         Options None
         如果只想关系一些独立的选项,则通过将Options做如下设置可实现:
         Options -ExecCGI -FollowSymLinks -Indexes
十、关闭对.htaccess文件的支持
         在一个目录标签中实现:
         AllowOverride None
         如果需要重载,则保证这些文件不能够被下载,或者把文件名改成非.htaccess文件。比如,我们可以改成.httpdoverride文件,然后像下面这样阻止所有以.ht打头的文件:

    AccessFileName .httpdoverride
    Order allow,deny
    Deny from all
    Satisfy All

十一、运行mod_security
         Run mod_security是O’Reilly出版社出版的Apache Security一书的作者,Ivan Ristic所写的一个非常好用的一个Apache模块。可以用它实现以下功能:
         ·简单过滤
         ·基于过滤的常规表达式
         ·URL编码验证
         ·Unicode编码验证
         ·审计
         ·空字节攻击防止
         ·上载存储限制
         ·服务器身份隐藏
         ·内置的Chroot支持
         ·更多其它功能

十二、关闭任何不必要的模块
         Apache通常会安装几个模块,浏览Apache的module documentation,了解已安装的各个模块是做什么用的。很多情况下,你会发现并不需要激活那些模块。
         找到httpd.conf中包含LoadModule的代码。要关闭这些模块,只需要在代码行前添加一个#号。要找到正在运行的模块,可以用以下语句:

grep LoadModule httpd.conf

         以下模块通常被激活而并无大用:mod_imap,mod_include,mod_info,mod_userdir,mod_status,mod_cgi,mod_autoindex。

         网络上学习了解收集到的~当作收藏,这东西实用性因人而异,嗯。

标签: