这里使用的是redhat5.8的系统,为了方便使用的是yum安装的,如源码安装可以参考之前的文档结合配
置,试验拓扑如下:
首先配置好yum,selinux关闭,这里使用的3台虚拟机,本机的DNS也指向192.168.80.139
1、配置192.168.80.140,mysql服务器:
- # yum -y install mysql mysql-server
- # service mysqld start
- # mysqladmin -u root password 'redhat'
- # mysql -u root -p
- mysql> GRANT ALL ON discuz.* TO root@'%.%.%.%' IDENTIFIED BY 'redhat';
- mysql> FLUSH PRIVILEGES;
- # mkdir -p /web/discuz
- # unzip Discuz_7.2_FULL_SC_UTF8.zip -d /web/discuz
- # vim /etc/exports
- /web/discuz 192.168.80.0/24(rw,no_root_squash)
- # service nfs restart
2、配置192.168.80.138,http服务器:# yum -y install httpd php53 php53-mbstrind php53-mysql
分别验证apache和php,apache和mysql的整合
- # vim /var/www/html/index.php
- <?php
- phpinfo();
- ?>
- <?php
测试与php整合:
- # vim /var/www/html/index.php
- $link=mysql_connect('192.168.80.140','root','redhat');
- if ($link)
- echo "OK!!";
- else
- echo "Error!";
- mysql_close();
- ?>
再次访问,测试与mysql整合:
配置http:
- # mkdir -p /web/discuz
- # mount -t nfs 192.168.80.140:/web/discuz/ /web/discuz/
- 这里也可以写进/etc/faste文件中,实现开机自动挂载:192.168.80.140:/web/discuz /web/discuz nfs defaults 0 0
- # vim /etc/httpd/conf/httpd.conf
- #DocumentRoot "/var/www/html"
- NameVirtualHost *:80
- <VirtualHost *:80>
- DocumentRoot /web/discuz
- ServerName www.peace.com
- ErrorLog logs/www.peace.com-error_log
- CustomLog logs/www.peace.com-access_log common
- </VirtualHost>
- # vim /etc/php.in
- short_open_tag = On
- # cd /web/discuz/upload/
- # chown -R apache config.inc.php p_w_uploads/ forumdata/ uc_client/data/cache/
- # service httpd restar
在浏览器中输入 按步骤初始化安装论坛:
3、配置192.168.80.139,http服务器:这里的139配置和138的http配置是一样的,不同的是在138上面初始化的Discuz论坛,这里直接访问即可,只需配置DNS解析:
按配置138http的步骤配置,http已经OK了:
配置DNS
- # yum -y remove bind-utils bind-libs
- # yum -y install bind97 bind97-utils bind97-libs
- # vim /etc/named.conf
- ……
- options {
- listen-on port 53 { any; };
- directory "/var/named";
- dump-file "/var/named/data/cache_dump.db";
- statistics-file "/var/named/data/named_stats.txt";
- memstatistics-file "/var/named/data/named_mem_stats.txt";
- allow-query { any; };
- recursion yes;
- };
- ……
- # vim /etc/named.rfc1912.zones
- zone "peace.com" IN {
- type master;
- file "peace.com.zone";
- };
- zone "168.192.in-addr.arpa" IN {
- type master;
- file "192.168.zone";
- };
- # vim /var/named/peace.com.zone
- $TTL 600
- $ORIGIN peace.com.
- @ IN SOA ns.peace.com. admin.peace.com. (
- 2012071601
- 1H
- 10M
- 7D
- 3H )
- IN NS ns
- ns IN A 192.168.80.139
- ns IN A 192.168.80.138
- www IN A 192.168.80.139
- www IN A 192.168.80.138
- # vim /var/named/192.168.zone
- $TTL 600
- @ IN SOA ns.peace.com. admin.peace.com. (
- 2012071601
- 1H
- 10M
- 7D
- 3H )
- IN NS ns.peace.com.
- 80.139 IN PTR ns.peace.com.
- 80.138 IN PTR ns.peace.com.
- 80.139 IN PTR www.peace.com.
- 80.138 IN PTR www.peace.com.
- # cd /var/named/
- # chown .named peace.com.zone 192.168.zone
- # chmod 644 peace.com.zone 192.168.zone
- # service named restart
- # vim /etc/resolv.conf
- nameserver 192.168.80.139
通过ping 查看是否有dns轮询:
4、测试之后就可以通过浏览器输入域名访问了:
可以再访问的同时,在两台http服务其上使用# tailf /var/log/httpd/www.peace.com-access_log监控访问日志,查看解析到那台上面就可以了。