การ FTP ใน AWS EC2

29 มิ.ย. 2018 , 4,091 Views   , หมวดหมู่ AWS โค๊ดดิ้ง   , ป้ายกำกับ:, ,


ก่อนอื่นให้ติดตั้งโปรแกรม FileZilla ก่อนหากยังไม่มีให้ดาวน์โหลดได้จากลิ้งค์นี้ https://filezilla-project.org/download.php

  • โดยเข้าไปที่ File->Site Manager แล้ว New Site ขึ้นมา โดยให้ใส่ข้อมูลดังนี้
    Protocol : SFTP – SSH File Transfer Protocol
    Host: ก็คือ Public DNS
    Logon Type : Key file
    User: ubuntu
    Keyfile : ไฟล์ private key สำหรับ PuTTY ตามลิ้งค์นี้ การเชื่อมต่อ AWS EC2 ด้วย PuTTY
  • ลอง FTP ดูก็จะเห็นได้ว่า FTP เข้ามาได้ โดยจะชี้ไปยังโฟลเดอร์ /home/ubuntu

    ส่วนโฟลเดอร์สำหรับอัพโหลดเว็บไซต์จะอยู่ใน /var/www/html
    หากลองทำการอัพโหลดไฟล์ดูจะเห็นว่าติด Permission denied อัพโหลดขึ้นไม่ได้ ซึ่งต้องทำการกำหนด Permission ก่อน

กำหนด Permission ให้สามารถอัพโหลดไฟล์ใน FTP ได้

  • Add the www group to your EC2 instance with the following command:
  • Add the ubuntu user to the www group:
  • To refresh your permissions and include the new www group, log out:
  • Log back in again and verify that the www group exists with the groups command:
  • Change the group ownership of the /var/www directory and its contents to the www group:
  • Change the directory permissions of /var/www and its subdirectories to add group write permissions and set the group ID on subdirectories created in the future:
  • Recursively change the permissions for files in the /var/www directory and its subdirectories to add group write permissions:

หลังจากนั้นลอง FTP ไฟล์ขึ้นไปใน  /var/www/html  จะเห็นว่า FTP ขึ้นไปได้ครับ

อ้างอิง
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html

http://www.select2web.com/webservice/amazon-elastic-computer-cloud-ec2-part-10-ftp.html


ป้ายกำกับ:, ,