Cài đặt Web Server cho Amazon EC2 Instance [Video Clip]
Đăng trong danh mục PHP, Web Programming bởi admin | Tags: amazon, ec2, installation, mysql, PHP, server, setup, web server
Đã lâu không viết blog, nay mình trở lại với bài viết hướng dẫn cài đặt một LAMP Stack hoàn chỉnh cho 1 Amazon EC2 Instance. Mình đã quay clip lại quá trình khởi tạo Instance cũng như cài đặt các phần mềm cần thiết cho Web Server.
Một số phần mềm đã cài cho Web Server là: Apache, PHP, MySQL, FTP cũng như các cấu hình FTP, Apache hỗ trợ virtual host…
Clip:
Hy vọng các bạn nào chưa từng tiếp cận với Amazon Web Service có thể có cái nhìn gần hơn về cách triển khai Amazon EC2. Tham khảo thêm Amazon EC2 tại http://aws.amazon.com/ec2.
——-
Dưới đây là các ghi chú của mình trong quá trình cài đặt được hướng dẫn trong Clip.
——————-
SETUP LAMP ON AMAZON EC2 INSTANCE
——————————
STEP 1:
- Setup EC2 instance with Linux 64bit AMI (Create new Security Group with following photo)
- Save permission file (private key file) to secret location, remove “other” permission for this file (because of security) and keep carefully.
- Allocate Elastic IP Address and assign to EC2 Instance
- SSH To EC2 Instance
STEP 2:
- Install Apache + Edit Httpd.conf, vhost.conf
- Install PHP + Edit php.ini
- Install MySQL
- Install PhpMyAdmin
- Install Vsftpd + Edit vsftpd.conf
STEP 3:
- Take a drink.
===============================================
Note:
- Security Group setting:
#SSH to EC2 instance
ssh -i /path/to/private_key.pem ec2-user@123.123.123.123
#change permission of private key file (.pem) downloaded from amazon (600)
sudo chmod 600 /path/to/private_key.pem
#Update YUM for latest package:
sudo yum -y update
——————————–
#Install MySQL server
sudo yum install mysql-server mysql
# Start mysql server
sudo /etc/init.d/mysqld start
# Set root password for MySQL (Choose a strong one if the
# MySQL TCP port is going to be left open.)
mysqladmin -u root password
=====================
= for security, we need to create other mysql user for our web project
=====================
# create new mysql account
mysql -u root -p
#after login to mysql
#create database
CREATE DATABASE mydatabase;
#create new user, password and assign all priviledge for this new user for only one selected database
GRANT ALL ON mydatabase.* TO newusername@localhost IDENTIFIED BY ‘mypassword’;
#now, you can use new mysql account and new database for your project
—————
#install Apache
sudo yum install httpd
#And then start apache with command:
sudo service httpd start
———-
NOW, can connect with browser to http://youripaddress/ to check apache running
——–
#install PHP
sudo yum install php php-common libmcrypt libmcrypt-devel php-mcrypt php-mbstring php-pear php-gd php-pear php-devel php-xml php-mysql php-pdo
#After which we’ll want to restart Apache:
sudo service httpd restart
#create phpinfo() to check installed php
#create new file on web server
sudo vi /var/www/html/phpinfo.php
#Learn more about vi command here: http://www.lagmonster.org/docs/vi.html
#in vi editor, type anycharacter to turn on — INSERT — mode
#type the content for this file
<?php
phpinfo();
#press ESC to exit INSERT mode
#type :wq and [ENTER] to save this file and exit vi editor.
———-
NOW, can connect with browser to http://youripaddress/phpinfo.php to check php information.
——–
#enable htaccess (for Rewrite URL) of current working www
#by default, the web home directory can not use .htaccess for rewrite url even the mod_rewrite had been enable (by default also). (Check mod_rewrite enable or not at httpd.conf file, the line
LoadModule rewrite_module modules/mod_rewrite.so
#must not have the pound ‘#’ character at the beginning)
#If your www directory is at “/var/www/html”, you need to open the apache httpd.conf (maybe in /etc/httpd/conf/httpd.conf) and change:
<Directory “/var/www/html”>
…
AllowOverride None
….
</Directory>
to
<Directory “/var/www/html”>
…
AllowOverride All
….
</Directory>
#restart apache
sudo service httpd restart
==========
#Install phpmyadmin
#Check documentRoot (usally /var/www/html/)
# to check the document Root, run the command “grep documentRoot /etc/httpd/conf/httpd.conf”
#Download latest PhpMyadmin (this example is 3.3.9.1)
#untar downloaded .gz file
sudo tar -xzvf phpMyAdmin-3.3.9.1-all-languages.tar.gz -C /var/www/html
#move to webroot
cd /var/www/html
#rename phpmyadmin directory
sudo mv phpMyAdmin-3.3.9.1-all-languages phpmyadmin
#create config file
cd /var/www/html/phpmyadmin
sudo cp config.sample.inc.php config.inc.php
#edit config file
sudo vi config.inc.php
#set blowfish_secret variable.
$cfg['blowfish_secret'] = ‘yoursecretstring’;
#save and exit vi editor.
ESC,
:wq
[ENTER]
=====================
= FTP SERVER INSTALLATION
=====================
#install vsftpd
sudo yum install vsftpd
#disable anonymous FTP user by editing file “/etc/vsftpd/vsftpd.conf”
sudo vi /etc/vsftpd/vsftpd.conf
anonymous_enable=YES
-> anonymous_enable=NO
#uncomment this line (default)
local_enable=YES
#add more setting for passive mode on FTP client connection
pasv_enable=YES
pasv_min_port=14000
pasv_max_port=14050
port_enable=YES
#if you have assigned Elastic IP Address to your Instance
pasv_address=72.44.42.109
pasv_addr_resolve=NO
#or if you use default Public DNS of Instance
pasv_address=ec2-72-44-42-109.compute-1.amazonaws.com
pasv_addr_resolve=YES
#start(or restart) vsftpd
sudo service vsftpd start
#edit Security Group inbound of current instance security group
#add port range 20-21 and 14000-14050 to allow connection in FTP
#we need to create a FTP user login
sudo useradd -d /var/www/html -G apache ftpuser
sudo passwd ftpuser
sudo chown -R ftpuser /var/www/html
sudo chmod 775 /var/www/html
Bài viết liên quan:
5 Lời bình cho bài viết “Cài đặt Web Server cho Amazon EC2 Instance [Video Clip]”
Viết lời bình
Bình luận mới nhất
- Giải thể công ty là hạnh phúc ?!
"@tranthe, Vụ người quản lý " - admin - Giải thể công ty là hạnh phúc ?!
"Kinh nghiệm là muốn làm 1 ý tưởng nào đó, càng lớn càng cần nhiều ngườ" - Lê Phạm Duy Hậu - Giải thể công ty là hạnh phúc ?!
"Cám ơn những chia sẻ của anh, nhưng mà việc mở thì vẫn phải mở, mở ra " - tranthe - Giải thể công ty là hạnh phúc ?!
"Há há, chúc mừng anh, hy vọng sẽ sớm có ngày hợp tác với anh, bên em đ" - Võ Phát - Giải thể công ty là hạnh phúc ?!
"Nhiêu đó chưa thấm gì mà, mỗi lần có liên quan tới giấy tờ là anh chị " - luckyluu - Tham gia quảng cáo trên ứng dụng Android
"Hi Tuấn, Mình là Thu. Hiện tại mình đang rất quan tâm đến việc hợp " - Tien Thu - phpmailer gởi mail SMTP bằng Gmail/Google Apps
"một số hosting bây giờ để chống spam họ đã chặn luôn cả phpmailer." - nokia 6110 - Ứng dụng Mobile Android
"hay" - thanh - Review sách: Người giỏi không phải là người làm tất cả
"sach toi chua doc nhung toi da nghe wa ve no tren internet nhung tuo" - huong dai ca - Karaoke Vietnam - Ứng dụng Android đầu tay
"Ứng dụng mang tính thực tế cao và rât hay. Mình đang làm đồ án tốt ngh" - Thinh
Danh mục
- android (3)
- Business (26)
- Flash (1)
- Graphic Design (16)
- IT Guys (1)
- Javascript (9)
- Miscellaneous (58)
- Photography (9)
- PHP (43)
- Review sách (13)
- Search Engine Optimization (2)
- security (3)
- software (5)
- User Interface Design & Usability (8)
- Web Design (29)
- Web Programming (53)
Lưu trữ
- June 2013 (2)
- September 2012 (1)
- May 2012 (2)
- March 2012 (2)
- February 2012 (1)
- January 2012 (1)
- December 2011 (1)
- November 2011 (2)
- September 2011 (2)
- August 2011 (1)
- July 2011 (4)
- June 2011 (2)
- May 2011 (2)
- April 2011 (2)
- March 2011 (2)
- February 2011 (2)
- January 2011 (4)
- December 2010 (6)
- November 2010 (3)
- October 2010 (3)
- September 2010 (5)
- August 2010 (6)
- July 2010 (5)
- June 2010 (2)
- May 2010 (5)
- April 2010 (7)
- March 2010 (8)
- February 2010 (4)
- January 2010 (10)
- December 2009 (12)
- November 2009 (12)
- October 2009 (15)
- September 2009 (16)
- August 2009 (11)
- July 2009 (15)
- November 2008 (1)
- October 2008 (1)
- September 2008 (3)




October 9, 2012 at 8:46 pm
Bài viết rất chi tiết
[Reply]
October 12, 2012 at 11:20 am
Bài viết chi tiết. Và EC2 có phải là giải pháp cho doanh nghiệp vừa và nhỏ ko?
[Reply]
October 31, 2012 at 9:44 pm
rất đầy đủ cảm ơn nhé .. thích nhất là cái Video dễ hiểu
[Reply]
December 23, 2012 at 3:56 pm
Có video hướng dẫn cách tự deploy Amazon EC2 không ?
[Reply]
December 27, 2012 at 1:33 pm
cảm ơn bài viết, mình thấy rất thú vị!
[Reply]