使用 ssh 指令連接到 EC2 主機
-i 為 .pem 檔案位置
使用者為 ec2-user
@後面請接上 剛剛 EC2 主機的 public DNS 名稱
> ssh -i /home/max/Downloads/awstest.pem ec2-user@ec2-174-129-98-2.compute-1.amazonaws.com
成功的話會出現
__| __|_ )
_| ( / Amazon Linux AMI
___|\___|___|
See /usr/share/doc/system-release/ for latest release notes.
There are 14 security update(s) out of 18 total update(s) available
的歡迎畫面
我們此次使用 wordpress 來進行實作
首先切換身份為 root
$sudo -i
首先先升級套件
#yum update
Dependencies Resolved
===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
kernel i686 2.6.35.14-103.47.amzn1 amzn-updates 7.5 M
Updating:
aws-amitools-ec2 noarch 1.4.0.2-1.3.amzn1 amzn-updates 88 k
aws-cfn-bootstrap noarch 1.0-6.amzn1 amzn-updates 51 k
nspr i686 4.8.8-1.11.amzn1 amzn-updates 121 k
nss i686 3.12.10-2.23.amzn1 amzn-updates 876 k
nss-sysinit i686 3.12.10-2.23.amzn1 amzn-updates 30 k
nss-util i686 3.12.10-1.9.amzn1 amzn-updates 50 k
perl i686 4:5.10.1-119.12.amzn1 amzn-updates 11 M
perl-Compress-Raw-Zlib i686 2.023-119.12.amzn1 amzn-updates 75 k
perl-Compress-Zlib i686 2.020-119.12.amzn1 amzn-updates 44 k
perl-Digest-SHA i686 1:5.47-119.12.amzn1 amzn-updates 64 k
perl-IO-Compress-Base i686 2.020-119.12.amzn1 amzn-updates 69 k
perl-IO-Compress-Zlib i686 2.020-119.12.amzn1 amzn-updates 151 k
perl-Module-Pluggable i686 1:3.90-119.12.amzn1 amzn-updates 38 k
perl-Pod-Escapes i686 1:1.04-119.12.amzn1 amzn-updates 31 k
perl-Pod-Simple i686 1:3.13-119.12.amzn1 amzn-updates 219 k
perl-libs i686 4:5.10.1-119.12.amzn1 amzn-updates 634 k
perl-version i686 3:0.77-119.12.amzn1 amzn-updates 49 k
Installing for dependencies:
python-daemon noarch 1.5.2-1.2.amzn1 amzn-updates 32 k
python-lockfile noarch 0.8-3.2.amzn1 amzn-updates 17 k
Transaction Summary
===============================================================================================================================================
Install 3 Package(s)
Upgrade 17 Package(s)
Total download size: 21 M
Is this ok [y/N]: y 輸入y升級套件 (此時可以感受套件飛快的安裝)
接下來安裝 相關套件
#yum install php httpd mysql-server php-mysql
Dependencies Resolved
===============================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================
Installing:
httpd i686 2.2.21-1.19.amzn1 amzn-updates 1.1 M
mysql-server i686 5.1.52-1.6.amzn1 amzn-main 10 M
php i686 5.3.8-3.20.amzn1 amzn-updates 1.3 M
php-mysql i686 5.3.8-3.20.amzn1 amzn-updates 89 k
Installing for dependencies:
apr i686 1.3.9-3.8.amzn1 amzn-main 126 k
apr-util i686 1.3.9-3.9.amzn1 amzn-main 84 k
apr-util-ldap i686 1.3.9-3.9.amzn1 amzn-main 6.9 k
httpd-tools i686 2.2.21-1.19.amzn1 amzn-updates 76 k
mysql i686 5.1.52-1.6.amzn1 amzn-main 1.0 M
mysql-libs i686 5.1.52-1.6.amzn1 amzn-main 1.7 M
perl-DBD-MySQL i686 4.013-3.4.amzn1 amzn-main 144 k
perl-DBI i686 1.609-4.4.amzn1 amzn-main 742 k
php-cli i686 5.3.8-3.20.amzn1 amzn-updates 2.5 M
php-common i686 5.3.8-3.20.amzn1 amzn-updates 625 k
php-pdo i686 5.3.8-3.20.amzn1 amzn-updates 82 k
system-logos noarch 4.9.99-11.13.amzn1 amzn-main 9.7 k
Transaction Summary
===============================================================================================================================================
Install 16 Package(s)
Total download size: 20 M
Installed size: 47 M
Is this ok [y/N]: y 輸入y安裝套件
啟動相關服務
#service httpd start
# chkconfig httpd --list
httpd 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
# chkconfig httpd on
# chkconfig httpd --list
httpd 0:關閉 1:關閉 2:開啟 3:開啟 4:開啟 5:開啟 6:關閉
#service mysqld start
# chkconfig mysqld --list
mysqld 0:關閉 1:關閉 2:關閉 3:關閉 4:關閉 5:關閉 6:關閉
# chkconfig mysqld on
# chkconfig mysqld --list
mysqld 0:關閉 1:關閉 2:開啟 3:開啟 4:開啟 5:開啟 6:關閉
設定 mysql 內root 密碼為 password (這邊請設定自訂的密碼)
#mysqladmin -u root password 'password'
#mysql -u root -p
Enter password: 請輸入剛剛設定的密碼
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.52 Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
建立 mysql database 名稱為 wordpress
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
離開 mysql
mysql> exit
取得 wordpress 相關套件
#wget http://tw.wordpress.org/wordpress-3.2.1-zh_TW.tar.gz
解壓縮套件
#tar -xzvf wordpress-3.2.1-zh_TW.tar.gz
將解壓縮後的目錄移動到 apache 根目錄下(這邊預設 DocumentRoot 為 /var/www/html)
#mv wordpress/* /var/www/html
刪除相關檔案
#rm -rf wordpress
#rm -f wordpress-3.2.1-zh_TW.tar.gz
調整 相關權限及擁有人
#chown -R apache:apache /var/www/html/
設定 Wordpress
請開啟瀏覽器 輸入 Public DNS Name
請點選建立一個設定檔
請點選 "衝吧"
請輸入相關資訊 (使用者帳號, 密碼, 資料庫名稱)
請點選 送出
請點選 開始安裝
請輸入相關資訊
請點選 安裝 WordPress
已經完成安裝
請點選登入
大功告成