2014年12月7日 星期日

EC2 linux apache httpd+php+MySql+phpMySqlAdmin

先說,EC2 linux 跟Centos不一樣,他的yum內容,是amz自己維護的,所以其實有很多東西有少,或者名字不一樣~所以~當初看到他的廣告宣傳說有MySQL...Postgresql就很高興的選了...然後就發生了一些事情|||Orz...

EC2上面好像沒有Centos,可能是怕搶到紅帽的飯碗,另一個要免費的就是ubuntu。
其實ubuntu也不是不好,最早一開始也是用ubuntu server...但是因為某次他跟kvm還是vitural box太不合,加上當時同事也吵著要用centos...所以後來就改centos了~

在EC2要 yum時,建議先用yum查詢一下~e.g. yum list postgres*
這樣才不會一直被騙XD..因為網路上的資源大都以CentOs為主...

1. Install apache httpd
apache和 php依然是相當的快樂和平順~
記得當初開instance時,防火牆要開80,預設只有22(ssh)
話說,為啥特別把document root搬家,因為原本那邊是root的領域,換到一般user的資料夾下,統一管理比較方便...
sudo yum -y install httpd
vim /etc/httpd/conf/httpd.conf
##change document root to somewhere...
sudo service httpd start

vim /...somewhere.../www/html/index.html
##write something in index.html
##test http://xxx.xxx.xxx.xxx/

2. Install php
sudo yum -y install php
vim /...somewhere.../www/html/index.php
##write something in index.php
sudo service httpd start

##test http://xxx.xxx.xxx.xxx/index.php

3. Install MySQL
MySQL 在上面,看起來最新就只到5.5,忍著點吧O_o|||,反正用MySQL的也不會要求什麼強大的功能,基本的能動不要有bug就好!
yum list mysql*
sudo yum install mysql55-server.x86_64
chkconfig --list (check mysql service name)
sudo service mysqld start
sudo service mysqld status  (check status)
## set mysql root password
/usr/bin/mysqladmin -u root password

4. Install phpMyAdmin
這個怪打超久的,中間還死了兩三次XD...網路上普遍是說,用tar的回來自己解,然後改設定檔...嗯,這種方式以前在win上玩過是ok,但是在EC2上試,就很鬼的一直白頁面。很不想還要去開php log來de的事情,還翻到了某個日文版的攻略...重點是還裝起來了(日文有漢字真好!)只是他是很舊的phpmyadmin...但是~能用就好XD...
(說到當年要裝python一個很鳥的套件,也是日文攻略來的,這要說台日友好嗎XD)

這個方法是用rpmforge的資源,其實我後來有去看一下他最新發布的,但是phpmyadmin還是在2版,社群資源還是有差...
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
rpm -Uvh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
sudo vim /etc/yum.repos.d/rpmforge.repo

[rpmforge]
name = Red Hat Enterprise $releasever - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/$basearch/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 0                             <---edit
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
priority = 10                         <---edit

yum -y --enablerepo=rpmforge install phpmyadmin
sudo vim /usr/share/phpmyadmin/config.inc.php



$cfg['blowfish_secret'] = 'a8b7c6d';    <---原本是空白,隨便找一個範例塞的

sudo vim /etc/httpd/conf.d/virtualhost.conf
<VirtualHost *:80>
    alias /phpmyadmin /usr/share/phpmyadmin/
    <Directory "/usr/share/phpmyadmin">
        Options ExecCGI
        AllowOverride all
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>

##restart httpd
sudo service httpd restart

在這個版本的phpmyadmin裡,他的phpmyadmin.conf,有寫了多重路徑都可以轉到,覺得有需要改就改吧:)



沒有留言: