【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标准( ...
随机推荐
- 访问自身子画面的方法 [self.view viewWithTag:100];
UIImageView *view1 = (UIImageView*)[self.view viewWithTag:100];
- [翻译] FreeStreamer 在线流媒体播放
FreeStreamer https://github.com/muhku/FreeStreamer Introduction FreeStreamer is an audio player engi ...
- HTTP参数CONNETCTION_TIMEOUT和SO_TIMEOUT区别
在开发中经常碰到这两个参数,但是之前对它们的真正含义一直比较模糊,今天通过调试程序并且结合官方文档,了解了两者的含义与区别. 参数的定义直接去看官方的文档(httpcore-4.3) org.apac ...
- 数学图形之Boy surface
这是一个姓Boy的人发现的,所以取名为Boy surface.该图形与罗马图形有点相似,都是三分的图形.它甚至可以说是由罗马曲面变化而成的. 本文将展示几种Boy曲面的生成算法和切图,使用自己定义语法 ...
- jquery选择器的实现流程简析及提高性能建议!
当我们洋洋得意的使用jquery强大的选择器功能时有没有在意过jquery的选择性能问题呢,其实要想高效的使用jquery选择器,了解其实现流程是很有必要的,那么这篇文章我就简单的讲讲其实现流程,相信 ...
- 开学了!这些Linux认证你要知道
大家好,今天我们将认识一些非常有价值的全球认可的Linux认证.Linux认证是不同的Linux专业机构在全球范围内进行的认证程序.Linux认证可以让Linux专业人才可以在服务器领域或相关公司等等 ...
- [Node.js] Availability and Zero-downtime Restarts
It might be possible for our node server has some downtime, no matter it is because server update or ...
- PHP的CLI综合
tip1:传入参数 使用标准的输入和输出 PHP CLI会定义三个常量,以便让在命令行提示符下与解释器进行交互操作更加容易.这些常量见表格A.表格A 常量 说明STDIN 标准的输入设备STDO ...
- ArcGIS高程Z值的去除方法
在ArcGIS中,我们常用的几何类型有点.线.面.体(体,在涉及三维的情况下使用),但在这之外,可能会遇到带ZM的类型,如图所示,面ZM,它与面类似,但比面多两个字段. 在编辑中查看草图属性可看到Z值 ...
- ZH奶酪:【阅读笔记】Deep Learning, NLP, and Representations
中文译文:深度学习.自然语言处理和表征方法 http://blog.jobbole.com/77709/ 英文原文:Deep Learning, NLP, and Representations ht ...