based on the first or second attempt to deploy.Net Core to Linux server, I try to summarize my experience after a simple Demo, trying to deploy on Linux server and cross server access database.


1, the local environment using Visual Studio 2017 development, the use of the.NetCore SDK version of 2.1.4

; 2, the use of the database MSSQLServer, deployed in the cloud server, WindowServer;

3, Demo Tencent deployed in the cloud server, CentOS system;

4, CentOS the installation of.Net CoreSDK 2.1.4 (the development and deployment of the best environment here, I had


5, code management is done by Git, the Git is installed locally in CentOS also installed Git;

6, using jexus reverse proxy; introduce

to build a Asp.Net Core project

two project, this process will not be established, mapping, simple steps.

here is not to use Docker, set up a project, do not check the Docker support



, an entity can only add a a User class, which is the basic user name and password, address and date.

 public class User public (User) {{this.CreateDate = DateTime.Now;} public int Id {get set; public string;} UserName {get set; public string;} Password {get; set;} public string Address {get set; public DateTime;} CreateDate {get}}; set; 

2 next, DbContext

 public class HDShopDbContext:DbContext is a HDShopDbContext {public (DbContextOptions< HDShopDbContext> options): base (options override void) {protected} OnModelCreating (ModelBuilder modelBuilder) {//modelBuilder.Entity< User> (.ToTable) ("XXXX");} public virtual DbSet< User> User; get set;} {



configuration service in the project has been the default EFCor E Nuget joined

packet service configuration in the StartUp.cs file, use the

 public class Startup Startup (IConfiguration configuration) {public} public {Configuration = configuration; 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.AddDbContext< (D; HDShopDbContext> => d.UseSqlServer (Configuration.GetConnectionString ("Default"))); (services.AddMvc);} / / This metho D gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure (IApplicationBuilder app, IHostingEnvironment Env) {if ((env.IsDevelopment)) {app.UseBrowserLink (app.UseDeveloperExceptionPage); (else);} {app.UseExceptionHandler ("/Home/Error");} (app.UseStaticFiles); app.UseMvc (routes => routes.MapRoute ({name: "default" template: "{controller=Home}/{action=Index}/{id?}");}}}); 

to explain the distinction Configure and ConfigureService:

Configure configuration is the middleware, the entire service process, is a jump in the form of middleware, from the first to the second middleware middleware, the most complete one a Middleware is required to go back to the last middleware, and the number of middleware can be controlled. If there are any functions that need to be added, we can also run in the form of middleware. Configure method controls middleware instantly.

ConfigureService is configured with various frameworks used throughout the run, injection, and so on, and is called before the Configure method.

specifically to see the "nofollow" @ "text-align: style=

action center" >

in the appsetting.json to configure the connection string, because the Linux can not be installed in the SQLServer version other than 2017 I will be another WindowServer server database. Come, SQLServer2017 is very high for the Linux server configuration requirements, I and other small civilians vulnerable, haha.

remembers the connection string name not wrong!!!

4, EFCore CodeFirst for the convenience in our deployment, the database is created automatically after the start, we prepare

 public class DbInitializer seed data {public static void Initialize (HDShopDbContext context) {context.Database.EnsureCreated ((if); (context.User.Any)) {return}; VAR users = new User[] new User ({Address=) {UserName = "test", "1 1", "123456 Password=" new User ({Address=)}, "test", UserName = "2 2", "123456 Password="}. New User ({Address=) "test", UserName = "3 3", "123456 Password=" new User ({Address=)}, " Try "UserName = 4" 4 "test, Password=" 123456 "new User ({Address=)}," test ", UserName =" 5 "5 test, Password=" 123456 "new User ({Address=)}," test ", UserName =" 6 "6 test, Password=" 123456 "}}, foreach (VaR user in; users) {context.Add} (user); context.SaveChanges (


);}} compiler operation, test the success of local operation. I won't show the results of my test.

6, enter the Linux server, download the Git, and make a record on the GitHub or the code cloud by configuring the SSH public key. (I still used code cloud, after all, many Chinese characters haha) "nofollow"

Linux server Gti configuration tutorial

7, Linux jexus server installation, installation of

 with the following command curl|sh

successfully installed Jexus has will prompt: OK, been installed in /usr/jexus.

so far as a reverse proxy, jexus installed, you need to install jexus+mono before, now the latest version of jexus mono has been merged into it, forming the jexus version of.

8 installed.Net, independent Core

my advice is to view the development environment of the.Net Core version of SDK, or if there are different versions of the server the environment and development environment, then there will be some pit, as I met A

#800000 >Error:
An assembly specified in the application dependencies manifest ({projectName}.deps.json) was not found:
package:'Microsoft.AspNetCore.Antiforgery', version:'2.0.2'
This was expected to assembly be in the local runtime store as the application was published using the following target manifest files:

when I install the SDK server option is the 2.1.3 version, and my development environment is the 2.1.4 version, the wrong lane for a while, did not do a good job of this, as it is for this reason that makes me from Git pull down the project, although the release of success But the deployment can not be accessed normally, while testing through dotnet /xxx/xxx/xx.dll will always be a mistake.

finally got the latest version by drying out the existing version. Also, I have a problem here. It seems that I don't have to update the SDK version of the instruction? I didn't find it. I'm sorry. If you do, please contact me. Thank you.

has been successfully running through a command to dry out the old version of the CLI and download a new version of the SDK.

 RM -rf /usr/share/dotnet cli

to delete the old version below is my.Net installation Core instruction

1, dotnet Feed

 sudo RPM product configuration --import sudo sh -c'echo -e packages-microsoft-com-prod] name=packages-microsoft-com-prod baseurl= enabled=1 [gpgcheck=1 gpgkey= > /etc/yum.repos.d/dotnetdev.repo'

2, SDK; installation, note version!!!

 sudo Yum update sudo Yum -y install libunwind libicu sudo. 


deployment process through Git code or Github cloud project Pull down, now the best server specified Git path

as I establish a dedicated project folder, which for every Clone to the local project to create a folder, can make me thinking clear. Maybe, you have a better way, and you can use it.

 is run through the establishment of GIT clone SSH 

address of your project, we can use other dotnet instructions for the operation of

what specific instruction can be obtained by

to check the contents of the folder "alt=

dotnet run can use the instructions will project to start


here will be found by dotnet --help, we can't do what thing, only

Ctrl + C for services to stop, we will be able to present this program A program is running, the specific operation is Ctrl +Z

service is suspended and then through the BG instruction set the background process, if you want to enter the background process through the instruction fg

if we are only in the command line operation, and can not see the page, but not by


to external access. To ensure that the site is really running successfully, we can use the instructions to view the website homepage information

 curl localhost:65758


will return to the site

Linux HTTP more specific instructions please refer to Linux curl

we can command issued by the dotnet, build will again project instruction compile

and publish a project to specify the folder

dotnet publish -o followed by /xxxx/xxxx, can To configure jexus.

This concludes the body part