在ubuntu Server上的启动时身份崩溃20.04lts

问题描述 投票:0回答:1

sudo systemctl stop myapp.service ● myapp .service - myapp app Loaded: loaded (/etc/systemd/system/myapp .service; enabled; vendor preset: enabled) Active: activating (auto-restart) (Result: exit-code) since Mon 2021-01-11 11:54:21 UTC; 4s ago Process: 17943 ExecStart=/usr/bin/dotnet /var/www/myapp .be/net5.0/myapp .be.dll (code=exited, status=1/FAILURE) Main PID: 17943 (code=exited, status=1/FAILURE)

我怀疑身份经理崩溃。虽然在我的Visual Studio Windows Dev环境上托管时效果很好 最令人讨厌的是,它没有崩溃,甚至没有启动没有出现错误。

Mystartup.csfile.

using mysite.com.Data; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpsPolicy; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.AspNetCore.Authentication; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication.OAuth; namespace mysite.com { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; } public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddAuthentication() .AddGoogle(options => { //clean this latter know how to implement user secrets.json options.ClientId = "xxxxxx.apps.googleusercontent.com"; options.ClientSecret = "xxxxxx"; }) .AddFacebook(facebookOptions => { facebookOptions.AppId = Configuration["Authentication:Facebook:AppId"]; facebookOptions.AppSecret = Configuration["Authentication:Facebook:AppSecret"]; }) ; string mySqlConnectionStr = Configuration.GetConnectionString("DefaultConnection"); services.AddDbContextPool<ApplicationDbContext>(options => options.UseMySql(mySqlConnectionStr, ServerVersion.AutoDetect(mySqlConnectionStr))); services.AddControllers(); services.AddDatabaseDeveloperPageExceptionFilter(); services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores<ApplicationDbContext>(); services.AddControllersWithViews(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseForwardedHeaders(new ForwardedHeadersOptions { ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto }); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseMigrationsEndPoint(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapRazorPages(); }); } } }

您可以在终端中的下面的命令下运行您的项目 dotnet run

如果您的项目已发布,则可以在终端中使用以下命令
dotnet YourProject.dll
asp.net-core ubuntu entity-framework-core asp.net-core-identity asp.net-core-5.0
1个回答
2
投票
我认为您可以在Linux Server中使用nginx反向代理。

server { listen 80; server_name example.com *.example.com; location / { proxy_pass http://localhost:5000; 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; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }

有关
Host ASP.NET Core on Linux with Nginx

的更多信息:

https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view = aspnetcore-5.0#ponfigure-nginx

    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.