.NET is Microsoft’s open-source, cross-platform application framework that runs on Linux, macOS, and Windows. .NET 8 (the current LTS release) includes the ASP.NET Core web framework for building REST APIs and web applications, Entity Framework Core ORM, and a high-performance Kestrel HTTP server. .NET applications are compiled to platform-independent intermediate language (IL) bytecode and run on the .NET runtime (CoreCLR), similar to Java’s JVM model. The .NET SDK includes the compiler, runtime, and dotnet CLI tool for creating, building, testing, and publishing applications. This guide covers installing the .NET 8 SDK and runtime on RHEL 9, building an ASP.NET Core API, and deploying it as a systemd service behind Nginx.
Prerequisites
- RHEL 9 with sudo/root access
Step 1 — Install .NET 8 SDK
# .NET is available from the RHEL AppStream repository
dnf install -y dotnet-sdk-8.0
# Verify
dotnet --version
dotnet --list-sdks
dotnet --list-runtimes
Step 2 — Install Only the Runtime (Production Servers)
# Production servers need only the ASP.NET Core Runtime (not the full SDK)
dnf install -y aspnetcore-runtime-8.0
# Verify runtime
dotnet --list-runtimes
Step 3 — Create and Run an ASP.NET Core API
mkdir /var/www/myapi && cd /var/www/myapi
# Create a new Web API project
dotnet new webapi --name MyApi --output .
dotnet run
# Test the default weather forecast endpoint
curl http://localhost:5000/weatherforecast
Step 4 — Publish for Production
# Publish self-contained deployment (no .NET runtime required on server)
dotnet publish -c Release -r linux-x64 --self-contained true -o /var/www/myapi-publish
# Or framework-dependent (requires .NET runtime on server — smaller output)
dotnet publish -c Release -o /var/www/myapi-publish
ls -lh /var/www/myapi-publish/
Step 5 — Configure appsettings for Production
# appsettings.Production.json
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://unix:/run/myapi.sock"
}
}
},
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=myapi_db;Username=myapi_user;Password=MyApiPass123!"
}
}
Step 6 — Deploy as systemd Service with Nginx
# /etc/systemd/system/myapi.service
[Unit]
Description=ASP.NET Core API
After=network.target
[Service]
User=dotnetapp
Group=dotnetapp
WorkingDirectory=/var/www/myapi-publish
ExecStart=/var/www/myapi-publish/MyApi
Restart=always
Environment=ASPNETCORE_ENVIRONMENT=Production
[Install]
WantedBy=multi-user.target
# /etc/nginx/conf.d/myapi.conf
server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://unix:/run/myapi.sock;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Conclusion
.NET 8 on RHEL 9 is fully supported through the Red Hat AppStream repository, making it a first-class citizen on RHEL systems with enterprise support from both Microsoft and Red Hat. The Kestrel HTTP server embedded in ASP.NET Core is production-ready and high-performance, but running it behind Nginx is still recommended for SSL termination, request buffering, and serving static files. Self-contained deployments (--self-contained true) eliminate the runtime dependency on the production server, making deployment and version management simpler at the cost of a larger deployment package.
Next steps: How to Install Docker on RHEL 9, How to Install Nginx on RHEL 9, and How to Configure HTTPS with Let’s Encrypt on RHEL 9.