Cài đặt iis trên windows server 2022

Theo Microsoft, Web Server (IIS) trong Windows Server 2019 cung cấp một nền tảng bảo mật, dễ quản lý, theo kiểu mô-đun và có thể mở rộng để lưu trữ các trang web, service và ứng dụng một cách đáng tin cậy. Bản phát hành Windows Server 2019 mới của Microsoft đi kèm với phiên bản IIS 10. Hướng dẫn này sẽ cho biết cách cài đặt cài đặt và sử dụng IIS trên Windows Server 2019.

Cài đặt IIS trên Windows Server 2019

1. Chạy Powershell với quyền admin và cài đặt IIS.

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# install IIS with admin tools
PS C:\Users\Administrator> Install-WindowsFeature Web-Server -IncludeManagementTools 

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {Common HTTP Features, Default Document, D...

# verify running to access to default web site
PS C:\Users\Administrator> Invoke-WebRequest http://localhost 

StatusCode        : 200
StatusDescription : OK
Content           : 
                    
                    
                    
Cài đặt iis trên windows server 2022
; outerText=; tagName=A; href=http://go.microsoft.com/fwlink/?linkid=66138&clcid=0x409}} ParsedHtml : System.__ComObject RawContentLength : 703

2. Chạy Server Manager và nhấp vào Add roles and features.

Cài đặt iis trên windows server 2022
Nhấp vào Add roles and features

3. Nhấp vào nút Next.

Cài đặt iis trên windows server 2022
Nhấp vào nút Next

4. Chọn Role-based or feature-based installation.

Cài đặt iis trên windows server 2022
Chọn Role-based or feature-based installation

5. Chọn host bạn muốn thêm các service.

Cài đặt iis trên windows server 2022
Chọn host bạn muốn thêm các service

6. Tích vào hộp Web Server (IIS).

Cài đặt iis trên windows server 2022
Tích vào hộp Web Server (IIS)

7. Các tính năng bổ sung được yêu cầu để thêm IIS Server. Nhấp vào nút Add Features > Next.

Cài đặt iis trên windows server 2022
Thêm các tính năng bổ sung

8. Nhấp vào nút Next.

Cài đặt iis trên windows server 2022
Nhấp vào nút Next

9. Nhấp vào nút Next.

Cài đặt iis trên windows server 2022
Nhấp vào nút Next

10. Đây là phần chọn các tính năng của Web Server. Hãy chọn những tính năng mà bạn muốn thêm. Trong ví dụ này, các tùy chọn mặc định được giữ nguyên. Tất nhiên, bạn có thể thêm các tính năng này sau khi cài đặt IIS.

Cài đặt iis trên windows server 2022
Chọn các tính năng của Web Server

11. Nhấp vào nút Install.

Cài đặt iis trên windows server 2022
Nhấp vào nút Install

12. Sau khi kết thúc cài đặt, nhấp vào nút Close.

Cài đặt iis trên windows server 2022
Nhấp vào nút Close

13. Chạy trình duyệt web và truy cập vào localhost, sau đó bạn có thể xác minh IIS có đang chạy bình thường không.

Cài đặt iis trên windows server 2022
Xác minh IIS có đang chạy bình thường không
  • Cách cài đặt Hyper-V trên Windows Server 2019

Sử dụng IIS trên Windows Server 2019

1. Chạy Powershell với quyền admin và cấu hình như sau:

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

# show Sites list : [Default Web Site] is only set
PS C:\Users\Administrator> Get-Website 

Name             ID   State      Physical Path                  Bindings
----             --   -----      -------------                  --------
Default Web Site 1    Started    %SystemDrive%\inetpub\wwwroot  http *:80:

# [Physical Path] is the Document Root
PS C:\Users\Administrator> Get-ChildItem C:\inetpub\wwwroot 

    Directory: C:\inetpub\wwwroot

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----        8/27/2019   6:57 PM            703 iisstart.htm
-a----        8/27/2019   6:57 PM          99710 iisstart.png

# verify accesses : [iisstart.htm] responds
PS C:\Users\Administrator> Invoke-WebRequest localhost 

StatusCode        : 200
StatusDescription : OK
Content           :  Get-WebConfigurationProperty -Filter "//defaultDocument/files/add" -PSPath "IIS:\Sites\Default Web Site" -Name "value" | select value 

Value
-----
Default.htm
Default.asp
index.htm
index.html
iisstart.htm

# create a test page under the Document Root and verify working
# [Write-Output] generates with UTF-16, so specify encoding explicitly with [Out-File]
PS C:\Users\Administrator> Write-Output "IIS Default Start Page" | Out-File C:\inetpub\wwwroot\Default.htm -Encoding Default 

# verify accesses
# for [curl.exe], specify extension ⇒ if not specify extension, [curl] is an Alias from [Invoke-WebRequest]
PS C:\Users\Administrator> curl.exe localhost 
IIS Default Start Page

2. Chạy Start > Server Manager và nhấp vào Tools > Internet Information Services (IIS) Manager.

Cài đặt iis trên windows server 2022
Nhấp vào Tools > Internet Information Services (IIS) Manager

3. Mở các mục ở bảng điều khiển bên trái, Default Web Site được cấu hình.

Cài đặt iis trên windows server 2022
Default Web Site được cấu hình

4. Chọn Default Web Site và nhấp vào Advanced Settings..., sau đó có thể xác nhận các cài đặt như Physical Path (Document Root), v.v...

Cài đặt iis trên windows server 2022
Chọn Default Web Site và nhấp vào Advanced Settings...

5. Mở Default Document, sau đó có thể xác nhận các tài liệu mặc định.

Cài đặt iis trên windows server 2022
Mở Default Document

6. Bạn có thể xem các tài liệu mặc định.

Cài đặt iis trên windows server 2022
Bạn có thể xem các tài liệu mặc định

7. Tạo trang test trong Physical Path (Document Root) và xác minh quyền truy cập bằng trình duyệt web.

Cài đặt iis trên windows server 2022
Tạo trang test trong Physical Path (Document Root)

Chúc bạn thực hiện thành công!