BREAKING:

Deploy website to Hostinger from Git (Bitbucket)

BƯỚC 1: SSH vào Hostinger

Từ máy tính của bạn (Windows dùng PuTTY hoặc Git Bash / macOS & Linux dùng Terminal):

ssh your-username@your-domain.com

Hoặc từ Hostinger hPanel → Advanced → SSH Access → dùng Terminal online.


🔹 BƯỚC 2: Tạo SSH key trên Hostinger (nếu chưa có)

ssh-keygen -t rsa -b 4096 -C "your-email@example.com"

      • Khi được hỏi nơi lưu file, cứ nhấn Enter (lưu mặc định)

      • Không cần đặt passphrase

    Sau đó bạn sẽ có file:

        • ~/.ssh/id_rsa – private key

        • ~/.ssh/id_rsa.pub – public key


      🔹 BƯỚC 3: Thêm public key vào Bitbucket (hoặc GitHub)

          1. Mở key: cat ~/.ssh/id_rsa.pub

          1. Copy nội dung

          1. Truy cập Bitbucket:
                • Profile → Personal SettingsSSH Keys → Add Key

                • Dán key và lưu lại


          🔹 BƯỚC 4: Kiểm tra kết nối SSH tới Git

          ssh -T git@bitbucket.org

          Kết quả thành công sẽ là:

          logged in as titach-admin.


          🔹 BƯỚC 5: Clone repository về host

              1. Di chuyển đến thư mục public_html hoặc sub-folder mong muốn:

            cd ~/public_html

                1. Clone repo:

              git clone git@bitbucket.org:your-username/your-repo-name.git

              Ví dụ:

              git clone git@bitbucket.org:titach-admin/html-landing-page.git


              🔹 BƯỚC 6: (Tuỳ chọn) Di chuyển nội dung repo ra public_html

              Nếu sau khi clone bạn có cấu trúc như sau:

              public_html/
              └── html-landing-page/
              ├── index.html
              └── assets/

              Bạn có thể move ra ngoài:

              mv html-landing-page/* html-landing-page/.* .
              rmdir html-landing-page

              ⚠️ Dòng trên sẽ move cả file ẩn (.htaccess), nhưng tránh move ..., nếu cần thì dùng lệnh sau an toàn hơn:

              shopt -s dotglob
              mv html-landing-page/* .
              rmdir html-landing-page
              shopt -u dotglob


              🔹 BƯỚC 7: Kiểm tra trên trình duyệt

              Truy cập https://your-domain.com để kiểm tra website đã hiển thị đúng chưa.


               

              Post A Comment

              Your email address will not be published. Required fields are marked *

              Leave a Reply