@gaston
To deploy ASP.NET Core web apps to a Linux server, you can follow these steps:
- Install .NET Core on the Linux server:
Download and install the .NET Core SDK from the official Microsoft website for Linux distributions.
Install any additional dependencies required by your application.
- Publish your ASP.NET Core app:
Open a terminal on your local development machine.
Navigate to the root directory of your ASP.NET Core app.
Run the following command to publish your app:
dotnet publish -c Release
This command will create a publish folder with the compiled binaries and all necessary files.
- Copy the published files to the Linux server:
Transfer the published files from your local machine to the Linux server, either by using SCP or any other preferred method.
- Set up a web server:
To host your ASP.NET Core app, you need a web server like Nginx or Apache. Install and configure an appropriate web server on your Linux server.
Here's an example using Nginx:
Install Nginx by running the appropriate command for your distribution (e.g., sudo apt-get install nginx for Ubuntu).
Edit the Nginx configuration file (sudo nano /etc/nginx/sites-available/default) and configure the server to proxy requests to your ASP.NET Core app.
An example configuration might look like this:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:5000; # the port where your app is running
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
- Start your ASP.NET Core app:
On the Linux server, navigate to the directory where you copied the published files.
Run the following command to start your app:
dotnet
- Test your web app:
Open a web browser and enter the server's IP address or domain name to access your ASP.NET Core web app.
That's it! Your ASP.NET Core web app should now be deployed and running on the Linux server.