網路上有許多centos安裝wordpress教學,但都不太完整,這篇文章會以圖一步一步說明。
安裝CentOS時可以選擇軟體GNOME,方便以下操作。
此篇指令如需使用root權限則以sudo代替,不建議使用root帳號,不小心輸入錯誤指令會導致系統損毀
1.開啟終端機輸入
sudo yum -y install mariadb-server mariadb
2.輸入你在安裝centos時設定的使用者密碼
3. systemctl start mariadb.service 開啟MariaDB
4.systemctl enable mariadb.service 設定開機自動啟用
5.sudo mysql_secure_installation mysql安全設定
6.按下Enter
7.n
8.Y
9.輸入Root密碼
10.Y
11.Y
12.Y
13.sudo mysql -u root -p 登入MariaDB
14.輸入使用者密碼
15.CREATE DATABASE wordpress; 建立資料庫wordpress 名稱可自訂
16.CREATE USER wpuser; 建立使用者wpuser 名稱可自訂
17.SET PASSWORD FOR wpuser= PASSWORD('1234'); 輸入密碼1234 密碼可自訂
18.GRANT ALL PRIVILEGES ON wordpress.* TO wpuser IDENTIFIED BY '1234'; 設定wpuser具有wordpress資料庫的完整權限
19.exit
20.sudo yum -y install httpd 安裝Apache HTTPd
21.systemctl start httpd.service 開啟httpd服務
22.systemctl enable httpd.service 設定開機自動啟用
23.firewall-cmd --permanent --zone=public --add-service=http 防火牆開啟http
24.firewall-cmd --permanent --zone=public --add-service=https 防火牆開啟https
25.sudo yum -y install php 安裝php
26.systemctl restart httpd.service 重啟Apache
27.sudo yum install epel-release 安裝 EPEL Repository
28.y
29.y
30.sudo yum install phpMyAdmin 安裝phpMyAdmin
31.y
32.y
33.sudo vi /etc/httpd/conf.d/phpMyAdmin.conf 編輯 phpMyAdmin 設定
34.更改成一下內容, 編輯模式請按i,編輯結束請按ESC
<Directory /usr/share/phpMyAdmin/>
Options none
AllowOverride Limit
Require all granted
</Directory>
35.按下: 鍵 輸入wq
36.sudo vi /etc/phpMyAdmin/config.inc.php 修改 phpMyAdmin 認證方式
37.$cfg['Servers'][$i]['auth_type']='cookie'; 改成$cfg['Servers'][$i]['auth_type']='http';
38.按下:鍵 輸入wq
39.systemctl restart httpd.service 重啟 Apache
40.cd /var/www/html 進入html路徑
41.sudo wget https://tw.wordpress.org/latest-zh_TW.tar.gz 下載wordpress
42.sudo tar -xzvf latest-zh_TW.tar.gz 解壓縮wordpress
43.sudo chown -R apache:apache /var/www/html/wordpress 更改wordpress擁有者
44.sudo chmod -R 755 /var/www/html/wordpress 更改wordpress權限
45.systemctl restart httpd.service 重啟Apache
46.cd wordpress 進入wordpress路徑
47.sudo cp wp-config-sample.php wp-config.php 複製wp-config-sample.php到wp-config.php
48.sudo vi wp-config.php 修改wp-config.php
49.更改資料庫的設定
50.開啟瀏覽器 http://你的固定ip/wordpress 輸入網站資訊後點安裝WordPress
51.安裝完成 登入wordpress
52.輸入剛剛網站資訊的帳號密碼
53.成功進入wordpress
發生未知錯誤
如果進入外觀或外掛時出現錯誤,請照以下步驟
1.開啟終端機 輸入 cd ~
2.輸入 sudo setsebool -P httpd_can_network_connect 1 開啟網路權限
3.解決問題
參考資料:https://blog.marklee.tw/setup-wordpress-on-centos7/
