##導語:
WordPress是一個以PHP和MySQL為平臺的自由開源的部落格軟體和內容管理系統。WordPress具有外掛架構和模板系統。Alexa排行前100萬的網站中有超過16.7%的網站使用WordPress。 #一.LAMP環境搭建 LAMP即Linux+Apache+MySQL(MariaDB)+PHP,由於其開源免費,所以是目前非常受歡迎的一組網站解決方案,本文也將採用此方案。 ##1.Linux選擇 筆者選用的是CentOS 7.2這個版本,CentOS實質為無支援版的RHEl,穩定性還是比較高的,當然也可以選擇其它發行版,只是後續的操作略有不同,本文將只介紹在CentOS下的操作(系統的安裝和本文關係不大,故不再贅述)。 ##2.安裝Apache 直接yum安裝
# yum -y install httpd
安裝完成後,啟動服務# systemctl start httpd.service
設定為開機啟動# systemctl enable httpd.service
之後可以在瀏覽器輸入localhost進行測試,由於筆者沒有安裝GUI,只能在客戶端瀏覽器進行測試,在這之前需要開啟80和443埠
首先開啟防火牆並設定為開機啟動
# systemctl start firewalld.service
# systemctl enable firewalld.service
開啟埠(80和443)
# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https
重啟防火牆
# firewall-cmd --reload
查詢已開啟埠
# irewall-cmd --list-ports


同樣還是利用yum命令進行安裝,並且配置開機啟動
# yum -y install mariadb-server mariadb
# systemctl start mariadb.service
# systemctl enable mariadb.service
配置root密碼
# mysql_secure_installation
配置過程中會有幾個選項,大家根據自己的需要進行配置就好了

# mysql -u root -p
為WordPress建立資料庫
# CREATE DATABASE wordpress;
檢視建立結果

# CREATE USER username@localhost IDENTIFIED BY 'password';
說明:username - 你將建立的使用者名稱, host - 指定該使用者在哪個主機上可以登陸,如果是本地使用者可用localhost, 如果想讓該使用者可以從任意遠端主機登陸,可以使用萬用字元%. password - 該使用者的登陸密碼,密碼可以為空,如果為空則該使用者可以不需要密碼登陸伺服器.
更改使用者許可權,儲存並退出
# GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;
# FLUSH PRIVILEGES;
# exit
重啟服務
# systemctl restart mariadb.service
##4.安裝PHP及相關元件
首先安裝PHP
# yum -y install php
安裝相關元件
# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
安裝完成之後我們可以新建一個php頁面進行測試
# vim /var/www/html/info.php
編輯為以下內容

# systemctl restart httpd.service
開啟網址 http://x.x.x.x/info.php 進行檢視(x.x.x.x為vps的ip地址)

# yum -y install wget unzip net-tools
下載WordPress
# wget http://wordpress.org/latest.zip

# unzip -q latest.zip
# cp -rf wordpress/* /var/www/html/

# cd /var/www/html
# cp wp-config-sample.php wp-config.php
# vim wp-config.php
將其修改為以下格式(其中wordpress為資料庫名稱,wordpressuser為資料庫使用者名稱,10293847為資料庫密碼)

# systemctl restart httpd.service
# systemctl restart mariadb.service
#三.WordPress的個人設定
完成以上配置之後,便可以輸入http://yourserverip/來訪問你的部落格了。
-
選擇語言
-
填寫個人資訊

- 安裝完成

- 登入到儀表盤

至此WordPress已經搭建完成,之後可根據自己的需要進行其它配置
本文有參考網上其它文章,如侵犯到個人利益,請與我聯絡