1、安装 .net core 环境
rpm --import https://packages.microsoft.com/keys/microsoft.asc
sh -c 'echo -e "[packages-microsoft-com-prod] name=packages-microsoft-com-prod baseurl= https://packages.microsoft.com/yumrepos/microsoft-rhel7.3-prod enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/dotnetdev.repo'
yum update yum install libunwind libicu yum install dotnet-sdk-2.0.2
2、运行.net core
dotnet new console -o myApp cd myApp
dotnet run
3、运行asp.net core程序
需要安装nginx,具体操作见:https://www.cnblogs.com/taiyonghai/p/6728707.html
查看nigix是否运行:
[root@localhost ~]# ps -ef |grep nginx root 13159 1 0 15:28 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx nobody 13160 13159 0 15:28 ? 00:00:00 nginx: worker process root 13251 13223 0 15:32 pts/1 00:00:00 grep --color=auto nginx [root@localhost ~]# netstat -tlnup|grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13159/nginx: master
配置 nginx.conf
[root@localhost nginx]# vi /usr/local/nginx/conf/nginx.conf
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' # '$status $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name 192.168.2.118; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; #index index.html index.htm; 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; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }
4,、启动aspnetcore程序
5、在宿主机上访问:http://192.168.2.118/