Docs / Programming & Development / Setting Up a .NET Core Application on Linux

Setting Up a .NET Core Application on Linux

By Admin · Jan 23, 2026 · Updated Apr 23, 2026 · 4 views · 3 min read

Managing dotnet effectively is a crucial skill for any system administrator. This tutorial provides step-by-step instructions for core configuration, along with best practices for production environments.

Environment Setup

When scaling this setup, consider vertical scaling (adding more RAM/CPU) first, as it's simpler to implement. Horizontal scaling adds complexity but may be necessary for high-traffic applications.


# Set up the development environment
sudo apt update
sudo apt install -y build-essential curl git

# Install the runtime
curl -fsSL https://get.dotnet.org | bash
dotnet --version

The configuration above sets the recommended values for a VPS with 2-4GB of RAM. Adjust the memory-related settings proportionally if your server has different specifications.

  • Document all configuration changes
  • Use version control for configuration files
  • Test disaster recovery procedures regularly
  • Maintain runbooks for common operations

Project Configuration

If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.


# Create a systemd service for the application
sudo tee /etc/systemd/system/myapp.service << 'EOF'
[Unit]
Description=My Application
After=network.target

[Service]
User=deploy
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/dotnet /opt/myapp/server.js
Restart=always
Environment=NODE_ENV=production
Environment=PORT=3000

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp

Each line in the configuration serves a specific purpose. The comments explain the reasoning behind each setting, making it easier to customize for your specific use case.

Deployment Process

If you encounter issues during setup, check the system logs first. Most problems can be diagnosed by examining the output of journalctl or the application-specific log files in /var/log/.


# Set up the development environment
sudo apt update
sudo apt install -y build-essential curl git

# Install the runtime
curl -fsSL https://get.dotnet.org | bash
dotnet --version

These commands should be run as root or with sudo privileges. If you're using a non-root user, prefix each command with sudo.

Process Management

The default configuration works well for development environments, but production servers require additional tuning. Pay particular attention to connection limits, timeout values, and logging settings.


# Create a systemd service for the application
sudo tee /etc/systemd/system/myapp.service << 'EOF'
[Unit]
Description=My Application
After=network.target

[Service]
User=deploy
WorkingDirectory=/opt/myapp
ExecStart=/usr/bin/dotnet /opt/myapp/server.js
Restart=always
Environment=NODE_ENV=production
Environment=PORT=3000

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable myapp
sudo systemctl start myapp

The output should show the service running without errors. If you see any warning messages, address them before proceeding to the next step.

  • Document all configuration changes
  • Set up monitoring before going to production
  • Test disaster recovery procedures regularly
  • Maintain runbooks for common operations

Summary

You've successfully configured dotnet on your VPS. Remember to monitor performance, keep your software updated, and maintain regular backups. If you run into issues, consult the official documentation or open a support ticket for assistance.

Was this article helpful?