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

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

httpd-2.4部署博客論壇和應用程序

檢查環境(關閉防火墻和改變SELinux狀態,保證外界可以訪問):

[root@chenliang ~]# iptables -F //-F代表無論如何都關閉防火墻,生產環境不建議
[root@chenliang ~]# iptables -vnL
Chain INPUT (policy ACCEPT 5 packets, 448 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 4 packets, 496 bytes)
pkts bytes target prot opt in out source destination
[root@chenliang ~]# getenforce
Enforcing
[root@chenliang ~]# setenforce 0
[root@chenliang ~]# getenforce

Permissive
保證mariadb服務(在CentOS7中使用mariadb)開啟
技術分享圖片

采用LAMP組合的快速架構搭建:Linux+Apache(httpd)+mariadb+PHP

1.安裝需要的程序包:
[root@chenliang ~]# yum install httpd php php-mysql mariadb.service
2.創建虛擬主機:創建虛擬主機並為主機提供一個測試頁面

[root@chenliang ~]# cd /etc/httpd/conf.d
[root@chenliang conf.d]# ls
autoindex.conf manual.conf php.conf README ssl.conf userdir.conf welcome.conf

[root@chenliang conf.d]# vim vhost.conf
<VirtualHost 172.16.72.2:80>
DocumentRoot /var/www/vhost
ServerName www.clvhost.com
<Directory "/var/www/vhost">
Options None
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
[root@chenliang conf.d]# mkdir -pv /var/www/vhost
mkdir: 已創建目錄 "/var/www/vhost"
[root@chenliang conf.d]# echo "This is httpd-2.4 vhost‘s homepage." >> /var/www/vhost/index.html[root@chenliang conf.d]# vim vhost.conf
[root@chenliang conf.d]# systemctl restart httpd.service
在本地主機系統C盤下\Windows\System32\drivers\etc\hosts文件添加:172.16.72.2 www.clvhost.com
開始測試虛擬機創建的結果如下圖,成功創建虛擬機並顯示測試界面:
技術分享圖片

3.在MySQL中創建並授權用於測試的用戶賬戶,進行php連接數據庫測試(要保證mysql服務開啟:systemctl restart mariadb.service):

[root@chenliang conf.d]# cd /var/www/vhost
[root@chenliang vhost]# ls
index.html
[root@chenliang vhost]# mv index.html index.php
[root@chenliang vhost]# vim index.php
This is httpd-2.4 vhost‘s homepage.~~~~ </br>
<?php
$conn = mysql_connect(‘172.16.72.2‘,‘chenliang‘,‘123456‘);
if($conn)
echo "Connect successful.";
else
echo "Connect failed.";
?>

在服務器數據庫中先授權一個用戶chenliang,用來數據庫連接測試:
技術分享圖片
測試結果如下,連接數據庫成功:
技術分享圖片
4.部署應用程序:
首先將wordpress博客系統、Discuz!論壇系統(僅需放置一個名為upload的目錄)及phpMyAdmin應用程序放置於/etc/httpd/conf.d/vhost/下:
解壓並更名(更名是為了方便在地址框鍵入地址):
技術分享圖片
掉了一個bbs目錄,補上:[root@chenliang vhost]# mv upload/ bbs/
(1)搭建Discuz!論壇系統
技術分享圖片
解決亂碼問題:
[root@chenliang vhost]# vim /etc/httpd/conf/httpd.conf
#AddDefaultCharset UTF-8 //僅僅是註釋掉,方便以後操作
AddDefaultCharset GB2312
記得重啟httpd服務:
[root@chenliang vhost]# systemctl restart httpd.service
刷新:
技術分享圖片
同意後在服務器端更改目錄讀寫權限:
技術分享圖片
更改目錄權限操作:
技術分享圖片
刷新,下一步,按提示鍵入設置,設置會在安裝過程中新建到服務器端數據庫中:
技術分享圖片
安裝成功:
技術分享圖片
技術分享圖片
在主頁中註冊的用戶以及信息會自動錄入到服務器的數據庫中;
至此,Discuz!論壇系統初始布置完成。
(2)wordpress博客系統
進入本地瀏覽器主頁打開WordPress首頁:
技術分享圖片
如上圖所示,我們需要先一步在服務器端準備所需要的數據庫名、數據庫用戶名、數據庫密碼、數據庫主機,並授權權限:
新建數據庫(mysql命令):
MariaDB [(none)]> create database wpdb character set =utf8;
Query OK, 1 row affected (0.01 sec)
在配置文件中wp-config-sample.php 作如下圖配置:
[root@chenliang wp]# vim wp-config-sample.php
技術分享圖片
使用mysql命令賦予數據庫用戶對數據庫wpdb的權限:
MariaDB [(none)]>grant all on wpdb.* to ‘wpuser‘@‘172.16.%.%‘ identified by ‘123456‘;

根據下圖提示,在wp目錄下新建配置文件 wp-config.php:
技術分享圖片
之後,按要求設定管理員賬號和密碼,最後進入登錄界面:
技術分享圖片
技術分享圖片
至此,配置wordpress博客系統成功。

(3)安裝phpMyAdmin應用程序,用來圖形化顯示和管理服務器端的數據庫:
進入首頁:
技術分享圖片
root超級管理員才能登錄,密碼使用在服務器端設置的數據庫管理員密碼,登錄後可以看到之前配置產生的數據庫wpdb和ultrax:
技術分享圖片
至此,安裝phpMyAdmin應用程序成功。

至此,httpd-2.4部署Discuz!論壇系統、wordpress博客系統和phpMyAdmin程序,成功。

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