检察linux内核版本
uname -a
打印功效
[email protected]:~$ uname -a Linux ubuntu 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
检察ubuntu系统版本
lsb_release -a
打印功效
[email protected]:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 16.04.1 LTS Release: 16.04 Codename: xenial [email protected]:~$
可以看到版本号是 16.4
检察官方文档执行 dotnet 环境安置过程
https://www.microsoft.com/net/learn/get-started/linuxredhat
这里我们选择 Ubuntu
继续执行下面的命令
Register the trusted Microsoft signature key:curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
继续
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
按照系统版本,执行下面的命令
sudo sh -c ‘echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list‘
好了,环境部署完毕,下面我们安置 SDK
分袂执行下面三行命令
sudo apt-get install apt-transport-https sudo apt-get update sudo apt-get install dotnet-sdk-2.1.4
至此,,SDK安置完毕
---------------------------------------------------------------------------------------------------------------------
下面我们新建一个控制台项目测试一下
dotnet new console -o myApp cd myApp dotnet run
遇到了一个目录权限问题
Template "Console Application" could not be created.
Access to the path ‘/etc/apt/trusted.gpg.d/myApp‘ is denied.
使用权限命令,添加目录的权限
然而这里,我们改削一下创建位置,改成当前的 home 目录创建即可
运行功效如下
[email protected]:~/dotnet$ dir myApp [email protected]:~/dotnet$ cd myApp/ [email protected]:~/dotnet/myApp$ dir myApp.csproj obj Program.cs [email protected]:~/dotnet/myApp$ dotnet run Hello World! [email protected]:~/dotnet/myApp$
编译运行告成了。
下面我们用在 windows 下编译好的 mvcapi 项目在 linux 上运行一下尝尝。
首先我们把整个项目解决方案目录传到 linux 处事器上
这里我用的是 xftp
然后要运行哪个项目,就直接切换到项目的目录,例如我要运行 mywebapi 这个api接口
[email protected]:~/dotnet/myweb$ cd mywebapi [email protected]:~/dotnet/myweb/mywebapi$ ls appsettings.Development.json bin mywebapi.csproj obj Properties wwwroot appsettings.json Controllers mywebapi.csproj.user Program.cs Startup.cs [email protected]:~/dotnet/myweb/mywebapi$ dotnet run Models/GEDU_LSA_V_1_7_1Context.cs(38,10): warning CS1030: #warning: ‘To protect potentially sensitive information in your connection string, you should move it out of source code. See http://go.microsoft.com/fwlink/?LinkId=723263 for guidance on storing connection strings.‘ [/home/python/dotnet/myweb/core/mydb.csproj] Controllers/MyController.cs(24,13): warning CS0162: Unreachable code detected [/home/python/dotnet/myweb/mywebapi/mywebapi.csproj] Using launch settings from /home/python/dotnet/myweb/mywebapi/Properties/launchSettings.json... Hosting environment: Development Content root path: /home/python/dotnet/myweb/mywebapi Now listening on: http://localhost:61697 Application started. Press Ctrl+C to shut down. ^CApplication is shutting down...
这个时候我们访谒以下 api 接口地点
告成看到接口返回的json
mvc项目也是这样操纵,即可。