修改權限
剛建立好的系統都有預設的權限設定,權限設定通常使用最高權限,若要透過 FileZilla 上傳 WordPress 軟體,就需要透過調整才能上傳成功。
輸入指令:進入 HTML 資料夾
指令:cd /var/www/html

前方位置多了 html 的文字,代表目前已經在 html 的資料夾了。

輸入指令,查詢權限代號
指令:ps aux | grep apache # The username should be in thefirst column.
第一個出現的單字,就是權限代號

確認 apache 的權限成員
指令:groups apache

輸入指令,更改 html 權限。
指令:sudo chown -R ec2-user:apache ../html

輸入指令,變動檔案權限
指令:sudo chmod g+rw -R ../html

透過 FileZilla 上傳 WordPress
點擊主機圖示,新增連線設定

點擊「新增站台」

命名站台

協定選擇 SFTP,主機貼上 EC2 的 IP,使用者為「ec2-user」,點擊「瀏覽」上傳 PPK 金鑰。
最後點擊「連線」。

顯示成功取得目錄代表登入成功。

在遠端站台欄位輸入「/var/www/html」,開啟 html 資料夾。

將準備好的 WordPress(前往下載),滑鼠點擊檔案,右鍵 ->「上傳」。

等待上傳成功。

透過 SSH 連線設定 WordPress
輸入指令,確認檔案是否有在 html 資料夾。
指令:ls -al
*注意要在 html 資料夾操作,若重開連線,記得先使用「cd /var/www/html」指令到 html 資料夾。

輸入指令,解壓縮檔案。
指令:tar zxvf 檔案名稱(包含格式)
*若下載的壓縮檔案格式與範例不同,可透過此頁搜尋適合的解壓縮指令。

輸入指令,確認解壓縮成功。
指令:ls -al
看到多一個資料夾「wordpress」。

輸入指令,將 wordpress 資料夾內的資料搬上來
指令:sudo cp -r wordpress/* /var/www/html/

輸入指令,確認檔案移動成功
指令:ls

輸入指令,將剛剛的資料夾刪除
指令:rm -r wordpress

輸入指令,將壓縮檔案刪除
指令:rm -r 壓縮檔名(包含格式)

輸入指令,確認檔案刪除成功
指令:ls

輸入指令,複製範例
指令:cp wp-config-sample.php wp-config.php

輸入指令,編輯 WordPress 資料庫權限及 salt key
指令:nano wp-config.php

變更以下幾行資料庫資訊
// ** MySQL settings – You can get this info from your web host ** ///
** The name of the database for WordPress */
define( ‘DB_NAME’, ‘database_name_here’ );
/** MySQL database username */
define( ‘DB_USER’, ‘username_here’ );
/** MySQL database password */
define( ‘DB_PASSWORD’, ‘password_here’ );
/** MySQL hostname */
define( ‘DB_HOST’, ‘localhost’ );
值應當為:
DB_NAME︰wordpress
DB_USER︰RDS 主帳號
DB_PASSWORD︰RDS 主密碼
DB_HOST︰資料庫主機位置

變更以下八行 Salt Key
/**#@+
* Authentication Unique Keys and Salts.
*
* Change these to different unique phrases!
* You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
* You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
*
* @since 2.6.0
*/define( ‘AUTH_KEY’, ‘put your unique phrase here’ );
define( ‘SECURE_AUTH_KEY’, ‘put your unique phrase here’ );
define( ‘LOGGED_IN_KEY’, ‘put your unique phrase here’ );
define( ‘NONCE_KEY’, ‘put your unique phrase here’ );
define( ‘AUTH_SALT’, ‘put your unique phrase here’ );
define( ‘SECURE_AUTH_SALT’, ‘put your unique phrase here’ );
define( ‘LOGGED_IN_SALT’, ‘put your unique phrase here’ );
define( ‘NONCE_SALT’, ‘put your unique phrase here’ )
此連結可提供動態 Salt Key

按下 Ctrl + O 存檔,詢問檔案名稱,檔案名稱不變,直接按下 Enter 即可。

出現已寫入的資訊後,按下 Ctrl + X ,離開。

輸入指令,重啟 Apache
指令:sudo service httpd restart

開啟瀏覽器,輸入 EC2 的 IP,出現安裝精靈代表安裝成功。

部落格近期迴響