1. 程式人生 > >httpd-2.2部署Discuz!論壇系統、wordpress博客系統和phpMyAdmin程序

httpd-2.2部署Discuz!論壇系統、wordpress博客系統和phpMyAdmin程序

httpd-2.2配置論壇博客和應用程

配置前先檢查環境:

[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

開始測試虛擬機創建的結果如下圖,成功創建虛擬機並顯示測試界面:
技術分享圖片

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.";
?>
測試結果:
技術分享圖片

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目錄,這裏是已經放置好的技術分享圖片
解壓兩個壓縮包:
[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
查看目錄:
技術分享圖片
(1)搭建bbs論壇(Discuz!論壇系統)
將wordpress的目錄名改為bbs(bbs論壇): //更名只是為了方便在瀏覽器地址框輸入地址
技術分享圖片
在httpd.conf文件中將默認的字符格式註釋掉並改為bbs論壇的GB2312(更改完成記得重啟httpd服務):
#AddDefaultCharset UTF-8
AddDefaultCharset GB2312

測試創建bbs論壇(Discuz!論壇系統)結果:
技術分享圖片
點擊同意:
技術分享圖片
在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}
賦予權限後如下:
技術分享圖片
技術分享圖片
點擊下一步:
技術分享圖片
按需求,然後下一步,安裝數據庫:
技術分享圖片
等待安裝過程:
技術分享圖片
安裝bbs論壇成功:
技術分享圖片
點擊註冊一個用戶名:
技術分享圖片
在服務器端會顯示bbs論壇的數據庫ultrax:
技術分享圖片
至此,bbs論壇(Discuz!論壇系統)創建成功。

(2)搭建wordpress博客系統(需要手動建立數據庫和對用戶進行授權)
把壓縮包解壓後的wordpress目錄更名為wp:
[root@chenliang vhost1]# mv wordpress/ wp/
本地瀏覽器端測試主頁:
技術分享圖片
切換到wp目錄中:
[root@chenliang vhost1]# cd wp/
修改配置文件,添加設置數據庫的名稱、數據庫用戶名、數據庫密碼、主機IP:(其他有需要再編輯)
[root@chenliang wp]# vim wp-config-sample.php
技術分享圖片
wpdb數據庫需要在我們服務器端進行手動授權:
技術分享圖片
對用戶wpuser進行訪問授權:

mysql> grant all on wpdb.* to ‘wpuser‘@‘%‘ identified by ‘123456‘; //向要對wpdb數據庫訪問的用戶wpuser進行訪問授權
Query OK, 0 rows affected (0.02 sec)

之後在客戶端(這裏是本地)瀏覽器端測試主頁登錄安裝,按上面配置好的用戶名和密碼主機IP等登錄:
技術分享圖片
按下圖中的要求在wp目錄中添加相應文件:
技術分享圖片
填寫好下圖中的基本信息後安裝wordpress博客系統:
技術分享圖片
如下圖所示,安裝wordpress博客系統成功:
技術分享圖片
進入wordpress博客系統管理員主界面:
技術分享圖片
至此,wordpress博客系統搭建成功。

(3)配置phpMyAdmin應用程序
把壓縮包解壓後的phpMyAdmin目錄更名為pma:
[root@chenliang vhost1]# mv phpMyAdmin-3.5.4-all-languages pma
直接在瀏覽器鍵入地址:
技術分享圖片
在主頁可以看到服務器端存在的數據庫(包括上面兩個論壇的ultrax和wpdb數據庫):
技術分享圖片
在這裏可以創建其他表,例如在mydb中創建一個學生成績表:
技術分享圖片
技術分享圖片
服務器端顯示的有剛剛創建的學生成績表:
技術分享圖片
技術分享圖片
至此,phpMyAdmin應用程序配置成功。

以上,就是使用httpd-2.2(在CentOS6中)配置部署Discuz!論壇系統、wordpress博客系統和phpMyAdmin應用程序。

httpd-2.2部署Discuz!論壇系統、wordpress博客系統和phpMyAdmin程序