Requirements
- CyberPanel (Installing CyberPanel)
- SSH credentials & SSH client (PuTTY)
- FTP credentials
- Working SSL on website
- ASP.NET IDE (Visual Studio Community)
Installing ASP.NET Runtime
Connect to your Linux server using SSH client. Use your Linux package manager to install ASP.NET Runtime. More can be read from here.
I’m following CentOS 7 instructions from the documentation link above.
Step 1
Before you install .NET, run the following commands to add the Microsoft package signing key to your list of trusted keys and add the Microsoft package repository. Open a terminal and run the following commands:
sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.26.28-1024x171-1.png)
Step 2
The ASP.NET Core Runtime allows you to run apps that were made with .NET that didn’t provide the runtime. The following command installs the ASP.NET Core Runtime, which is the most compatible runtime for .NET. In your terminal, run the following command:
sudo yum install aspnetcore-runtime-6.0
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.14.58.png)
Answer ‘y’ when needed to.
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.28.20-1024x768-1.png)
Success!
Configure & Publish ASP.NET
Configure your ASP.NET project. I used this documentation from Microsoft.
Step 1
Configure a reverse proxy server
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.43.43-1-1024x531-1.png)
Step 2
Publish using FTP to your Linux server.
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.45.45.png)
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.46.24-1024x718-1.png)
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.48.52-1024x718-1.png)
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.52.18-1024x669-1.png)
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-01.53.08-1024x257-1.png)
Success!
Create ASP.NET service
Step 1
Install Nano text editor.
sudo yum install nano
Create a service file using nano.
sudo nano /etc/systemd/system/example.service
Modify & Save the following content.
[Unit]
Description=Example .NET Web App running on CyberPanel
[Service]
WorkingDirectory=/home/example.com/public_html
ExecStart=/usr/bin/dotnet /home/example.com/public_html/Example.dll
Restart=always
# Restart service after 10 seconds if the dotnet service crashes:
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=dotnet-example
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy=multi-user.target
CTRL+O, Enter. to save the file in Nano. CTRL+X to exit Nano.
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.06.20-1024x768-1.png)
Step 2
Start the service
sudo systemctl enable example.service
sudo systemctl daemon-reload
sudo systemctl start example.service
Check if the service is running
sudo systemctl status example.service
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.12.05-1024x422-1.png)
Success!
Configure OpenLiteSpeed
Access OpenLiteSpeed WebAdmin Console using the port 7080 on your preferred web browser.
![](https://viov.nl/wp-content/uploads/2024/01/image-8-1024x513.png)
If you don’t know your OpenLiteSpeed WebAdmin Console credentials you can reset them running the following command.
/usr/local/lsws/admin/misc/admpass.sh
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.19.17.png)
Step 1
Add new external app.
![](https://viov.nl/wp-content/uploads/2024/01/image-10-1024x511.png)
Choose Type Web Server (1) & Click next (2).
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.25.37-1024x361-1.png)
Fill in the details and save your external app.
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.27.47-1024x549-1.png)
Perform graceful restart
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.30.13-1024x473-1.png)
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.30.56-1024x430-1.png)
Step 2
Add new Virtual Host
Open your websites Virtual Hosts configuration.
![](https://viov.nl/wp-content/uploads/2024/01/image-12-1024x515.png)
Click Context tab and press New button.
![](https://viov.nl/wp-content/uploads/2024/01/image-13-1024x513.png)
Choose Proxy as Type and click Next
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.34.50-1024x366-1.png)
- Enter URI as a slash (root): /
- Choose the Web Server we just created.
- Click Save button.
![](https://viov.nl/wp-content/uploads/2024/01/2022-09-13-02.37.18-1024x566-1.png)
Perform graceful restart again.
Success!
![](https://blog.viov.nl/wp-content/uploads/2022/09/2022-09-13-02.42.10-1024x512.png)
Republishing
After republishing your ASP.NET project you should run the following command for changes to take effect.
sudo systemctl restart example.service