Centos7系统下搭建.NET Core2.0+Nginx+Supervisor环境

2019-01-16 21:12:29丽君

yum update yum install libunwind libicu -y yum install dotnet-sdk-2.0.0 -y

3.检查dotnet是否安装成功与版本查看

dotnet --info dotnet --version

四、测试.NET Core2.0 环境

1.在home目录下初始化一个测试环境并输出”Hello World “内容 (测试方式一,可忽略)

cd /home dotnet new console -o hwapp cd hwapp dotnet run

输出空内容如下:

[root@localhost hwapp]# dotnet run Hello World!

2.上传.net core的实例页面进行测试 (测试方式二、推荐)

Centos 下.net core 2 环境测试用例 (把它上传到/home目录下或自定义的目录)

下载地址:

http://down.51cto.com/data/2334968

执行以下命令

cd /home/WebApplication1 dotnet restore //如果使过用测试方式一,就需先执行这命令重新加载一下当前新的网站文件 dotnet run

运行后如下图:

 

 通过IE访问测试页

  

五、安装配置nginx对ASP.NET Core应用的转发

1.安装Nginx环境

[root@localhost ~]#curl -o nginx.rpm http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm [root@localhost ~]#rpm -ivh nginx.rpm [root@localhost ~]#yum install nginx -y

输入:systemctl start nginx 来启动nginx。

[root@localhost ~]# systemctl start nginx

输入:systemctl enable nginx 来设置nginx的开机启动(linux宕机、重启会自动运行nginx不需要连上去输入命令)

[root@localhost ~]#systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

2.通过iE检查能否访问

[root@localhost nginx-1.8.1]# ps -ef|grep nginx root 14626 1 0 08:47 ? 00:00:00 nginx: master process nginx nginx 14627 14626 0 08:47 ? 00:00:00 nginx: worker process root 14636 3269 0 08:49 pts/1 00:00:00 grep --color=auto nginx

nginx常用的操作命令

systemctl start nginx.service               #启动nginx服务

systemctl enable nginx.service             #设置开机自启动

systemctl disable nginx.service            #停止开机自启动

systemctl status nginx.service             #查看服务当前状态