httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序

配置前先检查环境:

[root@chenliang ~]# iptables -vnL //检查防火墙配置,防止服务端无法被访问
Chain INPUT (policy ACCEPT 6 packets, 312 bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain OUTPUT (policy ACCEPT 6 packets, 312 bytes)
pkts bytes target prot opt in out source destination

[root@chenliang ~]# getenforce //查看SELinux状态
Enforcing
[root@chenliang ~]# setenforce 0 //更改SELinux为允许状态

[root@chenliang conf.d]# service httpd start //启动httpd服务
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for chenliang
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[确定]

[root@chenliang conf.d]# service mysqld start //启动mysql服务,mysqld是mysql 的服务器端
正在启动 mysqld: [确定]

采用LAMP组合的快速架构搭建此次服务:Linux+Apache(httpd)+mysql+PHP

1.安装需要的程序包:
[root@chenliang ~]# yum install httpd php php-mysql mysql-server

2.创建虚拟主机:创建虚拟主机并为主机提供一个测试页面

[root@chenliang ~]# cd /etc/httpd/conf.d
[root@chenliang conf.d]# ls
manual.conf mod_dnssd.conf php.conf README ssl.conf welcome.conf
[root@chenliang conf.d]# vim vhost1.conf
<VirtualHost 172.16.68.1:80>
DocumentRoot /var/www/vhost1
ServerName www.clvhost1.com
<Directory "/var/www/vhsot1">
Options None
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
[root@chenliang conf.d]# mkdir -pv /var/www/vhost1
mkdir: 已创建目录 "/var/www/vhost1"
[root@chenliang conf.d]# echo "This is vhost's homepage~" >> /var/www/vhost1/index.html
[root@chenliang conf.d]# vim ../conf/httpd.conf
NameVirtualHost 172.16.68.1:80 //在httpd.conf 配置文件中添加这一行

在本地主机系统C盘下\Windows\System32\drivers\etc\hosts文件添加:172.16.68.1 www.clvhost1.com

开始测试虚拟机创建的结果如下图,成功创建虚拟机并显示测试界面:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序

3.在MySQL中创建并授权用于测试的用户账户,进行php连接数据库测试:
php连接数据库测试:

[root@chenliang conf.d]# cd /var/www/vhost1/
[root@chenliang vhost1]# ls
index.html
[root@chenliang vhost1]# mv index.html index.php
[root@chenliang vhost1]# vim index.php
This is vhost's homepage~</br>
<?php
$conn = mysql_connect('172.16.68.1','chenliang','123456');
if($conn)
echo "Connect successful.";
else
echo "Connect failed.";
?>
测试结果:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序

4.部署应用程序:
将wordpress博客系统、Discuz!论坛系统及phpMyAdmin应用程序放置于/etc/httpd/conf.d/vhost1/下:

[root@chenliang vhost1]# ls
index.php phpMyAdmin-3.5.4-all-languages.tar.gz upload wordpress-4.2-zh_CN.tar.gz //phpMyAdmin和wordpress为压缩包,需要解压;而部署安装Discuz!论坛系统只需要压缩包中的的upload目录,这里是已经放置好的httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
解压两个压缩包:
[root@chenliang vhost1]# tar xf phpMyAdmin-3.5.4-all-languages.tar.gz //解压phpMyAdmin
[root@chenliang vhost1]# tar xf wordpress-4.2-zh_CN.tar.gz //解压wordpress
查看目录:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
(1)搭建bbs论坛(Discuz!论坛系统)
将wordpress的目录名改为bbs(bbs论坛): //更名只是为了方便在浏览器地址框输入地址
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
在httpd.conf文件中将默认的字符格式注释掉并改为bbs论坛的GB2312(更改完成记得重启httpd服务):
#AddDefaultCharset UTF-8
AddDefaultCharset GB2312

测试创建bbs论坛(Discuz!论坛系统)结果:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
点击同意:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
在bbs目录中,赋予这些目录权限:
[root@chenliang bbs]# chmod 777 config data/ data/{cache,avatar,plugindata,download,addonmd5,template,threadcache} data/attachment data/attachment/{album,forum,group} data/log uc_client/data/cache uc_server/data/ uc_server/data/{cache,avatar,backup,logs,tmp,view}
赋予权限后如下:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
点击下一步:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
按需求,然后下一步,安装数据库:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
等待安装过程:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
安装bbs论坛成功:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
点击注册一个用户名:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
在服务器端会显示bbs论坛的数据库ultrax:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
至此,bbs论坛(Discuz!论坛系统)创建成功。

(2)搭建wordpress博客系统(需要手动建立数据库和对用户进行授权)
把压缩包解压后的wordpress目录更名为wp:
[root@chenliang vhost1]# mv wordpress/ wp/
本地浏览器端测试主页:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
切换到wp目录中:
[root@chenliang vhost1]# cd wp/
修改配置文件,添加设置数据库的名称、数据库用户名、数据库密码、主机IP:(其他有需要再编辑)
[root@chenliang wp]# vim wp-config-sample.php
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
wpdb数据库需要在我们服务器端进行手动授权:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
对用户wpuser进行访问授权:

mysql> grant all on wpdb.* to 'wpuser'@'%' identified by '123456'; //向要对wpdb数据库访问的用户wpuser进行访问授权
Query OK, 0 rows affected (0.02 sec)

之后在客户端(这里是本地)浏览器端测试主页登录安装,按上面配置好的用户名和密码主机IP等登录:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
按下图中的要求在wp目录中添加相应文件:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
填写好下图中的基本信息后安装wordpress博客系统:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
如下图所示,安装wordpress博客系统成功:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
进入wordpress博客系统管理员主界面:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
至此,wordpress博客系统搭建成功。

(3)配置phpMyAdmin应用程序
把压缩包解压后的phpMyAdmin目录更名为pma:
[root@chenliang vhost1]# mv phpMyAdmin-3.5.4-all-languages pma
直接在浏览器键入地址:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
在主页可以看到服务器端存在的数据库(包括上面两个论坛的ultrax和wpdb数据库):
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
在这里可以创建其他表,例如在mydb中创建一个学生成绩表:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
服务器端显示的有刚刚创建的学生成绩表:
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
httpd-2.2部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin程序
至此,phpMyAdmin应用程序配置成功。

以上,就是使用httpd-2.2(在CentOS6中)配置部署Discuz!论坛系统、wordpress博客系统和phpMyAdmin应用程序。

猜你喜欢

转载自blog.51cto.com/chenliangdeeper/2112170