Deploy ASP.NET website
Website configuration
Suppose you have an ASP.NET website that you want to run under the domain domain.com
Go to application store, install the
ASP.NET
applicationCreate a website with the following configuration
- Enter domain
- Select Proxy Port
- Enter the port your ASP.NET application runs on, for example 3000
Install the source code for the website from git or upload it yourself
Update Database & Build & Publish
Open the terminal for the website
bashdotnet ef database update dotnet build dotnet publish
Create Service for website
Use the Service management feature to create a service
Create a service named
domain_com
(you can put domain_com or whatever you want, but note that it is short, easy to remember, no special characters)You can refer to the content of
domain_com
belowini[Unit] Description=ASP.NET - domain.com [Service] WorkingDirectory=/home/flashvps/domain.com ExecStart=/usr/bin/dotnet /home/flashvps/domain.com/bin/Debug/netcoreapp8.0/publish/domain_com.dll --urls "http://127.0.0.1:3000" // [!code focus ] Restart=always RestartSec=10 KillSignal=SIGINT SyslogIdentifier=domain_com User=flashvps Environment=ASPNETCORE_ENVIRONMENT=Production Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false [Install] WantedBy=multi-user.target
WARNING
- Change
3000
to the proxy port you declared when creating the website before - Please change
domain.com
to the domain name corresponding to your website flashvps
is the user that the website is running on, please replaceflashvps
with the user that the website is running on (be careful not to set it asroot
)bin/Debug/netcoreapp8.0/publish/domain_com.dll
is the path to the dll file thatdotnet publish
creates- Linux has a case-sensitive file system. Setting
ASPNETCORE_ENVIRONMENT
toProduction
will result in searching for the configuration fileappsettings.Production.json
, notappssettings.production.json
. - The colon separator (😃 is not supported in environment variable names. Use double underscores (__) instead of colons. The system will convert double underscores to colons when environment variables are read into the configuration. In the following example, the connection string key
ConnectionStrings:DefaultConnection
is placed in the service definition file asConnectionStrings__DefaultConnection
iniEnvironment=ConnectionStrings__DefaultConnection={Connection String}
- Change
Visit the website to see the successful results!