【asp.net Core 2.0 初步探索】
首先下载 对应的SDK 和runtime
https://www.microsoft.com/net/core#linuxubuntu ---------当前为 1.1 稳定版本
2.0 预览版本下载地址:
https://www.microsoft.com/net/core/preview#linuxubuntu
---安装vs 2017的用户 除外
然后 下载 vscode
然后下载 yeoman 这个模板生成工具 进行项目的架子生成
https://docs.microsoft.com/en-us/aspnet/core/client-side/yeoman
安装node.js
C:\nodejs\
在 powershell 中执行下面的命令 安装 bower ,一个js css 脚本管理工具 Bower — a package manager for the web
npm install -g yo bower
然后安装 asp.net core 模板
npm install -g generator-aspnet
The –g flag installs the generator globally, so that it can be used from any path.
--------------使用yoman 的模板生成 或者使用自带的模板生成项目---------
yo 生成: yo aspnet 比较的全面 但是比较旧 跟不上版本变化
或者自带命令:
dotnet new mvc --推荐使用,毕竟自家的东西,版本能及时跟随 sdk -runtime 版本
Creates a new project, configuration file, or solution based on the specified template.
dotnet new <TEMPLATE> [-lang|--language] [-n|--name] [-o|--output] [-all|--show-all] [-h|--help] [Template options]
dotnet new <TEMPLATE> [-l|--list]
dotnet new [-all|--show-all]
dotnet new [-h|--help]
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new
---------将程序 部署在 Linux Ubuntu 上----------------------
dotnet build 编译
dotnet run 运行调试
dotnet publish 发布
查看进程:
1,ps -e 命令
用 kill -9 pid 命令,来绝杀
kill $(ps aux | grep 'MySite.dll' | awk '{print $2}') --指定的站点
kill $(ps aux | grep 'dotnet' | awk '{print $2}')--全部asp.net core
最好的方式是使用进程守护工具
supervisor
sudo apt-get install supervisor
I have decided to use supervisor to monitor and manage the process. Here is an excellent article on getting it set up.
It allows simple control over specific dotnet apps like this:
-----------重启站点----------
supervisorctl stop MyWebsiteName
supervisorctl start MyWebsiteName
-----------为进程守护 写配置文件----------
/etc/supervisor/conf.d/bookManage.conf
[program:bookManage]
command=/usr/bin/dotnet /home/chen/webroot/BookManage1.1/bin/Debug/netcoreapp2.0/publish/BookManage.dll
directory=/home/chen/webroot/BookManage1.1/bin/Debug/netcoreapp2.0/publish/
autostart=true
autorestart=true
stderr_logfile=/var/log/BookManage.err.log
stdout_logfile=/var/log/BookManage.out.log
environment=HOME=/var/www/,ASPNETCORE_ENVIRONMENT=Production
user=www-data
stopsignal=INT
stopasgroup=true
killasgroup=true
-----------------------关于进程守护 Supervisor的介绍-----------
重启进程守护 加载新建的配置
sudo service supervisor stop
sudo service supervisor start
Viewing logs
Supervisord logs messages about its own health and its subprocess' state changes to the activity log. The path to the activity log is configured via the logfile parameter in the configuration file.
sudo tail -f /var/log/supervisor/supervisord.log
You can redirect application logs (STDOUT and STERR) in the program section of your configuration file.
tail -f /var/log/hellomvc.out.log
https://serversforhackers.com/monitoring-processes-with-supervisord
------使用nginx 反向 实现 web 服务器上 端口映射------------
sudo apt-get install nginx
sudo service nginx start
server {
listen 80;
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;
}
}
-----------上面是基本的nginx 配置,实际应用中nginx 有很多可以配置的地方--------------
参考文献:
https://www.hanselman.com/blog/PublishingAnASPNETCoreWebsiteToACheapLinuxVMHost.aspx
https://github.com/aspnet/Docs/blob/e9c1419175c4dd7e152df3746ba1df5935aaafd5/aspnetcore/publishing/linuxproduction.md
使用Visual Studio Code创建第一个ASP.NET Core应用程序
http://www.cnblogs.com/mengnan/p/5574593.html
https://docs.microsoft.com/en-us/aspnet/core/client-side/yeoman
【asp.net Core 2.0 初步探索】的更多相关文章
- 探索ASP.NET Core 3.0系列一:新的项目文件、Program.cs和generic host
前言:在这篇文章中我们来看看ASP.Net Core 3.0应用程序中一些基本的部分—— .csproj项目文件和Program.cs文件.我将会介绍它们从 ASP.NET Core 2.x 中的默认 ...
- [转]探索ASP.NET Core 3.0 系列
这是该系列的第一篇文章:探索ASP.NET Core 3.0. 第1部分-探索新的项目文件Program.cs和通用主机(本文) 第2部分-比较ASP.NET Core 3.0模板之间的Startup ...
- 探索 ASP.Net Core 3.0系列五:引入IHostLifetime并弄清Generic Host启动交互
前言:在本文中,我将介绍如何在通用主机之上重新构建ASP.NET Core 3.0,以及由此带来的一些好处. 同时也展示了3.0中引入新的抽象类IHostLifetime,并描述了它在管理应用程序(尤 ...
- 探索ASP.Net Core 3.0系列四:在ASP.NET Core 3.0的应用中启动时运行异步任务
前言:在本文中,我将介绍ASP.NET Core 3.0 WebHost的微小更改如何使使用IHostedService在应用程序启动时更轻松地运行异步任务. 翻译 :Andrew Lock ht ...
- 探索 ASP.Net Core 3.0系列三:ASP.Net Core 3.0中的Service provider validation
前言:在本文中,我将描述ASP.NET Core 3.0中新的“validate on build”功能. 这可以用来检测您的DI service provider是否配置错误. 具体而言,该功能可检 ...
- 探索ASP.Net Core 3.0系列六:ASP.NET Core 3.0新特性启动信息中的结构化日志
前言:在本文中,我将聊聊在ASP.NET Core 3.0中细小的变化——启动时记录消息的方式进行小的更改. 现在,ASP.NET Core不再将消息直接记录到控制台,而是正确使用了logging 基 ...
- 探索ASP.Net Core 3.0系列二:聊聊ASP.Net Core 3.0 中的Startup.cs
原文:探索ASP.Net Core 3.0系列二:聊聊ASP.Net Core 3.0 中的Startup.cs 前言:.NET Core 3.0 SDK包含比以前版本更多的现成模板. 在本文中,我将 ...
- ASP.NET Core 2.0 : 三. 项目结构
本章我们一起来对比着ASP.NET Framework版本看一下ASP.NET Core 2.0的项目结构.(此后的文章也尽量这样对比着, 方便学习理解.) 关注差异, 也为项目迁移做准备. 新建项目 ...
- Asp.Net Core Web应用程序—探索
前言 作为一个Windows系统下的开发者,我对于Core的使用机会几乎为0,但是考虑到微软的战略规划,我觉得,Core还是有先了解起来的必要. 因为,目前微软已经搞出了两个框架了,一个是Net标准( ...
随机推荐
- MVC日期格式化,后台使用Newtonsoft.Json序列化日期,前端使用”f”格式化日期
MVC控制器中,经常使用Newtonsoft.Json把对象序列化成json字符串传递到前端视图.当对象中有DateTime类型的属性时,前后台如何处理才能把DateTime类型转换成想要的格式呢? ...
- Oracle 10g AND Oracle 11g手工建库案例--Oracle 10g
Oracle 10g AND Oracle 11g手工建库案例--Oracle 10g 系统环境: 操作系统: RedHat EL6 Oracle: Oracle 10g and Oracle 11 ...
- C柔性数组
柔性数组成员 柔性数组 .允许结构中包含一个大小可变的数组,sizeof返回的这种结构大小不包括柔性数组的内存. .包含柔性数组成员的结构要使用malloc()函数进行内存的动态分配.分配的内存大于结 ...
- 读书笔记之:C语言深度剖析
读书笔记之:C语言深度剖析 <C 语言深度解剖>这本书是一本“解开程序员面试笔试的秘密”的好书.作者陈正冲老师提出“以含金量勇敢挑战国内外同类书籍”,确实,这本书中的知识点都是一些在面试中 ...
- sqlalchemy简单示例
1.初始化数据库database.py #!/usr/bin/env python # -*- coding: utf-8 -*- # Created by miaoshuijian on 2017/ ...
- C++ 全排列函数 std::next_permutation与std::prev_permutation
C++ STL中提供了std::next_permutation与std::prev_permutation可以获取数字或者是字符的全排列,其中std::next_permutation提供升序.st ...
- [转]VS2010快捷键
VS2010的快捷键,后附VS2008的快捷键 Ctrl+E,D ----格式化全部代码 Ctrl+E,F ----格式化选中的代码 CTRL + SHIFT + B生成解决方案 CTRL + F7 ...
- Android中XML解析-PULL解析
前面写了两篇XML解析的Dom和SAX方式,Dom比较符合思维方式,SAX事件驱动注重效率,除了这两种方式以外也可以使用Android内置的Pull解析器解析XML文件. Pull解析器的运行方式与 ...
- MVC 与 MVP 架构 MD
Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...
- C#匿名方法与Delegate类型转换错误
问题描述 C#2.0出现了匿名方法, 这在一定程度上节省了我们维护代码上下文的精力, 也不需要思考为某个方法取什么名字比较合适. 在FCL的一些方法中要求传入一个Delegate类型的参数, 比如Co ...