Start by creating a folder on your Linux server, for example named myweb. Remember to set proper folder permissions; 0755 is the standard default permission setting. 0755 translates to rwxr-xr-x:
Other users: Read and execute only (r-x)
Owner (your user account): Read, write and execute full access (rwx)
Group members: Read and execute only (r-x)
Next, publish your project inside Visual Studio. Switch to Release build configuration and compile the project first, then right-click your project and select Publish. Once publishing finishes, copy all generated files from the publish folder over to the myweb directory you just made using an FTP client.
cd /usr/myweb
After moving files across, run the command below to launch your app as a background process. Running in the background means your program stays active even after you close your remote Linux SSH window.
sudo nohup dotnet yourprogramname.dll &
The trailing & at the end of the command is critical for background execution. Leave it out, and the app runs in the foreground; closing your terminal or pressing Ctrl + C will shut down the program immediately.
For reference, here’s my live example: sudo nohup dotnet WebSite.dll &
Important Extra Note
Set your port settings before publishing. Open the appsettings.json file in your .NET MVC project.
Add the configuration shown below as your template:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://0.0.0.0:8080"
}
}
}
}
This setup accepts connections from any IP address on port 8080, letting you use Nginx for reverse proxy routing and host multiple separate domains on one Linux server.
You’ll need to open this port in your firewall unless you’re using Nginx as a reverse proxy. For proxy-only setups, bind the service to localhost only like this:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://127.0.0.1:8080"
}
}
}
}
With this config, the app only accepts local requests and blocks all outside direct connections.
My end goal is to access this application by visiting abc.com/hello.
Run sudo nohup dotnet WebSite.dll & afterwards to start up the application.
Check if your application runs properly with this command: ps -aux | grep WebSite.dll
A matching process entry confirms your service launched successfully.
Set Up Nginx Reverse Proxy (skip this section if you don’t need proxy features)
If you already have Nginx installed, its main config file sits under /etc/nginx/nginx.conf
Edit the site configuration at /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/web/xxxx;
index index.html index.htm index.nginx-debian.html;
server_name _;
# 主站
location / {
try_files $uri $uri/ =404;
}
# ✅ 关键:/hello 转发到 .NET
location /hello {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
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;
}
}
Restart Nginx after saving changes
sudo nginx -t
sudo systemctl restart nginx
Now restart your .NET MVC app
First find the existing process with ps -aux | grep WebSite.dll, then grab the PID number at the very start of the matching sudo process line
Kill that PID number to shut down the running .NET MVC instance.
Start the service again using this line: sudo nohup dotnet 你的项目.dll –urls http://127.0.0.1:8080 > /dev/null 2>&1 &
Time to test everything
Restart Nginx
Run this command:
bash
Execute:
sudo systemctl restart nginx
.NET listens on port 8080
Use the below command to verify your .NET service is active:
bash
Execute:
curl http://127.0.0.1:8080
You’ll know it works if raw HTML content gets printed out in your terminal.
