Raspberry Pi學習筆記(十六):搭建WordPress網站和Discuz!論壇(Apache+Nginx+PHP+MySQL)

Yanwei Liu
4 min readMay 22, 2019

--

#20190906更新:

使用樹莓派架設伺服器 Part1( Apache2+PHP+MySQL+phpyadmin)

使用樹莓派架設伺服器 Part2( phpMyAdmin)

更新軟體源

sudo apt-get update
sudo apt-get upgrade

安裝Apache

sudo apt-get install apache2
service apache2 status #伺服器狀態
sudo service apache2 start #啟動
sudo service apache2 stop #關閉
#輸入樹莓派IP地址,確認Apache是否正常運作
#預設目錄在/var/www

安裝Nginx

sudo apt-get install nginx
sudo /etc/init.d/nginx start #啟動
#預設目錄在/usr/share/nginx/www

安裝MySQL

sudo apt-get install mysql-server
#安裝時,須設定帳戶root及密碼
mysql -u root -p #進入資料庫create database 資料庫名稱 #建立資料庫
use 資料庫名稱 #卡開資料庫
#建立以pi_id為主鍵,varchar(10)類型的pi_password欄位,名為pi_user的表
create TABLE pi_user (pi_id int auto_increment not null primary key,pi_password varchar(10))
SHOW TABLES #顯示表sudo /etc/init.d/mysql start #啟動
sudo /etc/init.d/mysql stop #關閉

安裝PHP

sudo apt-get install php7

安裝WordPress

sudo apt-get install php7-mysql
sudo apt-get install wordpress
#將WordPress加入Apache的跟目錄中
sudo ln -s /WordPress所在資料夾/ /var/www/wordpress
#進入資料庫
mysql -u root -p
#建立資料庫
create databasses wordpress
#進入根目錄
cd /var/www/wordpress
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php
開啟後,自行修改資料庫名稱、用戶名及密碼
#重啟MySQL
sudo /etc/init.d/mysql stop #關閉
sudo /etc/init.d/mysql start #啟動

#重啟Apache
sudo service apache2 stop #關閉
sudo service apache2 start #啟動
#進入WordPress建站程式
樹莓派IP地址/wordpress

安裝Discuz!

#下載
sudo wget http://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_UTF8.zip
#解壓縮
sudo unzip Discuz_X3.3_SC_UTF8.zip
#賦予權限
chmo 777-R Upload
#重啟MySQL
sudo /etc/init.d/mysql stop #關閉
sudo /etc/init.d/mysql start #啟動
#重啟Apache
sudo service apache2 stop #關閉
sudo service apache2 start #啟動
#進入Discuz!建站程式
樹莓派IP地址/discuz

--

--

No responses yet