Hướng dẫn cài đặt

IT Equipment Management là hệ thống quản lý thiết bị IT và linh kiện toàn diện, được phát triển trên nền tảng ASP.NET Core 8.0 MVC. Hệ thống giúp doanh nghiệp theo dõi, quản lý vòng đời của thiết bị từ lúc nhập kho, đưa vào sử dụng, bảo dưỡng, sửa chữa cho đến thanh lý.

Yêu cầu hệ thống

Thành phầnYêu cầu tối thiểu
OSWindows Server 2016+ hoặc Windows 10+
Web ServerIIS 10 trở lên
RuntimeASP.NET Core 8.0 Runtime (Hosting Bundle)
DatabaseSQL Server 2019+ (Express hoặc Standard)
RAM≥ 4 GB
Disk≥ 2 GB trống
BrowserChrome, Edge, Firefox (bản mới nhất)

Bước 1: Cài đặt phần mềm cần thiết

1.1 ASP.NET Core 8.0 Hosting Bundle

  1. Tải từ: https://dotnet.microsoft.com/en-us/download/dotnet/8.0
  2. Chọn Hosting Bundle (Windows) ở phần ASP.NET Core Runtime
  3. Cài đặt → Khởi động lại máy

1.2 SQL Server

1.3 IIS

  1. Mở Control PanelProgramsTurn Windows features on or off
  2. Tích chọn:
    • ✅ Internet Information Services
    • ✅ Web Management Tools → IIS Management Console
    • ✅ World Wide Web Services → Application Development Features → ASP.NET 4.8
  3. Nhấn OK và đợi cài đặt

Bước 2: Tạo Database

2.1 Sử dụng SQL Script

  1. Mở SQL Server Management Studio (SSMS) hoặc công cụ query
  2. Kết nối đến SQL Server
  3. Mở file it-ems-script.sql (đi kèm bộ cài)
  4. Thực thi toàn bộ script → Database ITEquipmentManagement sẽ được tạo

2.2 Tự động qua ứng dụng (thay thế)

  • Ứng dụng hỗ trợ EnsureCreated() → nếu DB chưa tồn tại, sẽ tự tạo bảng khi khởi động lần đầu
  • Tuy nhiên cách này không chạy seed data đầy đủ — khuyến nghị dùng SQL Script

Bước 3: Cấu hình ứng dụng

3.1 Copy chương trình

  1. Tải ứng dụng https://github.com/ahi-tec/IT-Equipment-Management, giải nén và dán vào vị trí cài đặt, ví dụ:
C:\inetpub\ITEquipmentManagement

3.2 Chỉnh Connection String

  1. Mở file appsettings.json
  2. Sửa phần ConnectionStrings:
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=TEN_MAY\\SQLEXPRESS;Database=ITEquipmentManagement;User Id=sa;Password=MAT_KHAU;TrustServerCertificate=True;MultipleActiveResultSets=true"
  }
}
Tham sốGiải thích
ServerTên máy chủ SQL (ví dụ: localhost, .\SQLEXPRESS, 192.168.1.100)
DatabaseTên database (giữ ITEquipmentManagement)
User IdTài khoản SQL Server
PasswordMật khẩu SQL Server

Bước 4: Cấu hình IIS

4.1 Tạo Application Pool

  1. Mở IIS Manager
  2. Chuột phải Application PoolsAdd Application Pool
  3. Tên: ITEquipmentManagement
  4. .NET CLR version: chọn No Managed Code
  5. OK

4.2 Tạo Website

  1. Chuột phải SitesAdd Website
  2. Cấu hình:
    • Site name: ITEquipmentManagement
    • Application pool: ITEquipmentManagement
    • Physical path: C:\inetpub\ITEquipmentManagement
    • Port: 8080 (hoặc port mong muốn)
  3. OK

4.3 Phân quyền thư mục

  1. Chuột phải thư mục C:\inetpub\ITEquipmentManagement → Properties → Security
  2. Thêm quyền Read & Execute cho IIS_IUSRS
  3. Thêm quyền Modify cho IIS AppPool\ITEquipmentManagement (để ghi log)

Bước 5: Kiểm tra

  1. Mở trình duyệt, truy cập: http://localhost:8080
  2. Trang Login hiện ra
  3. Đăng nhập:
    • Username: admin
    • Password: Admin@123
  4. Nếu đăng nhập thành công → cài đặt hoàn tất ✅

Bước 6: Cấu hình Email (tùy chọn)

Sau khi đăng nhập Admin:

  1. Vào menu Email Settings
  2. Cấu hình SMTP:
TrườngVí dụ (Gmail)Ví dụ (Outlook)
SMTP Serversmtp.gmail.comsmtp.office365.com
Port587587
Username[email protected][email protected]
PasswordApp PasswordPassword
Use SSL
From Email[email protected][email protected]
From NameIT Equipment SystemIT Equipment System

Gmail: Cần bật 2FA và tạo App Password tại https://myaccount.google.com/apppasswords

  1. Nhấn Save → nhấn Test Send để kiểm tra

Xử lý sự cố

Lỗi 500.19 - Internal Server Error

  • Chưa cài ASP.NET Core Hosting Bundle → cài và restart IIS

Lỗi 502.5 - Process Failure

  • Kiểm tra Connection String trong appsettings.json
  • Kiểm tra SQL Server đang chạy
  • Xem log tại: C:\inetpub\ITEquipmentManagement\logs\ (nếu có)

Không kết nối được SQL Server

  • Kiểm tra SQL Server Browser service đang chạy
  • Kiểm tra firewall cho phép port 1433
  • Đảm bảo Mixed Mode Authentication đã bật

Quên mật khẩu Admin

  • Chạy SQL:
UPDATE Users SET PasswordHash = '$2a$11$bMIpoHPzJIBP7/qhOt3q8uXOnCswTLNhchZ6oNecVcQ2P.yHaBSq6' WHERE UserId = 'admin';
  • Hoặc xóa user admin trong DB, ứng dụng sẽ tự tạo lại khi khởi động

Cấu trúc thư mục ứng dụng

ITEquipmentManagement/
├── appsettings.json          ← Cấu hình (Connection String)
├── web.config                ← Cấu hình IIS
├── ITEquipmentManagement.dll ← Ứng dụng chính
├── wwwroot/                  ← Tài nguyên tĩnh (CSS, JS, Images)
│   ├── css/
│   ├── js/
│   ├── lib/
│   └── images/
└── ...                       ← Các DLL phụ thuộc